Plot Legend is removed when inside a list boxHi all,
So I have an issue with a plot that I am creating through a function. The function is as follows:
myRunChart = Function( {dt, y1, y2, y3, x, colour_col},
{Default Local},
dt << Control Chart(
Sample Label( Eval( x ) ),
KSigma( 3 ),
Chart Col( Eval( y1 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y2 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y3 ), Run Chart( Show Center Line( 0 ) ) ),
SendToReport(
Dispatch(
{Eval( "Run Chart of "|| y1 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {Eval( "Run Chart of "|| y1 )}, "Control Chart Limits frame", FrameBox, {Frame Size( 69, 114 )} ),
Dispatch(
{Eval( "Run Chart of "|| y2 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {Eval( "Run Chart of "|| y2 )}, "Control Chart Limits frame", FrameBox, {Frame Size( 69, 114 )} ),
Dispatch(
{Eval( "Run Chart of "|| y3 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {Eval( "Run Chart of "|| y3 )}, "Control Chart Limits frame", FrameBox, {Frame Size( 69, 114 )} )
)
);
);
When I call this function by itself everything is fine. The plot and legend plots as normal. However, when I call the function within a List Box, the legend is removed, and the size of the graphs are changed.
In the following code, I call the function twice in a window. The first time it's inside a H List Box and the legend is removed. But the second calling of the function works as normal.
nw2 = New Window("temp",
H list box(
rc2 = myRunChart(
dt_temp,
"column1",
"column2",
"column3",
time_col,
colour_col
)),
rc3 = myRunChart(
dt_temp,
"column4",
"column5",
"column6",
time_col,
colour_col
)
);
Does anyone have an idea what issue could be?
Re: Plot Legend is removed when inside a list boxWorks a charm. Thank you for your help. I'm sure this took a fair bit of your time.
It's greatly appreciated,
David
Re: Plot Legend is removed when inside a list boxApparently, from within the H List Box(), or even when I used an Outline Box(), the concatenation of "Run Chart of " and the y1, y2, or y3 variables is not being performed. I have reworked the script, forcing the string to be calculated correctly, and the script then completes properly
myRunChart = Function( {dt, y1, y2, y3, x, colour_col},
{Default Local},
Eval(
Substitute(
Expr(
dt << Control Chart(
Sample Label( Eval( x ) ),
KSigma( 3 ),
Chart Col( Eval( y1 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y2 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y3 ), Run Chart( Show Center Line( 0 ) ) ),
SendToReport(
Dispatch(
{ __y1__ },
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ),
Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch(
{ __y2__ },
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ),
Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch(
{ __y3__ },
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ),
Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
)
),
Expr( __y1__ ), "Run Chart of " || y1,
Expr( __y2__ ), "Run Chart of " || y2,
Expr( __y3__ ), "Run Chart of " || y3
)
);
Wait( 0 );
);
dt_temp = Open( "$SAMPLE_DATA\Solubility.jmp" );
Wait( 0 );
dt_temp << New Column( "Colour example" );
dt_temp:Colour Example << set formula( Modulo( Row(), 2 ) + 1 );
dt_temp << New Column( "Row Numbers" );
dt_temp:Row Numbers << set formula( Row() );
time_col = "Row Numbers";
colour_col = "Colour Example";
Wait( 0 );
nw2 = New Window( "temp",
H List Box(
"charts",
rc2 = myRunChart(
dt_temp,
"Chloroform",
"Benzene",
"Hexane",
time_col,
colour_col
)
),
rc3 = myRunChart(
dt_temp,
"Chloroform",
"Benzene",
"Hexane",
time_col,
colour_col
)
);Re: Plot Legend is removed when inside a list boxSo when I run this script:
myRunChart = Function( {dt, y1, y2, y3, x, colour_col},
{Default Local},
dt << Control Chart(
Sample Label( Eval( x ) ),
KSigma( 3 ),
Chart Col( Eval( y1 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y2 ), Run Chart( Show Center Line( 0 ) ) ),
Chart Col( Eval( y3 ), Run Chart( Show Center Line( 0 ) ) ),
SendToReport(
Dispatch(
{Eval( "Run Chart of " || y1 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch(
{Eval( "Run Chart of " || y2 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch(
{Eval( "Run Chart of " || y3 )},
"Run Chart",
FrameBox,
{Frame Size( 436, 114 ), Row Legend(
Eval( colour_col ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
wait(0);
);
dt_temp = Open("C:\Program Files\SAS\JMP\14\Samples\Data\Solubility.jmp");
wait(0);
dt_temp << new Column ("Colour example");
dt_temp:Colour Example << set formula(modulo(row(),2) + 1);
dt_temp << new column ("Row Numbers");
dt_temp:Row Numbers << set formula(row());
time_col = "Row Numbers";
colour_col = "Colour Example";
wait(0);
nw2 = New Window( "temp",
H List Box( rc2 = myRunChart( dt_temp, "Chloroform", "Benzene", "Hexane", time_col, colour_col ) ),
rc3 = myRunChart( dt_temp, "Chloroform", "Benzene", "Hexane", time_col, colour_col )
);I get this output:
As you can see, the legend only appears for the function call outside the H List Box.

See the log:

Can you confirm if you see this issue? Any ideas what could be wrong?
Re: Plot Legend is removed when inside a list boxThank you for your reply.
Really? Both calls of the function produced a plot with a legend?
That's interesting. I'll have to look closer. Perhaps it's something to do with the data. I am also running JMP 14Re: Plot Legend is removed when inside a list boxI ran your script in JMP 14 and did not see any issues.