- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
GraphBuilder - customize / reorder segs through JSL
In GraphBuilder when multiple components are added to the same graph, some components get hidden or are pushed behind others and are less visible.
Line segments below are behind the bar segments.
On the graph, there is the option to right-click > customize and re-order components using the up/down arrows and send the bar segments to the back.
I found a way to script this in JMP16 (full code below), but the same solution fails in JMP15.
Is there an equivalent solution for JMP15?
gbFB1 = report(gb)[Framebox(1)];
gbFB1 << Reorder Segs({1, 2, 5});
Thanks
Ray
Full JSL code to recreate:
dt_sampledata = New Table( "Exampe Data",
Add Rows( 24 ),
New Column( "Month",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Set Values(
[202101, 202101, 202101, 202101, 202102, 202102, 202102, 202102, 202103,
202103, 202103, 202103, 202104, 202104, 202104, 202104, 202105, 202105,
202105, 202105, 202106, 202106, 202106, 202106]
)
),
New Column( "Product",
Character( 16 ),
"Nominal",
Set Values(
{"ProductA", "ProductB", "ProductC", "ProductD", "ProductA", "ProductB",
"ProductC", "ProductD", "ProductA", "ProductB", "ProductC", "ProductD",
"ProductA", "ProductB", "ProductC", "ProductD", "ProductA", "ProductB",
"ProductC", "ProductD", "ProductA", "ProductB", "ProductC", "ProductD"}
)
),
New Column( "Volume",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[3869, 4964, 3188, 3109, 2623, 3447, 3179, 1038, 1781, 3195, 1621, 2034,
3231, 1390, 3187, 1998, 3280, 3570, 4443, 2150, 1638, 4083, 4242, 1186]
)
),
New Column( "Chem_A",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[5, 19, 45, 36, 35, 42, 28, 46, 33, 43, 19, 5, 11, 14, 47, 21, 5, 8, 33,
32, 7, 6, 9, 33]
)
),
New Column( "Chem_B",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[64, 38, 90, 41, 69, 70, 79, 75, 79, 59, 25, 71, 64, 65, 62, 51, 88, 79,
41, 47, 22, 62, 57, 38]
)
)
);
// Graph Builder
gb = dt_sampledata << Graph Builder(
Size( 1040, 562 ),
Variables(
X( :Month ),
Y( :Volume, Side( "Right" ) ),
Y( :Chem_A, Position( 1 ) ),
Y( :Chem_B, Position( 1 ) ),
Overlay( :Product )
),
Elements(
Line( X, Y( 2 ), Y( 3 ), Overlay( 0 ), Legend( 12 ) ),
Bar( X, Y( 1 ), Legend( 11 ), Bar Style( "Stacked" ) )
),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {12, [4, 5], 11, [0, 1, 2, 3]} )}
)
)
);gbFB1 = report(gb)[Framebox(1)];gbFB1 << Reorder Segs({1, 2, 5});
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: GraphBuilder - customize / reorder segs through JSL
In the JSL representation of Graph Builder, the order of the "segments" seems to be set by the order in which they appear in the Elements() argument.
Here's one idea on how to reorder the elements with JSL in JMP15. It assumes your dt_sampledata is the current data table.
// Graph Builder
gb = Graph Builder(
Size( 1040, 562 ),
Variables(
X( :Month ),
Y( :Volume, Side( "Right" ) ),
Y( :Chem_A, Position( 1 ) ),
Y( :Chem_B, Position( 1 ) ),
Overlay( :Product )
),
Elements(
Line( X, Y( 2 ), Y( 3 ), Overlay( 0 ), Legend( 12 ) ),
Bar( X, Y( 1 ), Legend( 11 ), Bar Style( "Stacked" ) )
)
);
Wait( 2 );
gbexpr = gb << get script;
// Find the position of the Elements() argument
i = 1;
While( Head( Arg( gbexpr, i ) ) != Expr( Elements ), i++ );
// Move forward the most background element to front
n = N Arg( Arg( gbexpr, i ) );
reordered_elem = Eval Expr( Elements( Expr( Arg( gbexpr, {i, n} ) ), Expr( Arg( gbexpr, {i, 1} ) ) ) );
// Replace old Elements() with the new re-ordered elements
Substitute Into( gbexpr, Arg( gbexpr, i ), Name Expr( reordered_elem ) );
// Replace the graph builder
gb << close window;
Eval( gbexpr );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: GraphBuilder - customize / reorder segs through JSL
In the JSL representation of Graph Builder, the order of the "segments" seems to be set by the order in which they appear in the Elements() argument.
Here's one idea on how to reorder the elements with JSL in JMP15. It assumes your dt_sampledata is the current data table.
// Graph Builder
gb = Graph Builder(
Size( 1040, 562 ),
Variables(
X( :Month ),
Y( :Volume, Side( "Right" ) ),
Y( :Chem_A, Position( 1 ) ),
Y( :Chem_B, Position( 1 ) ),
Overlay( :Product )
),
Elements(
Line( X, Y( 2 ), Y( 3 ), Overlay( 0 ), Legend( 12 ) ),
Bar( X, Y( 1 ), Legend( 11 ), Bar Style( "Stacked" ) )
)
);
Wait( 2 );
gbexpr = gb << get script;
// Find the position of the Elements() argument
i = 1;
While( Head( Arg( gbexpr, i ) ) != Expr( Elements ), i++ );
// Move forward the most background element to front
n = N Arg( Arg( gbexpr, i ) );
reordered_elem = Eval Expr( Elements( Expr( Arg( gbexpr, {i, n} ) ), Expr( Arg( gbexpr, {i, 1} ) ) ) );
// Replace old Elements() with the new re-ordered elements
Substitute Into( gbexpr, Arg( gbexpr, i ), Name Expr( reordered_elem ) );
// Replace the graph builder
gb << close window;
Eval( gbexpr );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: GraphBuilder - customize / reorder segs through JSL
There's a little bit more to it than JMP16 but still relatively short and neat.
And, an added bonus for me is that your solution has provided an introduction on how to parse and search the JSL GB script also.