Subscribe Bookmark RSS Feed

How can I use a variable in a chart legend?

rleeper

Community Trekker

Joined:

Jun 3, 2014

I am trying to automatically include the number of pass / fail in my chart legend.

I tried:

f=N Items(Fail);

p=N Items(Pass);

//The assignment of f and p works, the values are in the variables.

PassFailChart = Graph Builder(

Show Control Panel( 0 ),

Variables(

  X( :Diff_Forward_Neg_3 ),

  Y( :Diff_Forward_Pos_3 ),

  Overlay( :Filter )

),

Elements( Points( X, Y, Legend( 3 ), Jitter( 1 ) ) ),

SendToReport(

  Dispatch(

   {},

   "Graph Builder",

   OutlineBox,

   {Set Title(

    "Measurements Passing the 1e-10A @3V filter in Last 90 Days"

   )}

  ),

  Dispatch(

   {},

   "Diff_Forward_Neg_3",

   ScaleBox,

   {Scale( "Log" ), Min( 10 ), Max( 100000000000000 ), Inc( 1 ),

   Minor Ticks( 1 )}

  ),

  Dispatch(

   {},

   "Diff_Forward_Pos_3",

   ScaleBox,

   {Scale( "Log" ), Min( 10 ), Max( 100000000000000 ), Inc( 1 ),

   Minor Ticks( 1 )}

  ),

  Dispatch(

   {},

   "400",

   ScaleBox,

   {Legend Model(

    3,

    Level Name( 0, "Fail -" || f ),

    Level Name( 1, "Pass -" || p),

    Base( 0, 0, 0 ),

    Base( 1, 0, 0 ),

    Properties( 0, {Line Color( 3 )} ),

    Properties( 1, {Line Color( 5 )} )

   )}

  ),

  Dispatch(

   {},

   "400",

   LegendBox,

   {Set Title( "Current Filter Pass / Fail" )}

  )

)

)

I also tried :

Level Name( 0, "Fail -" || f || "" ),

    Level Name( 1, "Pass -" || p || ""),

Neither worked.  Is this even possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Not sure if it is possible. In any case f and p should be converted to strings before concat: "Fail -" || char(f).

An alternative approach is to set Value Labels for the Overlay column before plotting.

Script example:

Open( "$SAMPLE_DATA/Big Class.jmp" );

// List with all levels

levels = Associative Array( :sex ) << get keys;

// Make list of value-label "assignments"

vl = Repeat(

    i = 0;

    {i++ ; Eval Expr(

        Expr( levels[i] ) = Expr( levels[i] || "-" || Char( Col Sum( :sex == levels[i] ) ), )

    )};,

    N Items( levels )

);

// Set property       

:sex << Value Labels( vl );

// make graph with overlay

Graph Builder( Variables( X( :age ), Y( :height ), Overlay( :sex ) ), Elements( Bar( X, Y, ) ) );

2 REPLIES
Solution

Not sure if it is possible. In any case f and p should be converted to strings before concat: "Fail -" || char(f).

An alternative approach is to set Value Labels for the Overlay column before plotting.

Script example:

Open( "$SAMPLE_DATA/Big Class.jmp" );

// List with all levels

levels = Associative Array( :sex ) << get keys;

// Make list of value-label "assignments"

vl = Repeat(

    i = 0;

    {i++ ; Eval Expr(

        Expr( levels[i] ) = Expr( levels[i] || "-" || Char( Col Sum( :sex == levels[i] ) ), )

    )};,

    N Items( levels )

);

// Set property       

:sex << Value Labels( vl );

// make graph with overlay

Graph Builder( Variables( X( :age ), Y( :height ), Overlay( :sex ) ), Elements( Bar( X, Y, ) ) );

rleeper

Community Trekker

Joined:

Jun 3, 2014

MS,

You got it right first try.  I needed the Char function.  Chart looks amazing and now updates as the data changes, thank you!

   Level Name( 0, "Fail -" || Char(f) ),

    Level Name( 1, "Pass -" || Char(p)),