<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Scripting Column Switcher to reach to changes in Y variable on a control chart in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261482#M51200</link>
    <description>&lt;P&gt;Thanks, Jim. It works great now.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 05:48:24 GMT</pubDate>
    <dc:creator>scottahindle</dc:creator>
    <dc:date>2020-04-27T05:48:24Z</dc:date>
    <item>
      <title>Scripting Column Switcher to reach to changes in Y variable on a control chart</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261310#M51144</link>
      <description>&lt;P&gt;I have a data table with numerous responses (numerous columns). All are valid to be control charted.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To adapt the x-axis to the number of data in any given column I can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nData = N Rows() - Col N Missing( Column( 1 ) );

ccReport = cc &amp;lt;&amp;lt; Report;
axisbox = ccReport[axis box( 1 )];
axisbox &amp;lt;&amp;lt; Max( nData + 3 ) &amp;lt;&amp;lt; inc( Ceiling( (nData + 3) / 15 ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that this syntax "ColumnSwitcherObject &amp;lt;&amp;lt; Get Current;" returns the name of the column but how do I access with JSL each time I update using column switcher?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:27:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261310#M51144</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2023-06-09T23:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Column Switcher to reach to changes in Y variable on a control chart</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261339#M51153</link>
      <description>&lt;P&gt;I think you can solve your problem by attaching a Graphics Script to the FrameBox() in the Control Chart.&amp;nbsp; The script will run anytime something is changed in the FrameBox().&amp;nbsp; Below is a simple script I believe you should be able to build on&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]&amp;lt;&amp;lt; add graphics script( show(cs&amp;lt;&amp;lt;get current));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Apr 2020 02:38:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261339#M51153</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-26T02:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Column Switcher to reach to changes in Y variable on a control chart</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261375#M51166</link>
      <description>&lt;P&gt;Thanks, Jim.&lt;/P&gt;
&lt;P&gt;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.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I capture the selected column easy enough:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ccReport[FrameBox(1)]&amp;lt;&amp;lt; add graphics script(
&amp;nbsp; cName = cs &amp;lt;&amp;lt; Get Current;
&amp;nbsp; show(cName);
&amp;nbsp; If(cName == "JW004",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;show("JW004 selected");
&amp;nbsp; ,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cName == "JW001",
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;show("JW001 selected");
,

);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other parts of the syntax I can easily change the x-axis using e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;nbsp;ccReport = cc &amp;lt;&amp;lt; Report;
&amp;nbsp;axisbox = ccReport[axis box( 1 )];
&amp;nbsp;axisbox &amp;lt;&amp;lt; max(x+1); // where x is the no. of data in the column&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem arrives if I put the axisbox syntax in the framebox. One of the errors is&lt;/P&gt;
&lt;PRE&gt;Send Expects Scriptable Object in access or evaluation of 'Send' , ccReport[axis box( 1 )] &amp;lt;&amp;lt; /*###*/Max( 200 ) /*###*/&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 15:28:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261375#M51166</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2020-04-26T15:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Column Switcher to reach to changes in Y variable on a control chart</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261420#M51177</link>
      <description>&lt;P&gt;Rather than setting&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ccReport = cc &amp;lt;&amp;lt; Report;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you should reference it from the source when you use it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;report(cc)[AxisBox(1)] &amp;lt;&amp;lt; max(X+1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Below is a sample script that is picking up the correct references off of cc&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Column Switcher( :weight, {:height, :weight} );


report(cc)[FrameBox(1)]&amp;lt;&amp;lt; add graphics script( show(cs&amp;lt;&amp;lt;get current,
	report(cc)[TextEditBox(1)]&amp;lt;&amp;lt;get text;)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Apr 2020 17:00:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261420#M51177</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-26T17:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Column Switcher to reach to changes in Y variable on a control chart</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261482#M51200</link>
      <description>&lt;P&gt;Thanks, Jim. It works great now.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 05:48:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Column-Switcher-to-reach-to-changes-in-Y-variable-on-a/m-p/261482#M51200</guid>
      <dc:creator>scottahindle</dc:creator>
      <dc:date>2020-04-27T05:48:24Z</dc:date>
    </item>
  </channel>
</rss>

