Good question. Here's the JSL that can crawl through the display tree to gather the pieces. The journal tree changed between 17 and 18 and might change again. You could probably do the 17 variation on the graphbuilder directly, but I found it easier to work with the journal, especially with the JMP 18 Early Adopter version.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
g = dt << Graph Builder(
Size( 528, 2956 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ), Page( :age ) ),
Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) )
);
// make a journal just for this task, the vanilla journal might be in use.
tempWindow = New Window( "temp", <<Type( "journal" ) );
g << journal;
// place to save, be careful with delete directory!!!!!!
dir = "$temp/" || "junk/"; // keep the trailing / to join a file name
Delete Directory( dir ); // be careful here! this is really just for testing...
Create Directory( dir );
If( JMP Version() >= "18", // easier in 18, the journal groups the pictures
// moving the graphs to a journal window is the key; the elements are not
// grouped by pages in a usable displaybox tree in graphbuilder, but they
// are when graphbuilder sends them to a journal.
// now use xpath to extract the chunks you want. In this case, using the
// journal's showproperties, we discover there is a lineup box whose children
// are what is needed. Get those children as a list...
graphList = tempwindow << XPath( "//OutlineBox[text()='Graph Builder']//LineUpBox/ListBox" );
// save the pics; dig out a name for each one
For Each( {graph}, graphList,
// grab a name and keep the non-special characters for a disk file name
label = Regex( graph[LabelBox( 1 )] << gettext, "[^A-Za-z0-9]+", "_", GLOBALREPLACE );
// create the individual picture using the label for a filename
graph << savepicture( dir || label || ".png", "png" );
);
, // else harder in 17, find a way...
// at least for this example we find pairs of listboxes, without a listbox wrapper as in 18
labList = tempwindow << XPath( "//OutlineBox[text()='Graph Builder']//BorderBox//LabelBox" );
For Each( {lab}, lablist,
label = Regex( lab << gettext, "[^A-Za-z0-9]+", "_", GLOBALREPLACE );
parent = lab << parent; // use the journal's property sheet to see what is needed
spacer = parent << sib;
graph = spacer << sib;
combine = V List Box( parent, graph );
combine << savepicture( dir || label || ".png", "png" );
);
);
// just for fun, see what happened
fileList = Files In Directory( dir );
For Each( {file}, fileList, Open( dir || file ) );
Craige