<?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: Is there a method to get axis values from graph builder? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/274569#M53254</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3648"&gt;@nikles&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Not sure of your user scenario, however, if the user is actively filtering, they can also change the GraphBuilder structure, different roles, etc. So a &lt;STRONG&gt;Filter Change Handler&lt;/STRONG&gt; would be&amp;nbsp; more robust. Also note the Where Clause() does not capture the Inverse. The script and the TextBox of the Where captures the Inverse as a Not (!)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24728i2FE8FE7A814A87CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Below and attached is a script that gets the Xticks and prints them to the Log when the filter changes.&amp;nbsp; Here is a screen shot of the embedded Log with comments (//) and extra line feeds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24729iDCFAD564A7A7C79C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Size(513, 406),
	Show Control Panel(0),
	Back Color("White"),
	Variables(X(:age), X(:sex, Position(1)), Y(:weight)),
	Elements(Points(X(1), Y, Legend(1)), Smoother(X(1), Y, Legend(2))),
	Local Data Filter(
		Add Filter(
			columns(:age),
			Where(:age == {12, 13, 14}),
			Display(:age, Size(170, 96), List Display)
		)
	),
	SendToReport(Dispatch({}, "", AxisBox, {Select}))
);
//iftb = (report(gb)[PictureBox(1)]&amp;lt;&amp;lt;sib)[TextBox(1)]; //get handle to the textbox 
ldf = (gb&amp;lt;&amp;lt;parent)&amp;lt;&amp;lt;child;
gbb = report(gb)[GraphBuilderBox(1)] ;

f = function({a}, {zz,aa1,varlist={}, _xvar_={}, i, _xticks={}},
      varlist = gbb &amp;lt;&amp;lt; get variables;
      for(i=1, i&amp;lt;=nitems(varlist), i++,
        if(nameExpr(varlist[i][2]) == nameExpr(Role( "X" )), insertinto(_xvar_, varlist[i][1] &amp;lt;&amp;lt;get name) );
       );
      zz= ldf &amp;lt;&amp;lt; get filtered rows;
      if(isMissing(zz), zz= Index(1, nrow(dt)) );
   //check for excluded rows   
      _excl = dt &amp;lt;&amp;lt; get excluded rows;
      aa1 = AssociativeArray(zz);
      aa1 = Remove(aa1, Aslist(_excl));
      zz  = aa1&amp;lt;&amp;lt;get keys;    
   //zz are the rows used in creating the graph  
   
   //now use the Associative Array to get unique values   
      _xticks = Associative Array( dt[zz,_xvar_], AsList(J(nitems(zz),1,1)) ) &amp;lt;&amp;lt; get keys;
      print(_xticks);  //see the log
   );
  f(1);
