<?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: Get variable names from graphbuilder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272860#M53069</link>
    <description>Hi Jim. Thanks for your reply. Unfortunately the problem I have is that my script will not have any knowledge of the "gb" ref in your example. The only thing my script would be able to reference is the window and the subsequent display boxes. If I could somehow get the reference to gb however, then yes, your method is precisely the way I'd prefer to go.</description>
    <pubDate>Mon, 15 Jun 2020 21:44:58 GMT</pubDate>
    <dc:creator>nikles</dc:creator>
    <dc:date>2020-06-15T21:44:58Z</dc:date>
    <item>
      <title>Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272624#M53022</link>
      <description>&lt;P&gt;Hi. &amp;nbsp;Is there a method to get the variable names &amp;amp; roles used in a graph builder window? &amp;nbsp;Suppose I have a window containing a graph builder plot. &amp;nbsp;Is there a way to programmatically determine which variable was used for X, Y, Xgroup, Ygroup, etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, suppose the user created a plot in gb. &amp;nbsp;Now they wish to run some generalized script on the plot (e.g. a graphics script). &amp;nbsp;The script needs to know what variables were used in which roles without the user telling it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I start with this plot:&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(
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y), Smoother(X, Y))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I wish to run a script on the resulting plot. &amp;nbsp;My script is unaware of what is contained in the plot. &amp;nbsp;Here are 2 things I tried but did not work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

//Try to get script used to create plot
win = Window(1);  			//gets most recent window clicked on
gb = win &amp;lt;&amp;lt; Report;               //DNW: returns missing (win is not a platform)
scr = gb &amp;lt;&amp;lt; Get Script;  //from here I could parse the string to determine the roles

//Another stab: try to read the XML
win = Window(1);
str = win &amp;lt;&amp;lt; Get XML;  //This gives me the XML of the window, but does not provide the actual variable names used in the roles.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I could figure out how to convert the window reference into a report, I think I could get that first method to work. &amp;nbsp;Any ideas?&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;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:29:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272624#M53022</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2023-06-09T23:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272634#M53025</link>
      <description>&lt;P&gt;I thought that I remembered a previous question about this, but I searched and did not find one.&amp;nbsp; Regardless, the method that I have used to do this kind of thing, is to send a Message to Graph Builder to retrieve the script used to create the display, into a character variable, and then I parse through the string to find the variables mentioned.&lt;/P&gt;
&lt;P&gt;The script&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(
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);

theScript = char(gb &amp;lt;&amp;lt; get script);
show(theScript);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;retrieves:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;theScript = "Graph Builder(Variables(X(:weight), Y(:height)), Elements(Points(X, Y, Legend(6)), Smoother(X, Y, Legend(7))))";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jun 2020 00:34:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272634#M53025</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-06-15T00:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272731#M53046</link>
      <description>&lt;P&gt;The Hover Label Extensions added in JMP 15 allow you to define a script that will be executed in the context of a graph (a Hover Label Execution Context to be precise). This context provides information in local variables about the visual element that is being hovered over, including which variables are being used as "groupings" (X, GroupX, GroupY, etc), and measurements (Y, Color, Size, etc).&lt;/P&gt;
&lt;P&gt;You can access these variables in your own script, and perhaps use them to define a new visualization or analysis. This is precisely how the Hover Label Presets work. You might want to select one and then take a look at the generated JSL code in the Hover Label Editor (or by saving the script) to see an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also see their values by using the Textlet "context" preset (available from the Textlet panel on the Hover Label Editor):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hlec_context.PNG" style="width: 617px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24581i6F85B8B30A4DAB23/image-size/large?v=v2&amp;amp;px=999" role="button" title="hlec_context.PNG" alt="hlec_context.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A full list of the variables that are made available in the execution context is given &lt;A href="https://www.jmp.com/support/help/en/15.1/index.shtml#page/jmp/work-with-the-hover-label-execution-context.shtml" target="_self"&gt;here.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 15:57:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272731#M53046</guid>
      <dc:creator>nascif_jmp</dc:creator>
      <dc:date>2020-06-15T15:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272860#M53069</link>
      <description>Hi Jim. Thanks for your reply. Unfortunately the problem I have is that my script will not have any knowledge of the "gb" ref in your example. The only thing my script would be able to reference is the window and the subsequent display boxes. If I could somehow get the reference to gb however, then yes, your method is precisely the way I'd prefer to go.</description>
      <pubDate>Mon, 15 Jun 2020 21:44:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272860#M53069</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2020-06-15T21:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272862#M53070</link>
      <description>Thanks nascif_jmp. I'm actually still on JMP14, so I'm not yet familiar with Hover Label Extensions. I can switch to 15, but old habits...&lt;BR /&gt;&lt;BR /&gt;Quick question though...I'm looking for some method to programmatically read the variables from a window containing a graphbuilder plot. However, from its name it sounds like the Hover tool would require the user to interact with the window by hovering over various items. Is there a way to have this done automatically by a script? And can it be done if all I have is a reference to the window in which the gb plot exists (not a reference to the gb itself)?</description>
      <pubDate>Mon, 15 Jun 2020 21:52:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/272862#M53070</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2020-06-15T21:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/273026#M53100</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3648"&gt;@nikles&lt;/a&gt;&amp;nbsp;you are correct, the hover label functionality is based on interactivity. There are ways to trigger that using JSL (by moving the mouse, pausing, etc.) but that would add a lot of complexity to the solution that you really don't need.&lt;/P&gt;
&lt;P&gt;Based on your reply to and the solution proposed by&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, here is a script that will take you from the windows reference all the way down to the Graph Builder variable references.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
win = New Window("A Title",    // Let's create a Window that contains a Graph Builder
Graph Builder(                 // with a LDF to make things interesting (multiple OutlineBoxes).
	Size( 517, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :height ) ),
	Elements( Bar( X, Y, Legend( 6 ) ) ),
	Local Data Filter(
		Add Filter( columns( :height ), Where( :height &amp;gt;= 60.048 &amp;amp; :height &amp;lt;= 70 ) )
	)
));
ob = win[OutlineBox("Graph Builder")]; // This is how you get the Display Box that contains the GB object
gbb = ob &amp;lt;&amp;lt; Get Scriptable Object;     // Now we extract the GB object from the Display Box
gb_expr = gbb &amp;lt;&amp;lt; Get Script;           // You could wrap in Char() to get the GB script as a string
gb_nargs = NArg(gb_expr);              // and use pattern matching. Instead, 
for(i = 1, i &amp;lt;= gb_nargs, i++,         // let's see how to inspect it as an expression.
	child = Arg(gb_expr, i);
	If (HeadName(child) == "Variables",
		var_nargs = NArg(child);
		for(j = 1, j &amp;lt;= var_nargs, j++,
			Show(Arg(child, j))
		);
		Break();
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you should see:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Arg(child, j) = X(:sex);
Arg(child, j) = Y(:height);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 14:55:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/273026#M53100</guid>
      <dc:creator>nascif_jmp</dc:creator>
      <dc:date>2020-06-16T14:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable names from graphbuilder</title>
      <link>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/273136#M53117</link>
      <description>Thanks. That was exactly what I needed.</description>
      <pubDate>Wed, 17 Jun 2020 01:03:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-variable-names-from-graphbuilder/m-p/273136#M53117</guid>
      <dc:creator>nikles</dc:creator>
      <dc:date>2020-06-17T01:03:20Z</dc:date>
    </item>
  </channel>
</rss>

