Scripting stacked bar chartsI'm trying to trigger a script from a bar chart. When clicking on one of the segments of the bar JMP highlights the segment and its corresponding row in the data table. I then want to trigger a scipr that would read various entries in that row and create another page of plots, basically a drill down in another pane. I can implement the mouse functions as described in the JSL manual and get the coordinates of the mouse. However, I lose the ability to select a cell, and row in the table, when I do this. With a bar chart I don't know how I'd map coordinates to a cell in the plot. In the past I've done this by having the user select the cell and then click a 'drill down' button. That certainly works, but it would be much more elegant if they could just click on the cell and have the drill down plots appear. Is there a way to script this?
Thanks!
Re: Scripting stacked bar chartsHi @vt_sailor,
If you have access to JMP 15.0, you might want to try a new feature called graphlets that automates most (if not all) of the work of creating a drill down workflow based on graph visual elements. Instead of row states like selections, it translates the subsetting criteria into local data filters - so it is captured along in the new graph. This way it is explicit, can be better understood and even further modified.
Check the answer to drill down in a graph hierarchy for more details.
Re: Scripting stacked bar chartsThank you! I rebooted and now everything works as expected. It was a bit
of a dance to eliminate the returns from the 'release' of the prior
selected rows but I have that working now.
Thanks again
Re: Scripting stacked bar chartsHere is an example, taken mostly from
Help==>Scripting Index==>Data Table==>Make Row State Handler
If you run this code, and then click on one of the bars in he displayed graph, you will see that he row state handler is executed immediatly
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
f = Function( {a}, Print( a ) );
rs = dt << make row state handler( f );
Graph Builder(
Size( 533, 448 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ) ),
Elements( Bar( X, Y, Legend( 4 ) ) )
);Re: Scripting stacked bar chartsThank you for the help. I tried making a row state handler and it almost
works. Just to try it out I asked it to print the values of one of the
columns to the log. When I click on the rows in the data table nothing
happens--until I execute some other statement and then it shows up in the
log. For example, in the code below, if I execute the first five lines and
then select various rows in the table nothing shows up in the log. Then,
when I execute the last line I see everything printed as I would expect.
Do you need some sort of a 'GO' at the end of the function?
Thanks
names default to here(1);
dt=current data table();
cc=column(dt,"Sum(Mean Ratio)");
f=function({X},print(char(cc[x])));
obj=dt<PRINT></PRINT>
Re: Scripting stacked bar chartsI believe the easiest way to do this, is to use a "Make Row State Handler" on the data table. Since clicking on a bar within a Stacked Bar chart, or any other chart, will change the selections in the Row State column, you should be able to pick up the information you need from code you execute in the row state handler.