How to check if graph builder legend is showing or notI was wondering what the script would be to check if the graph builder legend is showing or not. I want to make a toolbar shortcut that would show or hide the legend depending on the state the legend is in (if showing then hide and if hidden then show). thanks for any suggestions!
Steve
ScriptingRe: How to check if graph builder legend is showing or notThis is close enough so appreciate it! It's to bad there isn't something like <Re: How to check if graph builder legend is showing or not
If you use the Visibility message to open and close the Legend, the Get Visibility message will return the status.
names default to here(1);
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
gb =Graph Builder(
Size( 525, 448 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ) ),
Elements( Points( X, Y, Legend( 3 ) ) )
);
report(gb)[legendbox(1)]<<VISIBILITY></VISIBILITY>
However, the Visibility status will not change if the legend is set using
gb << Show Legend(0);
// or
gb << Show Legend(1);
Re: How to check if graph builder legend is showing or notI tried to check how I could see if legend is showing or not, but couldn't figure out how it is being hidden by Show Legend() option. Show properties didn't help either.

So only thing that easily came to my mind is to get script of the graph builder as string and then check if it has Show Legend(0) in it... this won't work if user has preferences changed so you will have to check for them also. Something like this might work (and there hopefully is easier/more robust way to do this):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:Sex), Y(:Height), Group X(:Age)), Elements(Box Plot(X, Y)));
change_legend_state = function({gb_ref}, {Default Local},
legend_pref = Char(Get Platform Preference(Graph Builder(Show Legend)));
gb_script = Char(gb_ref << Get Script());
If(Contains(legend_pref, "Show Legend(0)") & !Contains(gb_script, "Show Legend(1)"),
gb_ref << Show Legend(1);
,
gb_ref << Show Legend(0);
);
);
wait(1);
change_legend_state(gb);
wait(1);
change_legend_state(gb);