cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
hcarr01
Level VI

image jpg

 

Bonjour à tous, 
 
J’ai une question par rapport aux images jpg, je ne trouve pas de documentation sur JMP à ce sujet.
Dans mon cas, je dispose d’un dossier contenant environ 3000 images sous le format « jpg ».
 
J’aimerais pouvoir afficher dans le constructeur de graphiques ces images au format « jpg » en fonction de la sélection des filtres de données locales.

Par exemple :
 
 
hcarr01_1-1687505622793.png

Ici, il faudrait que s’affiche l’image suivante : obj « B » et type « 2 ».

Cette image se nomme comme ceci dans mon dossier : " B_2.jpg " .

 

Merci pour votre aide !


 

2 REPLIES 2
ian_jmp
Level X

Re: image jpg

I think this is close to what you are asking for and should get you started:

// https://community.jmp.com/t5/Discussions/Drawing-other-shapes-in-graph-builder/m-p/368186#M61806

NamesDefaultToHere(1);

// Open a table and do Bivariate
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Bivariate(X(:height), Y(:weight));

// Add a local data filter (:sex plays the role of floor . . . )
df = biv << Local Data Filter( Add Filter( columns( :sex ) ));

// Get the title of the window
win = (biv << Report) << GetWindowTitle;

// Define a function that will update the background image on the Bivariate plot
f = Function( {a},
		// Infer what value of :sex is currenly selected in the data filter
		levRows = df << getFilteredRows;
		lev = Column(dt, "sex")[levRows];
		lev = lev[1];
		Speak(lev);
		// (Try to) remove an image that might already be there
		Try(
			imgSeg = Window(win)[FrameBox(2)] << FindSeg( PictSeg( 1 ) );
			imgSeg << Remove;
			);
		// Add the 'corresponding' image
		if(
			lev == "M",
				Window(win)[FrameBox(2)] << Add Image(Open("$SAMPLE_IMAGES/tile.jpg"), FillGraph),
			lev == "F",
				Window(win)[FrameBox(2)] << Add Image(Open("$SAMPLE_IMAGES/progress.gif"), FillGraph)
			);
		);

// Add a handler to the data filter so that when the user makes a selection the function 'f' is called
rs = df << Make Filter Change Handler( f );
txnelson
Super User

Re: image jpg

Taking a similar approach to @ian_jmp below is a simple example of script that displays an image based upon a data filter selection, but does not use a JMP platform such as Bivariate or Graph Builder.  It just simply displays an image.

txnelson_0-1687520501584.png

txnelson_1-1687520603106.png

Names Default To Here( 1 );
path = "c:\users\???\pictures"; // set the path to your image directory 

// Filter out all non jpg files
files = Filter Each( {file}, Files In Directory( path ), Word( -1, file, "." ) == "jpg" );

// I create a dummy data table to use for an example
ob = {"A", "B", "C"};
dt = New Table( "Pictures", invisible,
	add rows( N Items( files ) ),
	New Column( "Obj", character, set each value( ob[Mod( Row(), 3 ) + 1] ) ),
	New Column( "type", nominal, set each value( Col Cumulative Sum( 1, :obj ) ) ),
	New Column( "ImagePath", character, set each value( files[Row()] ) )
);
:ImagePath << hide;

// Here is the working code that can be used against a data table that matches
// the example data table created above
// It uses a Make Row State Handler to handle the changing of images when
// the data filter values change
nw = New Window( "Example",
	hlb = H List Box(
		dt << Data Filter(
			Location( {928, 247} ),
			Mode( Include( 1 ) ),
			Add Filter( columns( :Obj, :type ), Display( :type, N Items( 8 ) ) )
		),
		pb = Graph Box( Frame Size( 600, 600 ) )
	)
);
pb( report )[axisbox( 2 )] << delete;
pb( report )[axisbox( 1 )] << delete;

theFunction = Function( {a},
	If( N Rows( dt << get selected rows ) == 1,
		Try( pb << delete );
		hlb << append( pb = Picture Box( Open( path || "\" || dt:ImagePath[(dt << get selected rows)[1]], jpg ) ) );
		pb << set height( 600 );
		pb << set width( 600 );
	,
		Try( pb << delete );
		hlb << append( pb = Graph Box( Frame Size( 600, 600 ) ) );
		pb( report )[axisbox( 2 )] << delete;
		pb( report )[axisbox( 1 )] << delete;
	)
);
rs = dt << make row state handler( theFunction );

 

Jim