I have a use case to build a chart which will have a drill-down capability.
The user will click on a point on the chart and, using the Mousetrap() function a script will run which will pop up a new window containing another chart with some more detailed drill down information.
I want to then support an additional level of drill down from this first pop-up window.
I will illustrate with a simple example using BigClass dataset in the attached script.
The notes in the script highlight the problem : with only one mouse-trap() function call, the first drill down works.
But if I add a second mouse-trap, specifically adding it to the graph that will result from the first drill-down, what instead happens is that the second drill-down action is applied to the first mouse click, which wasn't expected.
Not sure if it's possible to use MouseTrap() like this or not ?
d
@Mark_Bailey thanks for the reference to graphlets!
@tsl so you want to drill down across multiple levels. Very nice, this is a great way to learn about your data using the data visualization itself to narrow your focus.
Let us count the ways you can do that in JMP15 using graphlets. This new feature follows a "porcelain + plumbing" architecture, meaning there are pre-defined, easy-to-use ways to accomplish standard behavior, built on top of a programming (JSL) API that you can also access to implement custom cases. The scenario you described can be implemented using two different "porcelain", or point-and-click, approaches.
If your focus is on a particular, single, measurement - say height - you can use a Graphlet Preset like Histogram. After creating your baseline graph, right-mouse click on the graph background to access the new "Hover Label" menu. From there you will see the preset options

A graphlet preset will create a graphlet of the indicated visualization type, deriving the role mapping from the variables selected in the baseline graph. Since the baseline graph is showing counts of the height variables, the histogram graphlet preset will automatically show the distribution of that variable for each given bar. But each bar already filters down to a single height value, so it is not an interesting distribution. Let's say our baseline was a histogram instead; a histogram preset would show the distribution of the values on each bin:

Note how the hover label thumbnail acts like a graph preview. If you go ahead and click on the thumbnail image, it will launch the equivalent graph on a new window. This new graph is filtered down to include only the rows corresponding to the hovered over visual element (in this case, the 60-62 bin), implementing the drill-down operation. The filter operation is implemented using a collapsed Local Data Filter, making it resilient to unrelated selection changes and allowing for further exploration through changes in the filter settings.

Another characteristic of Graphlet Presets is that they are pre-configured to be recursive, in order to support advanced drill-down scenarios. So you can go ahead and interact with the bins in the new histogram. You will see that you can drill-down on them as well:

Now the .jsl example attached to the page had a more complex drill-down scenario, where visualization types and role assignments were chosen to specific values at each drill-down level:
* Level 0 (baseline): height value counts
* Level 1: box plot of weight by sex
* Level 2: row details displayed on log
This level of customization can still be accomplished using a different type of "porcelain": the Paste Graphlet command. This command allows the user to "stack" graphlet definitions, which will be used as the user drills down on visual elements at each level.
So after creating the baseline graph, go ahead and create graphs representing each of the desired drill-down levels. Don't worry about filtering - as in the previous case, that will be done for you automatically. Then - starting with the last level - copy its script to the clipboard:

Then move to the preceding graph and then paste (the script as a) graphlet:

In the images above, we pasted the level 1 drill-down graph (the weight by sex graphlet) into the baseline graph. The result:

As this scenario was defined, there was no need for a level 2 paste graphlet. Showing the row values for the hovered visual element is already the default behavior for hover labels. Here is what we would see on a second level drill-down, after hovering over the second box plot:

By right-mouse clicking on the hover label the user can copy its contents, subset the data, or further change the hover label configuration.
I hope this was helpful. For a categorical drill-down example, check the answer to https://community.jmp.com/t5/Discussions/drill-down-in-a-graph-hierarchy/m-p/11702
More information about Hover Label customizations can be found at: https://www.jmp.com/support/help/en/15.0/index.shtml#page/jmp/add-hover-graphs.shtml#
Info on graphlets specifically is at: https://www.jmp.com/support/help/en/15.0/index.shtml#page/jmp/add-graphs-or-images-to-hover-labels.s...
Cool idea! Move your code into a function and it works:
makesubset = Function( {_x},
{TestWin}, // local variables
dt << select where( :height == _x );
TestWin = New Window( "Drill Down Window",
dt << GraphBuilder( Size( 534, 448 ), Show Control Panel( 0 ),
Where( Selected() ), Variables( X( :sex ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 4 ) ), Box Plot( X, Y, Legend( 5 ) ) )
)
);
TestWin[FrameBox( 1 )] << add graphics script(
Mousetrap(
_x2 = Round( X, 0 );
Show( _x2 );
)
);
);
dt = Open( "$sample_data/big class.jmp" );
dt << Graph Builder( Size( 527, 454 ), Show Control Panel( 0 ),
Variables( X( :height ) ), Elements( Bar( X, Legend( 6 ) ) ),
SendToReport( Dispatch( {}, "Graph Builder", FrameBox,
{Add Graphics Script( 2, Description( "Script" ),
Mousetrap(
_x = Round( X, 0 );
makesubset( _x );
)
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);It behaves the way you describe because the Mousetrap function isn't really executed like other functions. The <
I suspect it keeps the last one. The scanning will not follow into the function call, and the function call may make your JSL easier to read and maintain.
@EvanMcCorkle Yes, it seems odd that it finds a mousetrap inside of a mousetrap.
JMP 15 introduced 'hover labels' for exactly this purpose. There are three aspects that work together: graphlets, textlets, and gridlets.
See Help > JMP Documentation Library > Scripting Guide > Chapter 9: JMP Reports, page 512. There is a lot of explanations and examples to learn how to implement drill down behaviors.