cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
scottahindle
Level IV

Scripting Column Switcher to reach to changes in Y variable on a control chart

I have a data table with numerous responses (numerous columns). All are valid to be control charted.

When I add a column switcher I can, as expected, easily switch between responses (different columns) to update the control chart so I can look immediately at the variable of interest.

The only shortcoming is that the x-axis is always, by default, the same length but the number of data in each column varies; sometimes a lot but sometimes not.

 

To adapt the x-axis to the number of data in any given column I can do this:

 

nData = N Rows() - Col N Missing( Column( 1 ) );

ccReport = cc << Report;
axisbox = ccReport[axis box( 1 )];
axisbox << Max( nData + 3 ) << inc( Ceiling( (nData + 3) / 15 ) );

 

 

This works great for the first control chart, but as soon as I select another variable using the column switcher the x-axis is once again too long, returning to its default setting. (If N Rows() is e.g. 3,000 but for one variable I have 60 data, the resulting chart looks silly because the x-axis is way too long.)

 

Using JSL, how can I script so that each time I select another column using column switcher I can use the above code (or equivalent) to adjust the x-axis to well adapt to the number of actual data for the variable in question?

 

I see that this syntax "ColumnSwitcherObject << Get Current;" returns the name of the column but how do I access with JSL each time I update using column switcher?

 

Thanks for any help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

I think you can solve your problem by attaching a Graphics Script to the FrameBox() in the Control Chart.  The script will run anytime something is changed in the FrameBox().  Below is a simple script I believe you should be able to build on

names default to here(1);
dt=current data table();

cc = Control Chart Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Show Capability( 0 ),
	Variables( Y( :weight ) ));
	cs = cc << Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]<< add graphics script( show(cs<<get current));
Jim

View solution in original post

txnelson
Super User

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

Rather than setting

ccReport = cc << Report;

I think you should reference it from the source when you use it

report(cc)[AxisBox(1)] << max(X+1);

Below is a sample script that is picking up the correct references off of cc

names default to here(1);
dt=current data table();

cc = Control Chart Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Show Capability( 0 ),
	Variables( Y( :weight ) ));
	cs = cc << Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]<< add graphics script( show(cs<<get current,
	report(cc)[TextEditBox(1)]<<get text;)
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

I think you can solve your problem by attaching a Graphics Script to the FrameBox() in the Control Chart.  The script will run anytime something is changed in the FrameBox().  Below is a simple script I believe you should be able to build on

names default to here(1);
dt=current data table();

cc = Control Chart Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Show Capability( 0 ),
	Variables( Y( :weight ) ));
	cs = cc << Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]<< add graphics script( show(cs<<get current));
Jim
scottahindle
Level IV

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

Thanks, Jim.

Using the framebox, as you suggest, I can indeed show in the embedded log the column that is selected to update the control chart. (I have 12 columns that I would like to switch between and each column has a different no. of data, hence the wish to re-scale the x-axis in each case to reflect the no. of data in the selected column.)

 

I capture the selected column easy enough:

ccReport[FrameBox(1)]<< add graphics script(
  cName = cs << Get Current;
  show(cName);
  If(cName == "JW004",
           show("JW004 selected");
  ,
         cName == "JW001",
         show("JW001 selected");
,

);

In other parts of the syntax I can easily change the x-axis using e.g.

 ccReport = cc << Report;
 axisbox = ccReport[axis box( 1 )];
 axisbox << max(x+1); // where x is the no. of data in the column

 

The problem arrives if I put the axisbox syntax in the framebox. One of the errors is

Send Expects Scriptable Object in access or evaluation of 'Send' , ccReport[axis box( 1 )] << /*###*/Max( 200 ) /*###*/ 

 

I have tried a few things but to no avail. Do you have any tips so I can continue to access the axis box from within the Graphics Script? Would be much appreciated.

 

txnelson
Super User

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

Rather than setting

ccReport = cc << Report;

I think you should reference it from the source when you use it

report(cc)[AxisBox(1)] << max(X+1);

Below is a sample script that is picking up the correct references off of cc

names default to here(1);
dt=current data table();

cc = Control Chart Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Show Capability( 0 ),
	Variables( Y( :weight ) ));
	cs = cc << Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]<< add graphics script( show(cs<<get current,
	report(cc)[TextEditBox(1)]<<get text;)
);
Jim
scottahindle
Level IV

Re: Scripting Column Switcher to reach to changes in Y variable on a control chart

Thanks, Jim. It works great now.