cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hogi
Level XI

Hover Labels: send a more precise filter?

I want to generate a hover graphlet from another data table following a recipe provided by @nascif_jmp.

 

The problem that I am facing can be reproduced with a single data table.

The below example looks extremely boring - "why does he want to plot a single point ?!?"

... but makes sense when two different data tables are used [main data table with median values, hover plot with individual values]  : )

 

When hovering over a data point, I want the hover graphlet  to be restricted to the data corresponding exactly to the single data point.

my problem: the data point is not fully described by the columns used for x and y axis. In the example.
[I use sex and age on the axes leading to several data points for each sex and age.]

Hovering over one of the data points just restricts the hover graphlet by sex and age, but not to the single data point (which I could get via name  etc).

So, how to get a more precise specification of the data point beyond the x/y axis - without affecting the main graph?

I tried to use Color or Size, but those settings are just ignored by the Hover Label Framework.

 

Is there a way to tell the Hover Label Framework to pipe an additional column filter to the Hover Label - without changing the main graph?

 

2 points instead of a single point [corresponding to the entries in the hover label Gridlet: Marion, F, 16]: 

hogi_0-1678897139261.png

 

 

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Graph Builder( Variables( X( :sex ), Y( :age ), Color( :name ) ), Elements( Points( X, Y, Legend( 19 ) ) ), SendToReport( Dispatch( {}, "Graph Builder", FrameBox, {Set Graphlet( Picture( Graph Builder( Variables( Y( :height ) ), Elements( Points( Y, Legend( 6 ) ) ) ) ) )} ) ) )

 

 

 

6 REPLIES 6
jthi
Super User

Re: Hover Labels: send a more precise filter?

 Scripting Guide > Scripting Graphs > Hover Labels > Work with the Hover Label Execution Context is really helpful with hoverlabels

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Variables(X(:sex), Y(:age), Color(:name)),
	Elements(Points(X, Y, Legend(19))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Textlet(
				Setup(
					local:encodedWhere = XML Encode(local:_where);
					Show(Namespace("local") << Get Contents());
				),
				Markup(
					"
<b>Groupings</b>: {local:_groupings}
<b>Measurements</b>: {local:_measurements}
<b>Summary statistic</b>: {local:_summaryStatistic}
<b>Filter columns</b>: {local:_filters}
<b>Where clause</b>: {local:encodedWhere}
<b>Graph type</b>: {local:_displaySegName}
<b>Data table</b> {local:_dataTable}
<b>Drill depth</b>: {local:_drillDepth}
<b>First Row</b>: {local:_firstRow}
<b>Underlying Rows</b>: {local:_underlyingRows}
"
				)
			)}
		)
	)
);

If you run that and take a look at log, you should be able to access the name value

Namespace("local") << Get Contents() = {{"_filters", {:sex, :age}}, {"_mode", "Textlet"}, {"_where", ":sex == \!"F\!" & :age == 16"}, {"_age", 16}, {"_name", "MARION"}, {"_sex", "F"}, {"_groupings", {:sex, :age}}, {"_firstRow", 36}, {"_underlyingRows", 1}, {"_measurements", {}}, {"_displaySegName", "MarkerSeg"}, {"_dataTable", DataTable("Big Class")}, {"_summaryStatistic", ""}, {"_drillDepth", 1}, {"_xaxis", 0}, {"_yaxis", 0}, {"_customData", [=>]}, {"_localDataFilter", "Local Data Filter(
	Close Outline(1),
	Add Filter(columns(:sex, :age), Where(:sex == \!"F\!"), Where(:age == 16))
)"}, {"_whereExpr", :sex == "F" & :age == 16}, {"encodedWhere", ":sex == &quot;F&quot; &amp; :age == 16"}};

but I'm not sure if you can (easily) force the name filter in plotter graph. You can remove filters with Skip Filter but no idea about adding them Scripting Guide > Scripting Graphs > Hover Labels > Add Graphs or Images to Hover Labels Using Graph... . Subset workaround is one option

 

Overlay would let you filter to that level, but that isn't really helpful as you cannot hover over that single point...

-Jarmo
hogi
Level XI

Re: Hover Labels: send a more precise filter?

I mean:
a solution which I can show to my colleagues which have a 30 day trial license - to convince them that Jmp is SOOOOO useful and SOOOO easy.

 

hogi
Level XI

Re: Hover Labels: send a more precise filter?

Adapting the code from Hover-graphlet-from-another-data-table#M55890, I guess it will be something like the below code - but I hope that there is a non-JSL (2 clicks?) version available.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

mainGB = dt << Graph Builder( Variables( X( :sex ), Y( :age ), Color( :name ) ), Elements( Points( X, Y, Legend( 19 ) ) ) );
Report( mainGB )["Graph Builder", FrameBox( 1 )] << Set Graphlet(
	Picture(
		getGraphlet = Function( {row},
			{gb},
			gb = Graph Builder( Variables( Y( :height ) ), Elements( Points( Y, Legend( 6 ) ) ) );
			gb << Local Data Filter( Close Outline( 1 ), Add Filter( columns( :name ), Where( :name == :name[row] ) ) );
			gb;
		);
		If( local:_mode == "Click",
			New Window( "Wafer Graphlet", getGraphlet( local:_firstRow ) );
			Empty();
		,
			plt = Platform( local:_dataTable, gb = getGraphlet( local:_firstRow ) );
			Picture Box( (gb << report)[Picture Box( 1 )] << Get Picture( 0.5 ) );
		);
	),
	Skip Filters( 1 )
);
hogi
Level XI

Re: Hover Labels: send a more precise filter?

hogi
Level XI

Re: Hover Labels: send a more precise filter?

Much easier than I feared ...

I just learned a super cool trick from @Jasean :
restrict the hover graph via "Where"

 

 

Then one can start with @jthi 's  findings:
https://community.jmp.com/t5/Discussions/Hover-Labels-send-a-more-precise-filter/m-p/612705/highligh...

All you have to do is add (edit *)

 Where( :name == local:_name )

or

 Where( :name == _name )

 

 *) but not Where( :name == :_name ) !

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Graph Builder(
        Variables( X( :sex ), Y( :age ), Color( :name ) ),
        Elements( Points( X, Y, Legend( 19 ) ) ),
        SendToReport(
               Dispatch(
                       {},
                       "Graph Builder",
                       FrameBox,
                       {Set Graphlet(
                               Picture( 
                                      Graph Builder( 
                                              Variables( Y( :height ) ), 
                                              Elements( Points( Y, Legend( 6 ) ) ),
                                             Where( :name == local:_name )
                                      )
                               )
                       )}
               )
        )
);

 

 

Jasean
Staff

Re: Hover Labels: send a more precise filter?

Nice.  That is even better than what I sent you.  I learned something, too.  By the way, you should add the namespace name before the colon (:) or remove the colon in front of _name.  It is a variable in the local namespace, not a column.

local:_name
// or simply
_name