Subscribe Bookmark RSS Feed

Reference a scale box with a variable

bensyork

Community Trekker

Joined:

Apr 23, 2015


Hi,

I'm trying to produce multiple graphs with a for loop, and assign the column title to the Y axis.

After graphing, I want to add three reference lines to the Y axis with a Dispatch command, but cannot figure out how to dynamically reference the Y axis box, see *** below:


for (i=12, i <= 18, i++,

Col_name = Column(i) << Get Name;
temp = Expr(Col_name);
//Graph Line Data
Split_dt << Graph Builder(
  Size(536, 500),
  Variables(X(:Year), X(:Month, Position(1)), X(:Day, Position(1)), Y(Column(i))),
  Elements(
   Box Plot(
    X(1),
    X(2),
    Y,
    Legend(9),
    Jitter(1),
    Outliers(1),
    Box Style("Outlier")
   )
  ),
  SendToReport(
   Dispatch(
    {},
    ,
    ScaleBox,
    {Add Ref Line(9, Solid, "Black", "LSL"),
    Add Ref Line(21, Solid, "Black", "USL"),
    Add Ref Line(16, Dashed, "Medium Dark Green", "Target")}
   )
  ),
  SendToReport(Dispatch({}, "graph title", TextEditBox, {Set Text("Line " || Char(Line_Number) || " " || Col_name)}))
)

);

This code returns the error "Cannot find ScaleBox[ "Col_name" ] at {}", as if JSL is evaluating Col_name as a string.

Any ideas on for to make Col_name evaluate to it's value, or add the ref lines differently?

Thanks!

3 REPLIES
bensyork

Community Trekker

Joined:

Apr 23, 2015

Forgot to add the ***, see below:

for (i=12, i <= 18, i++,

Col_name = Column(i) << Get Name;
temp = Expr(Col_name);
//Graph Line Data
Split_dt << Graph Builder(
  Size(536, 500),
  Variables(X(:Year), X(:Month, Position(1)), X(:Day, Position(1)), Y(Column(i))),
  Elements(
   Box Plot(
    X(1),
    X(2),
    And,
    Legend(9),
    Jitter(1),
    Outliers(1),
    Box Style("Outlier")
   )
  ),
  SendToReport(
   Dispatch(
    {},
   
    ScaleBox,
    {Add Ref Line(9, Solid, "Black", "LSL"),
    Add Ref Line(21, Solid, "Black", "USL"),
    Add Ref Line(16, Dashed, "Medium Dark Green", "Target")}
   )
  ),
  SendToReport(Dispatch({}, "graph title", TextEditBox, {Set Text("Line " || Char(Line_Number) || " " || Col_name)}))
)

);

bensyork

Community Trekker

Joined:

Apr 23, 2015

I've discovered a work-around by setting spec limits for the columns I want to graph and setting show as reference lines:

10535_pastedImage_0.png

I still don't know of any way to make the Dispatch function evaluate the variable.  It just takes it as a string.

ian_jmp

Staff

Joined:

Jun 23, 2011

Here's one way to add reference lines to an axis via JSL:

NamesDefaultToHere(1);

// Make some data and make a graph

dt = NewTable("Test", NewColumn("Y", Numeric, Continuous, Formula(RandomNormal())), AddRows(20));

gb = dt << Graph Builder(

Size( 528, 420 ),

Show Control Panel( 0 ),

Variables( Y( :Y ) ),

Elements( Points( Y, Legend( 16 ) ) ),

);

// Template expression to add a reference line

addRefLine =

Expr(

gb << SendToReport(

Dispatch(

{},

"Y",

ScaleBox,

{Add Ref Line( TBD, "Solid", "Black", "", 1 )}

)

)

);

// Loop . . .

For(i=-3, i<=3, i++,

Wait(1);

Eval(Substitute(NameExpr(addRefLine), Expr(TBD), i));

);