Here is one approach to solve your problem. It loops through your data, 4 devices at a time, generating a chart and then moving the graph to a JMP Journal window, and then moving on to the next 4 devices. I have attached a sample data table that I used for the development. Please note, that the first 4 devices and the second 4 devices generate the same look of the graph, since all of the data are the same, except for the device names.
![multiple.PNG multiple.PNG](https://community.jmp.com/t5/image/serverpage/image-id/20482i99E075DDC925D406/image-size/large?v=v2&px=999)
The script is not real robust. It assumes that there are multiples of 4 devices, all graphs are to be output in a single column down the output page, etc. I am providing the JSL as a starting place for a possible solution, not the final, robust piece of code it probably should be
Add Properties to Table(
{New Script(
"Option C",
dt = Current Data Table();
// JMP changed the way Row Order Levels works in JMP 15, so 2 different
// methods to set the option has to be handled
If( Num( Word( 1, JMP Version(), "." ) ) >= 15,
dt:Device << set Property( "Value Order", {Row Order Levels( 1 )} );
dt:Device << set Property( "Row Order Levels", 1 );
);
// Get a list of the DeviceNames found in the order they exist in the
// data table
Summarize( dt, DeviceNames = By( dt:Device ) );
// Create a window to save all of the graphs to
nw = New Window( "Output", <<journal );
// Loop across all of the Devices, 4 at a time to build the graph
For( i = 1, i <= N Items( DeviceNames ), i = i + 4,
// Get a list of the current 4 devices
DeviceList = {};
For( k = i, k <= i + 3, k++,
Insert Into( DeviceList, DeviceNames[k] )
);
// Select the rows where the current 4 devices are found
dt << select where( Contains( DeviceList, :Device ) );
// Create a subset of the data with only the 4 current devices in it
dtSub = dt << Subset( invisible, Selected Rows( 1 ), Selected columns only( 0 ) );
// Wait for the new data table to be completed before processing
wait(0);
// Run the Graph Code, substituting in the new device's names where required
Eval(
Substitute(
Expr(
gb = dtSub << Graph Builder(invisible,
Size( 534, 448 ),
Show Control Panel( 0 ),
Variables(
X( :Date ),
Y( :Meas_Rise ),
Y( :Name( "No_of_Measurements" ) ),
Overlay( :Device )
),
Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 6 ) ),
Line( X, Y, Legend( 10 ) )
),
Elements(
Position( 1, 2 ),
Bar(
X,
Y,
Legend( 20 ),
Bar Style( "Stacked" ),
Label( "Label by Value" )
)
),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
6,
Base( 0, 0, 0, Item ID( __dev1__, 1 ) ),
Base( 1, 0, 0, Item ID( __dev2__, 1 ) ),
Base( 2, 0, 0, Item ID( __dev3__, 1 ) ),
Base( 3, 0, 0, Item ID( __dev4__, 1 ) )
)}
)
)
)
),
Expr( __dev1__ ), DeviceList[1],
Expr( __dev2__ ), DeviceList[2],
Expr( __dev3__ ), DeviceList[3],
Expr( __dev4__ ), DeviceList[4]
)
);
// Add the output from the graph to the output window
nw << append( Report( gb ) );
// Cleanup the current working items to get ready for the next 4 devices
report(gb) << delete;
Close( dtSub, nosave );
);
)}
)
Jim