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