Thanks for the help. I took the following approach (through iteration... lots of fails!):
1. I have a list of column names that I want to put into the chart. It's in list "a" (not shown). It's what I would like to plot.
2. I build a list from the data table columns that match my search list. These are the Y axis variables that exist that I can plot.
3. I build a Graph Builder, and set my X axis with nested variables. This is common for all of my data.
4. I then loop through and add the variables.
5. Then I loop through and add the elements.
6. Then I loop through and add gridlines. And then finally titles.
For steps 4-6, I kept crashing JMP if I tried to do these things within a single loop. It's how I came to this point. The script works (had to pull some minor confidential stuff out), but isn't fast.
Compared to other JSL I've programmed, this is rather cludgy. I haven't had this many JMP crashes ever. But it works.
dtname = dt << Get Name();
currentTime = Today();
timeString = "Last Updated " || Format( currentTime, "mm-dd-yyyy" ) ;
// Find columns that match the terms in list "a"
col = dt << get column names( string );
nc = N Items( col );
nsrch = N Items( a );
xxx = {};
For( j = 1, j <= nsrch, j++,
For( i = 1, i <= nc, i++,
If( Uppercase( col[i] ) == Uppercase( a[j] ),
Insert Into( xxx, col[i] ),
)
)
);
colList = xxx;
//Build Basic Chart with nested X variables, no Y variables (yet)
gb = dt << Graph Builder(
Size( 1226, 608 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Subtitle( 1 ),
Variables(
X( :XVar1, Combine( "Nested" ) ),
X( :XVar2, Position( 1 ), Combine( "Nested" ) ),
X( :XVar3, Position( 1 ), Combine( "Nested" ) ),
),
);
gbb = Report( gb )[Graph Builder Box( 1 )];
// I don't know why I have to break these into separate loops, but I tried not to....
// I think it's something to do with needing the "wait".
//Add Y variables.
For( i = 1, i <= N Items( colList ), i++,
gbb << Add Variable( {colList[i], Role( "Y" )} );
If( i == 1,
chrtname = colList[i],
chrtname = chrtname || ", " || colList[i]
);
);
Wait( 1 );
//Remove existing element and replace with points.
For( i = 1, i <= N Items( colList ), i++,
gbb << Remove Element( 1, i, 1 );
gbb << Add Element( 1, i, {Type( "Points" ), X, Y} );
);
Wait( 1 );
For( i = 1, i <= N Items( colList ), i++,
gbb << Add Element( 1, i, {Type( "Line" ), X, Y} )
);
//Set Major Axes
For( i = 1, i <= N Items( colList ), i++,
gbb << Dispatch( {}, colList[i], ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
);
//Set Various Titles
gb << SendToReport( Dispatch( {}, "graph 1 title", TextEditBox, {Set Text( timeString )} ) );
gb << SendToReport( Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( chrtname || " from " || dtname ), Image Export Display( Normal )} ) );
gb << SendToReport(
Dispatch(
{},
"XVar1",
ScaleBox,
{Label Row( 2, {Major Grid Line Color( 3 ), Show Major Grid( 1 )} ), Label Row( 3, {Major Grid Line Color( 5 ), Show Major Grid( 1 )} )}
)
);
);
Fred