rs = ldf &amp;lt;&amp;lt; Make Filter Change Handler( f );


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Line 20 is commented; it shows how to get a handle to the Where TextBox.&lt;/LI&gt;
&lt;LI&gt;Key features of the function f used for the Filter Change Handler are the capabilties of the JMP implementation of Associative Array: multiple methods to define it;&amp;nbsp; to get unique values in a list; almost any JMP object can be used as a key.&lt;/LI&gt;
&lt;LI&gt;Other key features are:&amp;nbsp; dt[ zz, _xvar_] is a list of row values, and ldf &amp;lt;&amp;lt; get filtered rows.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jun 2020 11:34:52 GMT</pubDate>
    <dc:creator>gzmorgan0</dc:creator>
    <dc:date>2020-06-20T11:34:52Z</dc:date>
    <item>
      <title>Is there a method to get axis values from graph builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/274510#M53239</link>
      <description>&lt;P&gt;Hi. &amp;nbsp;I'm interested in knowing there is a scripting method to read the displayed values for an axis in graphbuilder and return them as a list. &amp;nbsp;IOW, is there a function or a message that can "get" the axis values from a graphbuilder reference or an axis box? &amp;nbsp;Something like: xval_lis = gb &amp;lt;&amp;lt; Get X Axis Values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, suppose I have the following graph:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nikles_0-1592588721798.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24723iF24D3597EC5D178A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nikles_0-1592588721798.png" alt="nikles_0-1592588721798.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Size(513, 406),
	Show Control Panel(0),
	Back Color("White"),
	Variables(X(:age), X(:sex, Position(1)), Y(:weight)),
	Elements(Points(X(1), Y, Legend(1)), Smoother(X(1), Y, Legend(2))),
	Local Data Filter(
		Add Filter(
			columns(:age),
			Where(:age == {12, 13, 14}),
			Display(:age, Size(170, 96), List Display)
		)
	),
	SendToReport(Dispatch({}, "", AxisBox, {Select}))
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here, since the user has excluded certain ages using the local data filter, not all of the ages in the table are shown in x-axis. &amp;nbsp;In this case I would like a way to read off which ages are actually displayed in the graph. &amp;nbsp;This question applies only when a nominal or ordinal-type variable is used for the axis (no continuous variables).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've considered the following scripting method:&lt;/P&gt;&lt;P&gt;1. Read the local data filter&lt;/P&gt;&lt;P&gt;2. Create a subset table of just the unfiltered rows&lt;/P&gt;&lt;P&gt;3. Use the Summarize function on that table to get my list of displayed axis values&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ldf_str = ldf &amp;lt;&amp;lt; Get Where Clause;  //ldf = reference to local data filter in gb window
clause = Parse(Regex(ldf_str, "Select Where\((.+)\)$", "\1"));
r = dt &amp;lt;&amp;lt; Get Rows Where(Eval(clause));   //dt = ref to main datable
dtsub = dt &amp;lt;&amp;lt; Subset(//Invisible,
	Selected Rows(0),
	Rows(r),
	Selected columns only(0)
);
Summarize(dtsub, xlev_lis = By(:age, :sex));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This method seems unwieldy though. &amp;nbsp;Is there a command that can&amp;nbsp;"get" the axis values from a graphbuilder reference or an axis box?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:29:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/274510#M53239</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2023-06-09T23:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a method to get axis values from graph builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/274569#M53254</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3648"&gt;@nikles&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Not sure of your user scenario, however, if the user is actively filtering, they can also change the GraphBuilder structure, different roles, etc. So a &lt;STRONG&gt;Filter Change Handler&lt;/STRONG&gt; would be&amp;nbsp; more robust. Also note the Where Clause() does not capture the Inverse. The script and the TextBox of the Where captures the Inverse as a Not (!)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24728i2FE8FE7A814A87CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Below and attached is a script that gets the Xticks and prints them to the Log when the filter changes.&amp;nbsp; Here is a screen shot of the embedded Log with comments (//) and extra line feeds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24729iDCFAD564A7A7C79C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Size(513, 406),
	Show Control Panel(0),
	Back Color("White"),
	Variables(X(:age), X(:sex, Position(1)), Y(:weight)),
	Elements(Points(X(1), Y, Legend(1)), Smoother(X(1), Y, Legend(2))),
	Local Data Filter(
		Add Filter(
			columns(:age),
			Where(:age == {12, 13, 14}),
			Display(:age, Size(170, 96), List Display)
		)
	),
	SendToReport(Dispatch({}, "", AxisBox, {Select}))
);
//iftb = (report(gb)[PictureBox(1)]&amp;lt;&amp;lt;sib)[TextBox(1)]; //get handle to the textbox 
ldf = (gb&amp;lt;&amp;lt;parent)&amp;lt;&amp;lt;child;
gbb = report(gb)[GraphBuilderBox(1)] ;

f = function({a}, {zz,aa1,varlist={}, _xvar_={}, i, _xticks={}},
      varlist = gbb &amp;lt;&amp;lt; get variables;
      for(i=1, i&amp;lt;=nitems(varlist), i++,
        if(nameExpr(varlist[i][2]) == nameExpr(Role( "X" )), insertinto(_xvar_, varlist[i][1] &amp;lt;&amp;lt;get name) );
       );
      zz= ldf &amp;lt;&amp;lt; get filtered rows;
      if(isMissing(zz), zz= Index(1, nrow(dt)) );
   //check for excluded rows   
      _excl = dt &amp;lt;&amp;lt; get excluded rows;
      aa1 = AssociativeArray(zz);
      aa1 = Remove(aa1, Aslist(_excl));
      zz  = aa1&amp;lt;&amp;lt;get keys;    
   //zz are the rows used in creating the graph  
   
   //now use the Associative Array to get unique values   
      _xticks = Associative Array( dt[zz,_xvar_], AsList(J(nitems(zz),1,1)) ) &amp;lt;&amp;lt; get keys;
      print(_xticks);  //see the log
   );
  f(1);
rs = ldf &amp;lt;&amp;lt; Make Filter Change Handler( f );


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Line 20 is commented; it shows how to get a handle to the Where TextBox.&lt;/LI&gt;
&lt;LI&gt;Key features of the function f used for the Filter Change Handler are the capabilties of the JMP implementation of Associative Array: multiple methods to define it;&amp;nbsp; to get unique values in a list; almost any JMP object can be used as a key.&lt;/LI&gt;
&lt;LI&gt;Other key features are:&amp;nbsp; dt[ zz, _xvar_] is a list of row values, and ldf &amp;lt;&amp;lt; get filtered rows.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2020 11:34:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/274569#M53254</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2020-06-20T11:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a method to get axis values from graph builder?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/276044#M53567</link>
      <description>Thanks &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/70"&gt;@gzmorgan0&lt;/a&gt;. It took a little time for me to grasp, but this is a nice solution. I appreciate the help!</description>
      <pubDate>Mon, 29 Jun 2020 17:21:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-method-to-get-axis-values-from-graph-builder/m-p/276044#M53567</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2020-06-29T17:21:06Z</dc:date>
    </item>
  </channel>
</rss>

