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
jthi
Super User

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

I would drop the excluded rows already from selrows

selrows = dt << Get Rows Where(Selected() & !Excluded())
-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

Bad news if the graph builder has local data filter the index is mismatched. 

Is there a way to deal with  graphs with local filter active?

jthi
Super User

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

You can get the rows which local data filter will show by sending message

<< Get Filtered Rows;

to the local data filter

-Jarmo
Clanlope
Level III

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

Thanks for your help! I am almost there!

By the way, is there a way to batch remove the annotation added by the scripts?

gb << SendToReport( Dispatch( {}, "Graph Builder", FrameBox(__which__), __pin_expr__ ) )
jthi
Super User

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

If you can get references to all of those, I think you could set << Close or << Delete message to the list to remove them all at the same time. You might also want to utilize << inval before deletion and << update window after.

-Jarmo
Clanlope
Level III

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

My code is designed for an existing graph builder obtained by gb = (Current Report() << Find( "Graph Builder" )) << Get Scriptable Object;
then I created an Eval loop as mmarchandFSLR's way:
it looks like I can only get access to the gb itself, but nowhere to define the Add Pin Annotation list from the code below:
is there a way to read the Unique ID or something of each one and assign << delete to it then?

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 ) )
				)}
			)
		)
	)
);

.....

If( N Items( pin_expr ) > 0,
            Eval(
                Substitute(
                        Expr(
                        gb << SendToReport( Dispatch( {}, "Graph Builder", FrameBox(__which__), __pin_expr__ ) )
                        ),
                    Expr( __pin_expr__ ), Name Expr( pin_expr ),
                )
            )
        );
jthi
Super User

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

Names Default To Here(1);

dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << select rows([1, 10, 21, 30, 40]);

gb = dt << Graph Builder(
	Size(658, 556),
	Show Control Panel(0),
	Variables(X(:age), Y(:height)),
	Elements(Points(X, Y, Legend(3)))
);

pins = {};

gb << inval;
frame = Report(gb)[FrameBox(1)];
For Each({currow}, dt << Get Selected Rows,
	Eval(EvalExpr(
		Insert Into(pins, frame << Add Pin Annotation(
			Seg(Marker Seg(1)),
			Index(Expr(currow - 1)),
			Index Row(Expr(currow - 1)),
			UniqueID(Expr(currow - 1))
		));		
	));
);
gb << update window;

wait(1); // demo purposes
pins << Delete;
-Jarmo

Recommended Articles