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

Efficient way to label multiple rows with the same image?

I want to add images to my JMP table, so when I hover over a data point, I can see the associated image. My concern is that my table has 300,000+ rows, and I think if I add an image to each row the file size may become unmanageably large. However, many rows will share the same image - there are only ~30,000 images, with each image being shared by ~10 rows. Is there an efficient way to associate an image with multiple rows without increasing the file size? (Or would JMP already know to do that automagically?)

 

For reference, here is the code I previously used to add images to a JMP table, although in that case every row was getting a distinct image.

 

Names Default to Here(1);

// run the script on the currently-selected data table
dt = Current Data Table();

// point to the directory where your thumbnail images are stored
// this script assumes the image names follow the pattern "0001.jpg", "0002.jpg", etc.
BaseImageDirectory = "C:\Users\user\Downloads\thumbnails\";

// create a column called "pics" to put the images
CurrentColumnNames = dt << get column names(string);
if (!contains(CurrentColumnNames, "pics"), New Column("pics", Expression));

// iterate through each row in the data table to add the images
For Each Row(
  // look for a column called "image_directory" and take the name of the lowest-level subdirectory
  Directory = word(-1, :image_directory, "\");
  // zero-pad the image number to four digits (e.g. image_number 1 becomes 0001)
  ImageID = Repeat( "0", 4 - Length( Char( :image_number ) ) ) || Char( :image_number );
  // look for a file name like 0001.jpg in a folder with a name matching "image_directory"
  ThumbnailFile = BaseImageDirectory || Directory || "\" || ImageID || ".jpg";
  Eval(Eval Expr(tp = ThumbnailFile));	
  // insert the image into the column "pics"
  Try(dt:pics = new image(tp));  
);
// set "pics" as a label so it shows up when you hover over any data point
dt:pics << label(1);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Efficient way to label multiple rows with the same image?

I would put a single copy of each unique image in one data table, and then create a virtual table by linking your large data table to the image table, thus avoiding the duplication.

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Efficient way to label multiple rows with the same image?

I would put a single copy of each unique image in one data table, and then create a virtual table by linking your large data table to the image table, thus avoiding the duplication.

Jim
jthi
Super User

Re: Efficient way to label multiple rows with the same image?

Other option could be to use Hover Labels and load the images only when needed. In this case you could store the paths to the data table and then use hover label to load those based on those paths.

-Jarmo