<?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: How to check if graph builder legend is showing or not in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462399#M70717</link>
    <description>&lt;P&gt;If you use the Visibility message to open and close the Legend, the Get Visibility message will return the status.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
gb =Graph Builder(
	Size( 525, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

report(gb)[legendbox(1)]&amp;lt;&amp;lt;visibility("collapse");

report(gb)[legendbox(1)]&amp;lt;&amp;lt;get visibility;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, the Visibility status will not change if the legend is set using&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb &amp;lt;&amp;lt; Show Legend(0);
// or
gb &amp;lt;&amp;lt; Show Legend(1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 19 Feb 2022 20:20:55 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-02-19T20:20:55Z</dc:date>
    <item>
      <title>How to check if graph builder legend is showing or not</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462377#M70714</link>
      <description>&lt;P&gt;I was wondering what the script would be to check if the graph builder legend is showing or not.&amp;nbsp; I want to make a toolbar shortcut that would show or hide the legend depending on the state the legend is in (if showing then hide and if hidden then show).&amp;nbsp; thanks for any suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:11:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462377#M70714</guid>
      <dc:creator>shampton82</dc:creator>
      <dc:date>2023-06-09T18:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if graph builder legend is showing or not</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462398#M70716</link>
      <description>&lt;P&gt;I tried to check how I could see if legend is showing or not, but couldn't figure out how it is being hidden by Show Legend() option. Show&amp;nbsp; properties didn't help either.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1645300290521.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40126i7D7605F8877F1C7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1645300290521.png" alt="jthi_0-1645300290521.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So only thing that easily came to my mind is to get script of the graph builder as string and then check if it has Show Legend(0) in it... this won't work if user has preferences changed so you will have to check for them also. Something like this might work (and there hopefully is easier/more robust way to do this):&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 = dt &amp;lt;&amp;lt; Graph Builder(Variables(X(:Sex), Y(:Height), Group X(:Age)), Elements(Box Plot(X, Y)));

change_legend_state = function({gb_ref}, {Default Local},
	legend_pref = Char(Get Platform Preference(Graph Builder(Show Legend)));
	gb_script = Char(gb_ref &amp;lt;&amp;lt; Get Script());
	If(Contains(legend_pref, "Show Legend(0)") &amp;amp; !Contains(gb_script, "Show Legend(1)"),
		gb_ref &amp;lt;&amp;lt; Show Legend(1);
	,
		gb_ref &amp;lt;&amp;lt; Show Legend(0);
	);	
);
wait(1);
change_legend_state(gb);
wait(1);
change_legend_state(gb);&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 20:02:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462398#M70716</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-02-19T20:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if graph builder legend is showing or not</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462399#M70717</link>
      <description>&lt;P&gt;If you use the Visibility message to open and close the Legend, the Get Visibility message will return the status.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
gb =Graph Builder(
	Size( 525, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :sex ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

report(gb)[legendbox(1)]&amp;lt;&amp;lt;visibility("collapse");

report(gb)[legendbox(1)]&amp;lt;&amp;lt;get visibility;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, the Visibility status will not change if the legend is set using&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb &amp;lt;&amp;lt; Show Legend(0);
// or
gb &amp;lt;&amp;lt; Show Legend(1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Feb 2022 20:20:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462399#M70717</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-02-19T20:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if graph builder legend is showing or not</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462458#M70722</link>
      <description>&lt;P&gt;This is close enough so appreciate it!&amp;nbsp; It's to bad there isn't something like &amp;lt;&amp;lt;get show legend(); to get the legend state (1/0) since as you said this solution will not work if the legend state has been changed through either JSL or the control panel.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Feb 2022 01:59:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-graph-builder-legend-is-showing-or-not/m-p/462458#M70722</guid>
      <dc:creator>shampton82</dc:creator>
      <dc:date>2022-02-20T01:59:06Z</dc:date>
    </item>
  </channel>
</rss>

