<?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: Dynamically change latitude and longitude in Graph Builder with ComboBox pulldown menu in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905965#M106428</link>
    <description>&lt;P&gt;Thanks, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;. This is perfect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the idea is to wrap the ComboBox actions in an Eval() block and then run the block as a script when ComboBox is executed. I think I'm interpreting this correctly.&lt;/P&gt;</description>
    <pubDate>Sat, 04 Oct 2025 20:12:28 GMT</pubDate>
    <dc:creator>scott1588</dc:creator>
    <dc:date>2025-10-04T20:12:28Z</dc:date>
    <item>
      <title>Dynamically change latitude and longitude in Graph Builder with ComboBox pulldown menu</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905914#M106424</link>
      <description>&lt;P&gt;Note: Data and script uploaded below...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have developed the following script that first plots a wide area showing a route taken. A modal window pops up that allows the user to enter a code for a specific location -- in this example a 1 or 2. With this information, the graph will zoom in to that location. All this works fine but it's not exactly what I need. Most importantly, the dialog box disappears once the selection in made and the script ends. Second, I have been trying to get this to work with a ComboBox pulldown menu. I can get the menu itself working but for some reason, I can't seem to get the choice to make a change in the graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is what I have with the modal text box...&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 = Data Table( "Test Data" );

gb = Graph Builder(
	Graph Spacing( 10 ),
	Spacing Borders( 1 ),
	Variables( X( :Longitude ), Y( :Latitude ) ),
	Elements( Points( X, Y, Legend( 3 ) ) ),
	SendToReport(
		Dispatch( {}, "Longitude", ScaleBox, {Min( -104 ), Max( -98.47 )} ),
		Dispatch( {}, "Latitude", ScaleBox, {Min( 29.21 ), Max( 33.30 )} ),		
		Dispatch( {}, "Graph Builder", FrameBox,
			{Background Map( Images( "Street Map Service", "Mapbox Satellite", "" ) )}
		)
	)
);

// Build the modal input window
New Window( "Pick a spot", 
	Modal,
	H List Box(
		V List Box( Text Box( "Location Number:" ), ),
		V List Box( box = Number Edit Box( "Enter location number..." ), )
	),
	Button Box( "OK", 
		// Script to run when "OK" is clicked
		locNum = box &amp;lt;&amp;lt; Get;
		Print( "Location Number: " || Char( locNum ) );
	),
	Button Box( "Cancel", 
		// Script to run when "Cancel" is clicked
		Throw()
	)
);


If(
	locNum == 1,
		minLat = 30.99;
		maxLat = 31.06;
		minLong = -101.21;
		maxLong = -101.11;
		run = "1|1";,
	locNum == 2,
		minLat = 31.34;
		maxLat = 31.41;
		minLong = -101.81;
		maxLong = -101.71;
		run = "2|1";
);

gb &amp;lt;&amp;lt; Dispatch( {}, "Longitude", ScaleBox, {Min( minLong ), Max( maxLong )} );

gb &amp;lt;&amp;lt; Dispatch( {}, "Latitude", ScaleBox, {Min( minLat ), Max( maxLat )} );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The initial map looks like this...&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="scott1588_0-1759561057434.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/84339i2706FB457EC0E7B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="scott1588_0-1759561057434.png" alt="scott1588_0-1759561057434.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the zoomed in view looks like this...&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="scott1588_1-1759561157817.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/84340i8A386A578758D26C/image-size/large?v=v2&amp;amp;px=999" role="button" title="scott1588_1-1759561157817.png" alt="scott1588_1-1759561157817.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So my dilemmas are 1) how do I get the ComboBox to work with this, and 2) how can I prevent the script from completing so the user can continue to select different items from the pulldown menu.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a feeling this has something to do with the Set Function command but my multiple attempts at getting this to work have been fruitless.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any guidance on this would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 07:04:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905914#M106424</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2025-10-04T07:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change latitude and longitude in Graph Builder with ComboBox pulldown menu</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905947#M106427</link>
      <description>&lt;P&gt;I wouldn't use modal window for something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Data Table("Test Data");

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Graph Spacing(10),
	Spacing Borders(1),
	Variables(X(:Longitude), Y(:Latitude)),
	Elements(Points(X, Y, Legend(3))),
	SendToReport(
		Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
		Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
		Dispatch({}, "Graph Builder", FrameBox,
			{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
		)
	)
);
wait(0);

cb_expr = Expr(
	locNum = cb_option &amp;lt;&amp;lt; get;
	show(locNum);
	If(
		locNum == 1,
			minLat = 30.99;
			maxLat = 31.06;
			minLong = -101.21;
			maxLong = -101.11;
			run = "1|1";,
		locNum == 2,
			minLat = 31.34;
			maxLat = 31.41;
			minLong = -101.81;
			maxLong = -101.71;
			run = "2|1";
	);

	gb &amp;lt;&amp;lt; Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});

	gb &amp;lt;&amp;lt; Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
);


