Subscribe Bookmark RSS Feed

Obtain Filtered Data within Graphics Script in Graph Builder when using Wrap

Hank

New Contributor

Joined:

Dec 5, 2016

I would like to know what data is being plotted within each the graph in Graph Builder when using the Wrap option. To be clear here's an example code of the situation:

 

// Define constants
MoreThanNecessary = 100;

// Open example dataset
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );

// Randomly exclude rows
rEnd = Random Integer( 1, N Rows() );
rStart = Random Integer( 1, rEnd );
r = dt << Select Rows( rStart::rEnd );
r << Hide and Exclude();

// Plot pie charts using Graph Builder
gb = Graph Builder(
	Variables( X( :Number of Fillings ), Wrap( :Age Group ) ),
	Elements( Pie( X, Legend( 3 ) ) )
);

// Customize text in each graph
For( i = 1, i <= MoreThanNecessary, i++,
	Report( gb )[FrameBox( i )] << Add Graphics Script(
		1, Description( "Custom Text for Each Graph" ),
		GraphTitle = "Get indication of what data is plotted";
		If(
			GraphTitle == "25-29",
			Text( Right Justified, {1, 0}, "Late 20s" ),
			GraphTitle == "30-34",
			Text( Right Justified, {1, 0}, "Early 30s" ),
			GraphTitle == "35-39",
			Text( Right Justified, {1, 0}, "Late 30s" ),
			Text( Right Justified, {1, 0}, "40 or over" )
		);
	)
);

 

2 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

Maybe you can elaborate on what you mean when you say 'know what data is being plotted'? Onece you have done your random 'hide and exclude' it's easy enough to figure out which rows remain for each level of :Age Group. But I have the sense you need something more.

 

Hank

New Contributor

Joined:

Dec 5, 2016

Hi Ian,

 

I don't know why but I think the second half of the initial post got wiped out by the forum.

 

If you try to run the script I initially posted, the labels "Late 20s" and "Early 30s" etc are not shown with the proper data. "Late 20s" should be shown with the "25-29" graph, "Early 30s" with "30-34", etc. Right now it just shows "40 or over" for all the graphs. Ideally each graphics script in each graph need to figure out what is being plotted in its own graph. I was hoping for the graphcis script to be able to access the text above each graph (i.e., GraphBuilderGroupBox(2), GraphBuilderGroupBox(3), etc.) but there are no accessible properties for those display box elements. I hope this clarifies the problem.

 

Thanks,

Hank