Remove and add wrap variables in graph builder with JSLWhen I manually add a line in graph builder via the costume graph script function in the window and then wrap or group it with a nominal variable, the stacked windows will have the same costume line copied.
Right click in the graph windows --> Customize --> click on the “+” button (add the “Script” entry) and add the line script (for example with the Samples --> “Drag Line” option).
But if I then save the script to the data table, every windows has now an entry to add the costume graph and can become very long. I would need to program a complicated for loop to add the graph code to each window.
I want to make the same steps in JSL as by hand:
- create graph
- set costume line
- add the wrap column
Mass CustomizationRe: Remove and add wrap variables in graph builder with JSLCode snippet to add and remove a wrap variable. This came from the online discovery summit 2021 unsession JSL scripting.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
//make initial graph
gb = Graph Builder(
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y ), Smoother( X, Y ) )
);
//get a reference to the grab builder box
gbb = Report( gb )[Graph Builder Box( 1 )];
Wait( 1 );
//add a wrap variable to demonstrate adding
gbb << Add Variable( {:age, Role( "Wrap" )} );
Wait( 1 );
//remove wrap variable
gbb << Remove Variable( {:age, Role( "Wrap" )});
Wait( 1 );
//add graphics script
gbb[frame box( 1 )] << Add Graphics Script(
2,
Description( "" ),
If( Is Empty( g_x4 ),
g_x4 = [52.92, 68.48, 70.56];
g_y4 = [119.69, 139.30, 124.01];
);
Drag Line( g_x4, g_y4 );
);
//add wrap variable
gbb << Add Variable( {:age, Role( "Wrap" )} );Script by @julian THX a lot.
Re: Remove and add wrap variables in graph builder with JSLThe following example uses the <
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
gb = dt << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 2 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
Report( gb )[FrameBox( 1 )] << Add Graphics Script(
If( Is Empty( g_x1 ),
g_x1 = [50.53, 66.28, 64.49];
g_y1 = [102.99, 45.69, 106.10];
);
Drag Line( g_x1, g_y1 );
);
Report( gb )[Graph Builder Box( 1 )] << Add Variable( {:age, Role( "Wrap" )} );
I hope that helps.