Graph Builder Dynamic SubtitlesHello, 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".
Automation and ScriptingRe: Graph Builder Dynamic Subtitlesmin / 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).
Re: Graph Builder Dynamic SubtitlesTo 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 )
Re: Graph Builder Dynamic SubtitlesAnd 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 );
Re: Graph Builder Dynamic SubtitlesI 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 onceRe: Graph Builder Dynamic Subtitlesrelated discussion - with similar solutions:
Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?
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:

Re: Graph Builder Dynamic SubtitlesHello, 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.
Re: Graph Builder Dynamic SubtitlesLike 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 ) ) )}
)
)
);Re: Graph Builder Dynamic SubtitlesThat worked wonderfully! Thank you so much!