cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Clanlope
Level III

[Graph builder] Batch pin the hover label for selected rows

Dear all,

Currently I use JMP16 to create a graph.

I have a col with picture in it, and I want to pin the picture for each dot I selected so I turn on the "add label" of this col.

But I find that I can only by hover my pointer on the dot, and wait the hover label shown itself, and then click the pin button to pin it one by one,

is there any faster way to achieve this like jsl code?  I have million of rows need to show out the pics.

thanks!

17 REPLIES 17

Re: [Graph builder] Batch pin the hover label for selected rows

Does it need to be a hover label? Or could you use the picture as the symbol in your graph? For example, using the Big Class Families sample dataset: 

christianz_0-1780651419584.png

If you only want pictures for selected rows, you could select them and Name Selection in Column, then use that Column to create a Transform column, like this: 

// Open Data Table: Big Class Families.jmp
// → Data Table( "Big Class Families" )
Open( "$SAMPLE_DATA/Big Class Families.jmp" );

// Name selection in column: Use Images
Data Table( "Big Class Families" ) << Clear Select <<
Select Rows( [1, 6, 14, 15, 16] ) <<
Name Selection in Column( Column Name( "Use Images" ), Selected( 1 ) );

Graph Builder(
	Transform Column( "Transform[height]", Formula( :height * :Use Images ) ),
	Size( 648, 551 ),
	Show Control Panel( 0 ),
	Variables(
		X( :weight ),
		Y( :height ),
		Y( :"Transform[height]"n, Position( 1 ) )
	),
	Elements(
		Points( X, Y( 1 ), Y( 2 ), Legend( 3 ) ),
		Points( X, Y( 2 ), Legend( 5 ), Set Shape Column( :picture ) )
	)
);
christianz_0-1780654730474.png

 

I included the script so you can see the results with one click, but this can all be done within Graph Builder with no scripting. The key functionalities are Transform Columns and Set Shape Column

Clanlope
Level III

Re: [Graph builder] Batch pin the hover label for selected rows

Thanks for the reply! Using Set Shape Column works great, but it would be even better if the points could be displayed as well. This is definitely a convenient approach!

mmarchandFSLR
Level VI

Re: [Graph builder] Batch pin the hover label for selected rows

Here's an example pinning the hover labels.  Interesting that the selection is zero-based indexing.  May want to modify to handle no rows selected.

 

Names Default To Here( 1 );

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

dt << Select Rows( [1 5 7] );

pin_expr = {};
For Each( {v, i}, dt << Get Selected Rows,
	Insert Into(
		pin_expr,
		Eval(
			Eval Expr(
				{Add Pin Annotation(
					Seg( Marker Seg( 1 ) ),
					Index( Expr( v - 1 ) ),
					Index Row( Expr( v - 1 ) ),
					UniqueID( Expr( v - 1 ) )
				)}
			)
		)
	)
);

Eval(
	Substitute(
			Expr(
				dt << Graph Builder(
					Size( 658, 556 ),
					Show Control Panel( 0 ),
					Variables( X( :weight ), Y( :height ) ),
					Elements( Points( X, Y, Legend( 5 ) ) ),
					SendToReport( Dispatch( {}, "Graph Builder", FrameBox, __pin_expr__ ) )
				)
			),
		Expr( __pin_expr__ ), Name Expr( pin_expr )
	)
);

mmarchandFSLR_0-1780659051670.png

 

Clanlope
Level III

Re: [Graph builder] Batch pin the hover label for selected rows

 

	For Each( {v, i}, row_selection,
		local_x = Column( dt, col_x )[v];
		local_y = Column( dt, col_y )[v];

		Insert Into(
			pin_expr,
			Eval(
				Eval Expr(
					{Add Pin Annotation(
						Seg( Marker Seg( 1 ) ),
						Index( Expr( v - 1 ) ),
						Origin( {Expr( local_x ), Expr( local_y )} ),
						Index Row( Expr( v - 1 ) ),
						UniqueID( Expr( v - 1 ) ),
                     Offset( {-50, -45} ),
                     Replace Text( " " ),
                     Filled( 0 ),
						Tag Line( 1 )
					)}
				)
			)
		);
	);

Great! It works, but all my annotations were pinned at the exact same position without the Origin setting. To fix this, I read out the values of the x/y axes and assigned them to the Origin. While this works perfectly on numeric axes, passing character column values crashes the app. Is there a workaround for character columns? Thanks!

 

jthi
Super User

Re: [Graph builder] Batch pin the hover label for selected rows

For nominal/ordinal columns the axis starts from 0 and each value increases it by 1. You can verify this from axis settings

jthi_0-1780977594025.png

You can write logic which takes care of this based on the data table or if you have point plot, you can get the values from markers

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));

ms = report(gb)[framebox(1)] << find seg(markerseg(1));

Show(ms << Get X Values, ms << Get Y Values);

 

-Jarmo
Clanlope
Level III

Re: [Graph builder] Batch pin the hover label for selected rows

Thanks! It seems to return all the X/Y values, but how can I read-out the selected rows x/y? I tried code below but the x/y returned is not where I selected.

r = dt << Get Selected Rows();
ms = Report(gb)[framebox(1)] << Find Seg( Marker Seg( 1 ) );
For Each( {v, i}, r,
	t = ms << Get Point( v );
	x = t[1];
	y = t[2];
	show(x,y);
);
jthi
Super User

Re: [Graph builder] Batch pin the hover label for selected rows

For me this seems to return correct values

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
dt << Select Rows([1, 10, 16, 20, 30]);

ms = Report(gb)[framebox(1)] << Find Seg(Marker Seg(1));

selrows = dt << Get Selected Rows();

For Each({currow}, selrows,
	coord = ms << Get Point(currow);
	Show(coord);
);

jthi_0-1781024881201.png

coord = {0, 59};
coord = {1, 61};
coord = {1, 65};
coord = {1, 63};
coord = {2, 61};
coord = {2, 62};
coord = {3, 67};
-Jarmo
Clanlope
Level III

Re: [Graph builder] Batch pin the hover label for selected rows

Oh I see the issue now: hiding or excluding rows causes an index mismatch for the remaining data.

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
dt << Select Rows([1, 10, 16, 20, 30]);
ms = Report(gb)[framebox(1)] << Find Seg(Marker Seg(1));

selrows = dt << Get Selected Rows();
pin_expr = {};
For Each({v}, selrows,
	coord = ms << Get Point(v);
	Show(coord);
	Insert Into(
		pin_expr,
		Eval(
			Eval Expr(
				{Add Pin Annotation(
					Seg( Marker Seg( 1 ) ),
					Index Row( Expr( v - 1 ) ),
					Origin( Expr(coord)),
					UniqueID( Expr( v - 1 ) )
				)}
			)
		)
	)
);

Eval(
	Substitute(
			Expr( Report(gb)[framebox(1)] << __pin_expr__ ),
		Expr( __pin_expr__ ), Name Expr( pin_expr )
	)
);

By using this code, when row 17 hidden/excluded, it will cause the annotations of rows 20/30 to shift to the wrong positions.

Is there a way to prevent this from happening? I mean for sure I have data points to be excluded..

Clanlope
Level III

Re: [Graph builder] Batch pin the hover label for selected rows

This works, thanks guys!

ex = dt << Get Excluded Rows;
pin_expr = {};
For Each( {v}, dt << Get Selected Rows,
	offset = N Rows(Loc(ex < v));
	coord = ms << Get Point(v - offset);

Recommended Articles