<?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 How to script frame size for existing Graph Builder window in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/635782#M83392</link>
    <description>&lt;P&gt;Is there a way to set the frame size for an existing Graph Builder window with JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g., suppose I have a Graph Builder window open, and I would like to run a JSL file that will set the overall frame size of the graph in that window to 800x600.&amp;nbsp; Is that possible without having the reference to the GB object in the JSL script?&lt;/P&gt;</description>
    <pubDate>Fri, 26 May 2023 04:20:37 GMT</pubDate>
    <dc:creator>BHarris</dc:creator>
    <dc:date>2023-05-26T04:20:37Z</dc:date>
    <item>
      <title>How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/635782#M83392</link>
      <description>&lt;P&gt;Is there a way to set the frame size for an existing Graph Builder window with JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g., suppose I have a Graph Builder window open, and I would like to run a JSL file that will set the overall frame size of the graph in that window to 800x600.&amp;nbsp; Is that possible without having the reference to the GB object in the JSL script?&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 04:20:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/635782#M83392</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-05-26T04:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/635785#M83393</link>
      <description>&lt;P&gt;Easiest would be if you can get the reference to the Graph Builder. You can for example use &amp;lt;&amp;lt; Get Scriptable Object after you have the reference to the outline box&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("",
	Graph Builder(
		Variables(X(:height), Y(:weight)),
		Elements(Points(X, Y), Smoother(X, Y))
	);	
);

gb = (nw[OutlineBox("Graph Builder")] &amp;lt;&amp;lt; Get Scriptable Object);
fb = Report(gb)[FrameBox(1)];
fb &amp;lt;&amp;lt; Frame Size(800,200);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or in some cases you might be able to find framebox directly from window&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("",
	Graph Builder(
		Variables(X(:height), Y(:weight)),
		Elements(Points(X, Y), Smoother(X, Y))
	);	
);

nw[FrameBox(1)] &amp;lt;&amp;lt; Frame Size(800,200);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And finally XPath&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("",
	Graph Builder(
		Variables(X(:height), Y(:weight)),
		Elements(Points(X, Y), Smoother(X, Y))
	);	
);

(nw &amp;lt;&amp;lt; XPath("//FrameBox")) &amp;lt;&amp;lt; Frame Size(800,200);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can get reference to the window using Current Window(), but it is a bit annoying to use from script window and works much better from toolbar/shortcut/add-in.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 05:02:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/635785#M83393</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-26T05:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636039#M83410</link>
      <description>&lt;P&gt;Here is an alternative approach. You can get a list of all the current windows. They are ordered by appearance, so if you just opened Graph Builder, it will be the last item. Otherwise, you can inspect the list of windows to find the GB you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

obj = dt &amp;lt;&amp;lt; Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

win = Get Window List();
frame = (win[N Items(win)] &amp;lt;&amp;lt; XPath( "//FrameBox" ))[1];
frame &amp;lt;&amp;lt; Select &amp;lt;&amp;lt; Frame Size( 800, 600 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your script could be add as a menu or toolbar item, or made into an add-in.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 13:23:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636039#M83410</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-05-26T13:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636177#M83426</link>
      <description>&lt;P&gt;I like this answer, but it errors out when I take out the "dt =..." and "obj = ..." lines and put "//!" at the top and double-click it.&amp;nbsp; Here's the error:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Subscript Range in access or evaluation of '(win[N Items(win)] &amp;lt;&amp;lt; XPath("//FrameBox"))[ /*###*/1]' , (win[N Items( win )] &amp;lt;&amp;lt; XPath( "//FrameBox" ))[/*###*/1]&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 26 May 2023 21:02:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636177#M83426</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-05-26T21:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636881#M83473</link>
      <description>&lt;P&gt;For&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;'s script to work as-written the graph box would have to be the last window open, I am guessing when launching it from a separate script that is no longer the case.&amp;nbsp; You could modify it like this to only pick graph builder windows, you would want check that at least one window is open.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

//Find graph builder windows
graphs = filter each({w}, win, 
	if(
		length(w &amp;lt;&amp;lt; XPath("//OwnerBox[@helpKey='Graph Builder']")) &amp;gt; 0 ,
		1,
		0
	)
);

//Choose the last one
frame = (graphs[N Items(graphs)] &amp;lt;&amp;lt; XPath( "//FrameBox" ))[1];

//Modify the frame
frame &amp;lt;&amp;lt; Select &amp;lt;&amp;lt; Frame Size( 800, 600 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I do something similar to this when looking for 3d plot windows in this add-in: &lt;LI-MESSAGE title="3D Plot Tools" uid="48699" url="https://community.jmp.com/t5/JMP-Add-Ins/3D-Plot-Tools/m-p/48699#U48699" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;, and there I let the user choose which windows(s) to modify.&amp;nbsp;The code is on &lt;A href="https://github.com/himanga/JMP3DPlotTools/blob/master/src/main.jsl" target="_self"&gt;GitHub&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 14:48:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/636881#M83473</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2023-05-30T14:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637235#M83498</link>
      <description>&lt;P&gt;Awesome.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, that if "Fit to Window" is not "off", those Frame Sizes don't always work.&amp;nbsp; I've tried for 30 minutes to adapt this code to also modify the "Fit to Window" setting without luck.&amp;nbsp; Any ideas how to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, curiously, if the Graph Builder window has multiple plots, e.g. with a variable in the Wrap field, the Frame Size modifies the individual plot frames instead of the entire plot area.&amp;nbsp; Is it possible to resize the entire plot area to a given size instead of the individual plots?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, where did you learn to code like this?&amp;nbsp; As a 10-year python coder (and 20-year perl coder), I'll say that JSL is pretty hard to understand.&amp;nbsp; Even after reading the Scripting Index on those items (XPath, Select...) I'm still not sure what they mean here...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 03:59:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637235#M83498</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-05-31T03:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637314#M83504</link>
      <description>&lt;P&gt;Just guessing here... Fit to Window must be sent to Graph Builder not to frame box (&amp;lt;&amp;lt; Get Scriptable Object might help here). If Wrap is used (or Group X), maybe you will have to calculate the size based on how many groups there are. Or you could maybe manipulate the size of graph builder window?&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))
);

wait(0);

win = Get Window List();

//Find graph builder windows
graphs = Filter Each({w}, win,
	If(Length(w &amp;lt;&amp;lt; XPath("//OutlineBox[@helpKey='Graph Builder']")) &amp;gt; 0, 1, 0)
);

last_gb = graphs[N Items(graphs)][OutlineBox("Graph Builder")] &amp;lt;&amp;lt; Get Scriptable Object;
last_gb &amp;lt;&amp;lt; Fit to Window("On");

last_gb &amp;lt;&amp;lt; Size(800,600); // instead of manipulating framebox

//frame = Report(last_gb)[FrameBox(1)];
//frame &amp;lt;&amp;lt; Frame Size(800, 600);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;XPath isn't JMP thing&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/XPath" target="_blank" rel="noopener"&gt;XPath - Wikipedia&lt;/A&gt;, but it is easy way to access different objects in reports. Using &amp;lt;&amp;lt; Get XML helps you seeing what you are XPathing&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Report(gb) &amp;lt;&amp;lt; Get Xml;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:25:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637314#M83504</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-31T12:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to script frame size for existing Graph Builder window</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637473#M83523</link>
      <description>&lt;P&gt;That did it!&amp;nbsp; Thanks, Jarmo, and to everyone who responded!!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 16:30:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-frame-size-for-existing-Graph-Builder-window/m-p/637473#M83523</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-05-31T16:30:46Z</dc:date>
    </item>
  </channel>
</rss>

