Subscribe Bookmark RSS Feed

Mouse hover over data point to display image?

djhanson

Community Trekker

Joined:

Jun 23, 2011

Does anyone know if this is possible?  Mouse hover over a data point, like a chart, and pop up a JPG/GIF image in a window or some sort of display box?

I know and use <<Set Label Columns to display values upon mouse hover over data points - it works very well.  Wondering if there's a way to do this by referencing an image path?  thx... dj

12 REPLIES
msharp

Super User

Joined:

Jul 28, 2015

Yes it is possible. The easiest way is to simply add a column of pictures and give that column a label property.  See below for an example.

Names Default to Here(1);

table1 = New Table( "one",

  Add Rows( 1 ),

  New Column( "pic", Expression, Set Values( {Empty()} ) )

);

// make random image

d = J(25,50,rgbcolor(randomuniform(),randomuniform(),randomuniform()));

p = newimage(d);

// store in table1

table1:pic[1] = p;

// make a new table

table2 = New Table( "two",

  Add Rows( 1 ),

  New Column( "pic", Expression, Set Values( {Empty()} ) )

);

// put two copies in table 2, from table 1

table2:pic[1] = table1:pic[1];

table2<<addrow(1); // two was created with one row, add a second

table2:pic[2] = table1:pic[1];

//Add X/Y columns

table2 << New Column("X", Numeric, Continous, Set Values({1,2}));

table2 << New Column("Y", Numeric, Continous, Set Values({2,1}));

//label pic column

table2:pic << Label;

//open bivariate analysis

biv = table2 << Bivariate( Y( :Y ), X( :X ) );

The below script was adapted from Craige's code Re: JMP_12: Embedding a JSL expression directly into a row if you are wondering what else it is doing.

vkessler

Community Trekker

Joined:

Dec 23, 2015

Hi,

this example works fine for me, but i´m interested in a different solution. The issue is, that i rather don´t like to fill every row with a picture, since this would consume lots of memory in a big data table. Considering this, my question is, if it is possible to execute some code in an expression column, when the mouse is hovering above a data point? Then the X and Y position of that point could be used as an argument in the expression column to open the approbiate picture.

Is this possible?

Thank you very much!

ian_jmp

Staff

Joined:

Jun 23, 2011

Although I didn't check, I imagine that 'Empty' cells in an expression column have almost no overhead. And you could hide this column, or make the table invisible if need be.

But if you don't like this approach, look at 'MouseTrap()' and 'IsCommandKey()' in Help > Scripting Index

msharp

Super User

Joined:

Jul 28, 2015

I believe the short answer is no.  There's not much HOVER capabilities when interacting with graphs. 

If the user 'clicks' the point there's several options as far as mousetrap() which interacts with user clicks, drags, ect in a graphbox.  You could also use a row state handler which will run scripts when users interact with a data table. For example, selecting a point in a graph will also select the data table row, which your handler could then use to run a script.  They both have their pros and cons.

Anyways, if memories the only issue, you should consider Ian's solution of simply hiding the data table and/or the column.  If you are worried about speed, ie. the time it takes the generate an image/load an image file into each cell, I would just recommend condensing the data table.  Do your users NEED to see images from the large table?  Can you subset the data to make smaller data sets the users can then interact with?

vkessler

Community Trekker

Joined:

Dec 23, 2015

Thank you Ian and msharp. I will try a few ways and see which solutions works best for us. The MouseTrap() function is definitely helpful, but i will also try to hide the image column and check if we actually are limitated by speed or memory.

EDIT: I have difficulties to add the MouseTrap() function to the Graph Builder. I was looking for a solution like this:

exx = 20;

exy = 50;

window = New Window( "Wafer Map",

    gb = Data Table("Data Table Wafer Map") << Graph Builder(

        Variables( X( :PosX ), Y( :PosY ), Color( :Value ) ),

        Elements( Points( X, Y, Legend( 9 ) ) ),

        Mousetrap(

            exx = X( :PosX );

            exy = Y( :PosY );

            Show(exx);

            ,

            Show(exy);

        )

    );

);

Frankly, I was just guessing as i inserted the MouseTrap() function, but I didn´t find any information concerning the combined usage of Graph Builder and MouseTrap.

Is it possible to use the MouseTrap() function with Graph Builder?

msharp

Super User

Joined:

Jul 28, 2015

MouseTrap needs to be applied to a frame box.  Graph builder is a pretty complex display which includes a frame box.

window = New Window( "Wafer Map",

    gb = Data Table("Data Table Wafer Map") << Graph Builder(

        Variables( X( :PosX ), Y( :PosY ), Color( :Value ) ),

        Elements( Points( X, Y, Legend( 9 ) ) ),

    );

);

rgb = gb << Report;

rgb[frame box(1)] << Add Graphics Script(MouseTrap(print("test")));

vkessler

Community Trekker

Joined:

Dec 23, 2015

Thank you! That was exactly what I needed. It´s amazing what jmp can do.

However, although the picture of the chip is now shown if i click on it, i´m wondering why the data point (chip) in the map is no longer marked / selected. But then again that isn´t really necessary...

Thanks!

msharp

Super User

Joined:

Jul 28, 2015

See post Mousetrap and Biviariate Frame Box for when I had the exact same question.

vkessler

Community Trekker

Joined:

Dec 23, 2015

Thanks again. Now everything works like a charme!