cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lala
Level VIII

Can JMP graphics have this effect?

This is the HTML effect.
Can JMP graphlet achieve this effect?

Thanks!

test.gif

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: Can JMP graphics have this effect?

 


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
fb = Report( gb )[FrameBox( 1 )];
xx = yy = 0;
fb << addgraphicsscript(//
	Mousetrap(
		xx = x;
		yy = y;
	);
	V Line( xx );
	// at this point you can highlight all the values near xx
	For( irow = 1, irow <= N Rows( dt ), irow += 1,
		If( Abs( dt:height[irow] - xx ) < 0.5, // big class height step is 1, <.5 selects a single column of weights
			Marker( Marker State( 4 ), {dt:height[irow], dt:weight[irow]} )
		)
	);
	xwidth = X Range();
	xmidpoint = X Origin() + xwidth / 2;
	If( xx < xmidpoint,
		Text( {xx + xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nmore" )//
	,
		Text( right justified, {xx - xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nmore" )
	);
	//	
);

edit: Line 18 now says xx rather than x. Must have been something left over in my namespace. Thanks @lala  @hogi 

Craige

View solution in original post

Re: Can JMP graphics have this effect?

Slightly changed the script to display weight values instead of more:

 

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
fb = Report( gb )[FrameBox( 1 )];
xx = yy = 0;
valuesMatrix = :height << Get Values; //***new*** Get column values for height
fb << addgraphicsscript(//
	Mousetrap(
		xx = x;
		yy = y;
	);
	V Line( xx );
	// at this point you can highlight all the values near xx
	For( irow = 1, irow <= N Rows( dt ), irow += 1,
		If( Abs( dt:height[irow] - xx ) < 0.5, // big class height step is 1, <.5 selects a single column of weights
			Marker( Marker State( 4 ), {dt:height[irow], dt:weight[irow]} )
		)
	);
	
	valuesRows = char(:weight[loc(valuesMatrix,round(xx))]); //***new*** write to char weight values for all rows of height at position round(xx)
	xwidth = X Range();
	xmidpoint = X Origin() + xwidth / 2;
	If( xx < xmidpoint,
		Text( {xx + xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nweight " || valuesRows  )////***new*** exchanged "more" with weigth and list of weight values for that location of height
	,
		Text( right justified, {xx - xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nweight " || valuesRows )
	);
	//	
);

you may even could add sorting the values ascending/descending. 

/****NeverStopLearning****/

View solution in original post

17 REPLIES 17
hogi
Level XII

Re: Can JMP graphics have this effect?

via JSL, yes.

hogi
Level XII

Re: Can JMP graphics have this effect?

via (JSL-free) Graph Builder: not yet. Maybe in a future release?

More and more competitor programs provide this type of annotations, so I guess it will also be implemented in JMP.

You can go to New type of cross hair for line and smoother type charts and support @shampton82 's  wish.

Craige_Hales
Super User

Re: Can JMP graphics have this effect?

 


dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
fb = Report( gb )[FrameBox( 1 )];
xx = yy = 0;
fb << addgraphicsscript(//
	Mousetrap(
		xx = x;
		yy = y;
	);
	V Line( xx );
	// at this point you can highlight all the values near xx
	For( irow = 1, irow <= N Rows( dt ), irow += 1,
		If( Abs( dt:height[irow] - xx ) < 0.5, // big class height step is 1, <.5 selects a single column of weights
			Marker( Marker State( 4 ), {dt:height[irow], dt:weight[irow]} )
		)
	);
	xwidth = X Range();
	xmidpoint = X Origin() + xwidth / 2;
	If( xx < xmidpoint,
		Text( {xx + xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nmore" )//
	,
		Text( right justified, {xx - xwidth / 100, yy}, "height " || Char( Round( xx ) ) || "\!nmore" )
	);
	//	
);

edit: Line 18 now says xx rather than x. Must have been something left over in my namespace. Thanks @lala  @hogi 

Craige
lala
Level VIII

Re: Can JMP graphics have this effect?

2024-11-10_19-28-58.png

hogi
Level XII

Re: Can JMP graphics have this effect?

@Craige_Hales , nice, very smooth! : )

Almost too smooth: I hope this example will not stop the developers from implementing a non-JSL approach.
some arguments for a native support via Graph Builder:

- make native Graph Builder more powerful

- make the non-JSL users happy as well

- show the automatic fancy annotations even without mouse clicks
  ->  allow the users to use the mouse as usual to select data points
   (with the current "JSL" approach, one might add some toggle buttons to choose the correct mode - like it's implemented for Venn Diagram )

 

It took me a while to understand the error message!

Names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
// x=y=60;
fb = Report( gb )[FrameBox( 1 )];
fb << addgraphicsscript(//
	If(Not( Is Empty( x ) ), // if the mouse did not yet enter the graph -> do nothing.
		Mousetrap("nothing to do");
		V Line(x);
	// at this point you can highlight all the values near xx
		For( irow = 1, irow <= N Rows( dt ), irow += 1,
			If( Abs( dt:height[irow] - x ) < 0.5, // big class height step is 1, <.5 selects a single column of weights
				Marker( Marker State( 4 ), {dt:height[irow], dt:weight[irow]} )
			)
		);
		xwidth = X Range();
		xmidpoint = X Origin() + xwidth / 2;
		If( x < xmidpoint,
			Text( {x + xwidth / 100, y}, "height " || Char( Round( x ) ) || "\!nmore" )//
		,

			Text(
				right justified,
				{x - xwidth / 100, y},
				"height " || Char( Round( x ) ) || "\!nmore"
			)
		);
	)
	//	
);

 

Craige_Hales
Super User

Re: Can JMP graphics have this effect?

@hogi MouseTrap is a strange thing in JSL. It is a function that does nothing when executed and doesn't matter if it is executed or not or (mostly) where it is positioned in the script. When a mouse move happens on the graph, the coordinates are sent to the script in x,y which need to be copied into globals as shown.

Handle, and the various Drag variants, have a position associated with them and will only activate if close enough. The order does matter, a little, because the first one encountered in the script that is close enough (a few pixels) will get the update.

I can't fully explain why it works with your change. X really shouldn't exist... it appears it escapes the mousetrap!

I repaired the script in my first post.

Craige
lala
Level VIII

Re: Can JMP graphics have this effect?

I SEE

  • Hold down the left button to move automatically change.

Thank Craige!

hogi
Level XII

Re: Can JMP graphics have this effect?

I just found this information in the Scripting Index:

hogi_0-1731245964407.png

 

 

 

 

the coordinates x and y are stored as global variables for the execution of the script.

And any pre-existing global variables x & y are restored after executing the script.

Here is where the story could end.

 

Uncommenting the 

// x=y=60;

lets the graph start with a line at x = 60. -> the script uses the local variable from the Here namespace.
What surprised me:
When I try to drag the line to another location, it works!

Why is this surprising:
x inside the Here namespace stays at 60. And the script will prefer the variables from the Here namespace over the variables from the global namespace. [Edit: for the global variables the original values should be "restored" at this point of time: after executing MouseTrap]. So, why does the script work ?!

Seems that inside the script there are local variable x & y which are preferentially used - instead of the variables from the Here namespace. It this interpretation correct? 


Then, under the line, it's very kind that JMP does the extra effort with the global variables. This way even functions which live outside of the context of the Graphics Script (myfunctions:xy ) can access the variables

 

maybe interesting to check:
Graphics scripts of one FrameBox - do they share a common namespace or does every graphics script use it's own ...

hogi
Level XII

Re: Can JMP graphics have this effect?

Ok, ONE shared Namespace per Framebox - separate from the global Namespace

- and separate from the Namespace of the other FrameBoxes.

 

How do I access this namespace?

Both:

Report(gb)[FrameBox(1)]  << get namespace() ;
(Report(gb)[FrameBox(1)] << find seg(TopSeg (1))) << get namespace();

produce a new namespace.



Another finding - at the end of the video:
rescaling the window triggers a reset of the plot with the original values from the Here namespace.

::x= 5;
(Report( gb )<< xpath("//FrameBox")) << addgraphicsscript(//
	If(Not( Is Empty( x ) ), // if the mouse did not yet enter the graph -> do nothing.
		Caption("global x is "|| Char(::X));
		V Line(x+3);
	)
	//	
);