Graphics script to detect graph titleI would like to set up a custom graphics script so each graph gets a unique line based on information contained in an associative array. In the example below, I want to have a graph on the line differently for each category... for my actual use, I will need the graph to 'recognize' the heading it's under so I can use the correct values for the line creation.
For the example image below, I manually updated the "F" graphics script to be "F". So I am looking to find syntax to "gather the graph info" ... in my head, if I can grab the outline box title, I can manipulate that to get what I need... but I am not sure if that is the only/best option.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);

Mass CustomizationRe: Graphics script to detect graph title@Mark_Bailey Thanks for that idea! It's good to know that summarize will match the order of how the graphs will be created in the report. That's something I can see uses for in several of my scripts 
@Craige_Hales That's a really cool idea with the function, I'll have to play with that, too!
Re: Graphics script to detect graph titleIf you make the entire graphic script a function, it gets a this parameter that is the frame box. You can climb up to the outline to grab the title. The benefit is knowing you got the outline containing this graph.
Outline title copied into graph by graphic scriptOutline title copied into graph by graphic scriptOutline title copied into graph by graphic script
dt = Open( "$sample_data/big class.jmp", invisible );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );
(bv << report)[framebox( 1 )] << addgraphicsscript(
// if a function is used, it must be the only statement in the graphic script
Function( {this},{titlebox=this},
// the function can use this to find the frame box, climb to an Outline title...
While( (titlebox << classname) != "OutlineBox", titlebox = titlebox << parent );
// then other graphics commands
Text( center justified, {60, 120}, (titlebox << gettitle) );
Circle( {60, 120}, 30 );
this<<BACKGROUNDCOLOR></BACKGROUNDCOLOR>Re: Graphics script to detect graph titleAnother approach might be to determine the values before you launch Bivariate. The Summarize() function can be used to determine the levels in the same order and they appear when using a By variable or Where() clause.
Summarize( level = By( :Group ) );
The variable level stores a list of strings of all the unique levels in the :Group data column in the right order. So you graphics script does not need to query the outline display box to find out where it is.
Re: Graphics script to detect graph titleThat could work too, @jthi ... as written it wouldn't be as dynamic as I would need long term, but I could use that to build in a custom iterator variable so each graph has teh same variable, but set to a different number, corresponding to it's place in the report.
Thanks again to everyone for their thoughts!
Re: Graphics script to detect graph titleExpanding on one of codes by @txnelson :
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Grid Line Order(1 ), Reference Line Order( 3)}
)
)
);
rep = biv << Get As Report;
For( i = 1, i <= N Items(rep), i++,
keyForAa = Substr(Report(rep [i])[Outline Box( 1 )] << get title,
Contains(Report(rep [i])[Outline Box( 1 )] << get title, "=" ) + 1);
//see Add Graphics Script example from Scripting Index
framebox = Report(rep [i])[frame box(1)];
Eval(EvalExpr(framebox << Add Graphics Script(
2,
Description( "" ),
Y Function(Expr(test[keyForAa][1]) * x + Expr(test[keyForAa][2]), x );
)));
);Re: Graphics script to detect graph titleThat's fascinating that you can start i at 0 and it just 'magically' iterates like that... I got the errors pasted below, but seems to have at least worked some. I created a show(i) command just before creating the graphInfo variable.
It seems to have worked great for the two graphs, but for some reason it also iterated two more times resulting in an inability to locate biv[i] ... so I wrapped that part in a Try() and it seemed to work as necessary!
1) I am not sure why "i" iterates like that or when I could potentially utilize that for other functions in jsl
2) I am not sure why it seems to iterate two more times ... one per graph, one per graphics script??
3) Thank you so much for the help here... I may not understand the how/why it works yet, but if I can get it to work consistently, that's the win!

Names default to here(1);
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
show(i);
Try(
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);Re: Graphics script to detect graph titleTry this
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);Re: Graphics script to detect graph titleThat's just it .... from within the graphics script itself, can I know that information?
Getting the title is easy from outside.
I want to be able to place the exact same graphics script into each graph of a report and have that script be able to figure out where it is.
Re: Graphics script to detect graph titleYou will need to know which Outline Box you need to get the title from, but after that, it is a simple get title
graph title = report( biv[1] )[OutlineBox(1)] << get title;
Re: Graphics script to detect graph titleI wasn't looking to update the title, but to grab the title information ... from within the Graphics Script. I can do all the string manipulation once I have the title information.
Ideally I need something to put within the graphics script which is like "graphTitle = graph << get title;" and go from there, but I am not sure that's possible unless the object "knows" which part of the tree it's contained within...
Re: Graphics script to detect graph titleHere are the modifications to your script that will update the titles

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);
For( i = 1, i <= N Items( biv ), i++,
Report( biv[i] )[Outline Box( 1 )] << set title(
Substr(
Report( biv[i] )[Outline Box( 1 )] << get title,
Contains( Report( biv[i] )[Outline Box( 1 )] << get title, "=" ) + 1
)
)
);