How do I use a variable inside the graph builder script with a loop?Hi all. I am using a variable CD to keep track of several different products. I would like to use a for loop to run the graph builder and under the Variables function of the graph substitute my variable for the Y axis name.
I have this under graph builder script:
Graph Builder(
Variables( X( :DateTime ), Y( :BLU14031717111005_100_200 ) ),
Elements( Points( X, Y, Legend( 11 ), Jitter( 1 ), Error Bars( "Range" ) ) ),
{},
"BLU14031717111005_100_200",
ScaleBox,
{Add Ref Line( 2120, Solid, "Medium Light Red", "LCL", 2 ),
Add Ref Line( 2340, Solid, "Medium Light Red", "HCL", 2 )}
),
Dispatch( {}, "400", LegendBox, {Position( {0} )} )
I want to change the :blu14031717........ to a variable that will change depending on the for loop iteration. I would also like the graph title to change with each iteration. Any help would be most appreciated.
Re: How do I use a variable inside the graph builder script?<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />You are correct - I think it was a typo - it should be Eval( yCol )
Re: How do I use a variable inside the graph builder script?@HI,
I have a quick question on this. (If someone sees this message, this comes roughly two years after the last reply).
The above code works perfectly fine for me, but I am not understanding why Eval(i) is used for Y variable in the Graph builder code in the line below. Shouldn't it be Eval(yCol(i)) ? Eval(i) will just give 1,2,3 ... etc ,then how does it work fine?
Variables( X( :weight ), Y( Eval(i) ) ),
Thanks,
-Ankur
Re: How do I use a variable inside the graph builder script?Thanks Peter
Re: How do I use a variable inside the graph builder script?Dave - if you copy/paste the code from JMP to MS-Word, and then re-copy/paste from MS-Word to this forum, it will retain the formatting. Clunky but it works.
Re: How do I use a variable inside the graph builder script?David,
Thank you!
I just changed one line and now the name of the graph is the column name, you rock!
strTitle = Char( yCol )
Re: How do I use a variable inside the graph builder script?Here is an example - it uses the Eval function to evaluate the variable that contains the column reference:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
For( i = 1, i <= N Cols( dt ), i++,
yCol = Column( dt, i );
strTitle = "Graph #" || Char( i );
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :weight ), Y( Eval( i ) ) ),
Elements( Points( X, Y, Legend( 1 ) ) ),
SendToReport( Dispatch( {}, "graph title", TextEditBox, {Set Text( strTitle )} ) )
);
);
Unfortunately I still have no idea how to cut and paste JSL whilst maintaining its formatting - this is what it looks like:

David Burnham