// Build the modal input window
nw = New Window("Pick a spot",
	Lineup Box(N Col(2), 
		Text Box("Location Number:"), 
		cb_option = Combo Box({"1", "2"},
			cb_expr
		),
	),
	Button Box("OK",
		cb_expr; // not necessary if you wish to run when combo box is changed
		Print("Location Number: " || Char(locNum));
	),
	Button Box("Cancel", 
		// Script to run when "Cancel" is clicked
		Throw()
	)
);



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also move your options into associative array so it makes it easier to add more options later&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 13:16:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905947#M106427</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-04T13:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change latitude and longitude in Graph Builder with ComboBox pulldown menu</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905965#M106428</link>
      <description>&lt;P&gt;Thanks, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;. This is perfect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the idea is to wrap the ComboBox actions in an Eval() block and then run the block as a script when ComboBox is executed. I think I'm interpreting this correctly.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 20:12:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/905965#M106428</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2025-10-04T20:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically change latitude and longitude in Graph Builder with ComboBox pulldown menu</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/906012#M106435</link>
      <description>&lt;P&gt;You can move the expression inside combo box BUT it is generally much easier to modify if you separate it, especially if you are using same action in multiple places&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Data Table("Test Data");

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Graph Spacing(10),
	Spacing Borders(1),
	Variables(X(:Longitude), Y(:Latitude)),
	Elements(Points(X, Y, Legend(3))),
	SendToReport(
		Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
		Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
		Dispatch({}, "Graph Builder", FrameBox,
			{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
		)
	)
);
wait(0);

// Build the modal input window
nw = New Window("Pick a spot",
	Lineup Box(N Col(2), 
		Text Box("Location Number:"), 
		cb_option = Combo Box({"1", "2"},
			locNum = cb_option &amp;lt;&amp;lt; get;
			show(locNum);
			If(
				locNum == 1,
					minLat = 30.99;
					maxLat = 31.06;
					minLong = -101.21;
					maxLong = -101.11;
					run = "1|1";,
				locNum == 2,
					minLat = 31.34;
					maxLat = 31.41;
					minLong = -101.81;
					maxLong = -101.71;
					run = "2|1";
			);

			gb &amp;lt;&amp;lt; Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});

			gb &amp;lt;&amp;lt; Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
		),
	),
	Button Box("OK",
		locNum = cb_option &amp;lt;&amp;lt; get;
		show(locNum);
		If(
			locNum == 1,
				minLat = 30.99;
				maxLat = 31.06;
				minLong = -101.21;
				maxLong = -101.11;
				run = "1|1";,
			locNum == 2,
				minLat = 31.34;
				maxLat = 31.41;
				minLong = -101.81;
				maxLong = -101.71;
				run = "2|1";
		);

		gb &amp;lt;&amp;lt; Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});

		gb &amp;lt;&amp;lt; Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
		Print("Location Number: " || Char(locNum));
	),
	Button Box("Cancel", 
		// Script to run when "Cancel" is clicked
		Throw()
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;You can also use &amp;lt;&amp;lt; Set Function instead of &amp;lt;&amp;lt;Set Script (&amp;lt;&amp;lt;Set Script isn't usually "visible", but it is the same as optional &amp;lt;script&amp;gt; argument you can use,&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/18.2/#page/jmp/construct-display-boxes-for-new-windows.shtml#ww634710" target="_self"&gt;Combo Box&lt;/A&gt;)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

aa_options = Associative Array(); 
aa_options[1] = [
	"minLat" =&amp;gt; 30.99,
	"maxLat" =&amp;gt; 31.06,
	"minLong" =&amp;gt; -101.21,
	"maxLong" =&amp;gt; -101.11,
	"run" =&amp;gt; "1|1"
];
aa_options[2] = [
	"minLat" =&amp;gt; 31.34,
	"maxLat" =&amp;gt; 31.41,
	"minLong" =&amp;gt; -101.81,
	"maxLong" =&amp;gt; -101.71,
	"run" =&amp;gt; "2|1"
];

update_graph = Function({cb_ref, idx}, {Default Local},
	s = aa_options[idx];
	show(s);
	gb &amp;lt;&amp;lt; Dispatch({}, "Longitude", ScaleBox, {Min(s["minLong"]), Max(s["maxLong"])});
	gb &amp;lt;&amp;lt; Dispatch({}, "Latitude", ScaleBox, {Min(s["minLat"]), Max(s["maxLat"])});	
);



dt = Data Table("Test Data");

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Graph Spacing(10),
	Spacing Borders(1),
	Variables(X(:Longitude), Y(:Latitude)),
	Elements(Points(X, Y, Legend(3))),
	SendToReport(
		Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
		Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
		Dispatch({}, "Graph Builder", FrameBox,
			{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
		)
	)
);
wait(0);


options = Transform Each({item}, aa_options &amp;lt;&amp;lt; get keys, Char(item)); // combo box requires strings
nw = New Window("Pick a spot",
	Lineup Box(N Col(2), 
		Text Box("Location Number:"), 
		cb_option = Combo Box(options, 
			&amp;lt;&amp;lt; Set Function(Function({this, idx},
				update_graph(this, idx);
			))
		)
	),
	Button Box("Cancel", 
		&amp;lt;&amp;lt; Set Function(function({this},
			this &amp;lt;&amp;lt; close window;
		))
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Oct 2025 07:15:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamically-change-latitude-and-longitude-in-Graph-Builder-with/m-p/906012#M106435</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-05T07:15:54Z</dc:date>
    </item>
  </channel>
</rss>

