Hello community,
I come to you with a difficult question. Please see the image below for reference. I am using JMP 18, and I am trying to create a bar chart to show PPB values by quarter for various categories. The trouble I run into is that I want the category that has the highest total value from the chart to be on the bottom of the stack. For example, in the image below the category memory should be on the bottom of all the bar stacks followed by metal and so on. I know I can manually change the positions of these but that is where the complicated part of this question comes in.
From the image below you can see I have a local data filter where you can look at different technologies. Changing the different views drastically changes the total values for the overlay categories. I need a script that automatically reorders the overlay categories as I described before, every time the local data filter was changed.
I have been able to create a function that activates when the local data filter changes. I cannot figure out how to get the values of the categories that appear on the graph into some type of array so that I can create a custom order and then apply that to the graph. Does anyone know how to do this?
Here is some sample code for the function that activates when the local data filter changes:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dist = Distribution(
Automatic Recalc( 1 ),
Continuous Distribution( Column( :POP ) )
);
filter = dist << Local Data Filter(
Add Filter( columns( :Region ) )
);
f = Function( {a},
Print( a );
Print( "you can glue additional code to this function" );
Return( y = a - 5 );
);
rs = filter << Make Filter Change Handler( f );
Here is the code for the graph builder:
PPM_TABLE << New Script("SubMech PPB by Quarter (Technologies)",
names default to here(1);
gb = Graph Builder(
Transform Column(
"PPB",
Set Properties("Configure Level", 1),
Set Property(
"Value Order",
{Custom Order(_subMech)}
),
Formula(:Sub Mech)
),
Size( 1120, 685 ),
Show Control Panel( 0 ),
Variables(
X( :CLNDR_YR_QTR_TXT ),
Y( :Net Shipments, Side( "Right" ) ),
Y( :PPB, Position( 1 ) ),
Overlay( :Sub Mech )
),
Elements(
Bar( X, Y( 2 ), Legend( 11 ), Bar Style( "Stacked" ), Label( "Label by Value" ) ),
Line( X, Y( 1 ), Overlay( 0 ), Legend( 10 ) )
),
Local Data Filter(
Add Filter(
columns( :Year, :TECH, :Fail Mech, :Sub Mech ),
Where( :TECH == "160k" ),
Where( :Fail Mech == {"*MUST SELECT", "Fab Related"} ),
Display( :TECH, N Items( 11 ), "Radio Box Display" ),
Display( :Fail Mech, N Items( 7 ), "Check Box Display" ),
Display( :Sub Mech, N Items( 7 ), "Check Box Display", Find( Set Text( "" ) ) )
)
),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model( 10, Properties( 0, {Line Color( 0 )}, Item ID( "Mean(Net Shipments)", 1 ) ) )}
),
Dispatch( {}, "graph title", TextEditBox,
{Set Text( "Fab 4 PPB by Quarter (Technologies by Sub Mechanism)" )}
),
Dispatch( {}, "400", LegendBox,
{Legend Position( {11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 10, [0]} )}
)
)
)
);