cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
ACraig
Level I

Graph Builder Dynamic Subtitles

Hello, I was hoping someone could help me figure out how to make it so that the subtitle of my graph would be take the min(:Year) and max(:Year) and use them in the subtitle. So, if the minimum year was 2018 and the maximum was 2025 then the subtitle would be "2018 - 2025".

1 ACCEPTED SOLUTION

Accepted Solutions
mmarchandFSLR
Level VI

Re: Graph Builder Dynamic Subtitles

Like this?

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/US Regional Population.jmp" );
dt:Year << Data Type( "Numeric" );
dt << Graph Builder(
	Show Control Panel( 0 ),
	Show Subtitle( 1 ),
	Variables( X( :Year ), Y( :Population ), Overlay( :Region ) ),
	Elements( Points( X, Y, Legend( 18 ) ) ),
	SendToReport(
		Dispatch( {}, "graph 1 title", TextEditBox,
			{Set Text( Char( Col Min( :Year ) ) || " - " || Char( Col Max( :Year ) ) )}
		)
	)
);

View solution in original post

8 REPLIES 8
hogi
Level XIII

Re: Graph Builder Dynamic Subtitles

min / max form the local data filter - or from the whole data set?

 

For the Data filter, please have a look at https://marketplace.jmp.com/appdetails/Graph+Builder+Toolbar 
One of the shortcuts allows you to use the settings of the data filter as title (not subtitle).

(view in My Videos)

 

hogi
Level XIII

Re: Graph Builder Dynamic Subtitles

To make it adjust the subtitle, go to  C:\Users\_username_\AppData\Roaming\JMP\JMP\Addins\hogi.GraphBuilderToolbar\resetAxisLabels.jsl

and change line 36 to

gb[Text Edit Box( 2 )] << Set Text( title ); // was Text Edit Box( 1 )

 

(view in My Videos)

hogi
Level XIII

Re: Graph Builder Dynamic Subtitles

And based on the data in the table, it is something like:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/US Regional Population.jmp" );
:Year << data type(numeric);
Graph Builder(
	Show Subtitle( 1 ),
	Variables( X( :Year ), Y( :Population ), Overlay( :Region ) ),
	Elements( Line( X, Y ) )
);
dt << select  where  (:year < 1950 ) << exclude(1) << select where(0);


// ---------------



myRows=where(dt, not (excluded()));
min = Char(min (dt[myRows,"Year"]));
max = Char(min (dt[myRows,"year"]));

((Current Report() << XPath( "//OutlineBox[@helpKey='Data Filter']" )) << get scriptable object) << Show Subtitle( 1 )  ;
current report()[Text Edit Box( 2 )] << Set Text( min || " — " || max );
ACraig
Level I

Re: Graph Builder Dynamic Subtitles

Hello, sorry for the confusion, I should have been more specific. From the whole data set. As my data set updates, I would want those dates to update as well in the subtitle.

mmarchandFSLR
Level VI

Re: Graph Builder Dynamic Subtitles

Like this?

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/US Regional Population.jmp" );
dt:Year << Data Type( "Numeric" );
dt << Graph Builder(
	Show Control Panel( 0 ),
	Show Subtitle( 1 ),
	Variables( X( :Year ), Y( :Population ), Overlay( :Region ) ),
	Elements( Points( X, Y, Legend( 18 ) ) ),
	SendToReport(
		Dispatch( {}, "graph 1 title", TextEditBox,
			{Set Text( Char( Col Min( :Year ) ) || " - " || Char( Col Max( :Year ) ) )}
		)
	)
);
ACraig
Level I

Re: Graph Builder Dynamic Subtitles

That worked wonderfully! Thank you so much!

jthi
Super User

Re: Graph Builder Dynamic Subtitles

I assume as you are talking about "dynamic" subtitles you mean when using Local Data Filter? You will have to use some script to add << Make Filter Change Handler to your local data filter. 

Not sure how robust this example is, but it gives an idea of how to use << make filter change handler

 

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Show Subtitle(1),
	Variables(X(:weight), Y(:height), Overlay(:sex)),
	Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11))),
	Local Data Filter(Add Filter(columns(:height)))
);

// Reference to filter
ob_filter = (gb << Top Parent) << XPath("//OutlineBox[@helpKey='Data Filter']");
ob_filter = ob_filter[1];
ldf = ob_filter << Get Scriptable Object;


f = Function({a},
	dt = gb << Get Data Table;
	
	w = ldf << Get where clause;
	If(Is missing(w),
		minval = Col Min(:height);
		maxval = Col Max(:height);
	,
		Substitute Into(w, "Select ", "Get Rows ");
		r = Eval(EvalExpr(Send(dt, Expr(Parse(w)))));
		minval = Min(dt[r, "height"]);
		maxval = Max(dt[r, "height"]);
	);		
	
	title = Eval Insert("^minval^ < height: < ^maxval^");
	gb << Dispatch({}, "graph 1 title", TextEditBox, {Set Text(title)});
);

rs = ldf << Make Filter Change Handler(f);

f(0); // run once
-Jarmo
hogi
Level XIII

Re: Graph Builder Dynamic Subtitles

related discussion - with similar solutions:
Is it possible to dynamically update "graph title" based item selection in local data filter (includ... 

 

here are wishes to add this feature to JMP - without the need for scripting:
Auto population of title - graph builder 

Local Data Filter: option use the selection as graph title 
the idea: the user can specify which entries of the data filter are added to the title:

hogi_0-1764748000408.png

Recommended Articles