<?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: [Help] - How to get graph builder with polygon updated as slider changes in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-How-to-get-graph-builder-with-polygon-updated-as-slider/m-p/888211#M105051</link>
    <description>&lt;UL&gt;
&lt;LI&gt;the variables offset_x and _y need to be defined, possibly as arrays&lt;/LI&gt;
&lt;LI&gt;the sb&amp;lt;&amp;lt;setfunction at the end is probably overriding (and throwing away) the important bit "tb &amp;lt;&amp;lt; Set Table Variable( "scaleFactor", sliderValue )"&lt;/LI&gt;
&lt;LI&gt;Possibly something like this will make it more interactive once the offsets are defined&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sb &amp;lt;&amp;lt; Set Function(
	Function( {thisBox},
		((((thisBox) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; Set Text( Char( thisBox &amp;lt;&amp;lt; Get ) );
		tb &amp;lt;&amp;lt; Set Table Variable( "scaleFactor", sliderValue );
		tb &amp;lt;&amp;lt; rerunformulas;
		chartdisplay &amp;lt;&amp;lt; inval &amp;lt;&amp;lt; reshow;
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;edit: added&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;offset_x = j(19999,1,0);
offset_y = j(19999,1,0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;near the top and it does look interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6375878221112w960h540r348" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6375878221112" data-account="6058004218001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6058004218001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6375878221112w960h540r348');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.jmp.com/t5/video/gallerypage/video-id/6375878221112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jul 2025 11:35:03 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2025-07-20T11:35:03Z</dc:date>
    <item>
      <title>[Help] - How to get graph builder with polygon updated as slider changes</title>
      <link>https://community.jmp.com/t5/Discussions/Help-How-to-get-graph-builder-with-polygon-updated-as-slider/m-p/888184#M105048</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;I am quite new in JSL scripting. Currently, I added Slider to change some variable in data table. Data table gets updated as&amp;nbsp; the slider change&lt;/P&gt;
&lt;P&gt;In the next step, I would like to get data 2 column in the data table to turn them into matrix and starting draw Polygon in Graph Builder&lt;/P&gt;
&lt;P&gt;However , I face some difficulty that once I move sliders, the content does not change:&lt;/P&gt;
&lt;P&gt;1. I add one text box in New window and display Column value of data table&lt;/P&gt;
&lt;P&gt;2. Polygon with coordinates from data table does not change in graph builder&lt;/P&gt;
&lt;P&gt;My purpose is once I move slider, the content in Text Box and graph changes as well&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PhamBao_0-1752997200474.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78604iC992BFC485C383AC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PhamBao_0-1752997200474.png" alt="PhamBao_0-1752997200474.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here is my code:&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("ww17_DATAALL_TRIAL.jmp");
 
//get malahanobis distance
multi = dt &amp;lt;&amp;lt; Multivariate(
	Y(:FORCEDROPTIME_3, :ACTUAL_MAXCHASEHOLDFORCE_4),
	Variance Estimation("Row-wise"),
	Scatterplot Matrix(1),
	Pairwise Correlations(1)
);
multi &amp;lt;&amp;lt; Mahalanobis Distances(1, Save Outlier Distances);
mahal_ucl = Column("Mahal. Distances") &amp;lt;&amp;lt; Get Property("Mahal.Value");
mahal_max = Col Maximum(Column(dt, "Mahal. Distances"));
 
 
 
 
 
 
 
tri = Triangulation(X(:FORCEDROPTIME_3, :ACTUAL_MAXCHASEHOLDFORCE_4), Y(:BHT));
 
 
// get contour around all data point
hulledge = tri &amp;lt;&amp;lt; Get Hull Edges;
hullpoint = tri &amp;lt;&amp;lt; Get Hull Points;
{xx, yy} = tri &amp;lt;&amp;lt; Get Points();
tri2 = tri &amp;lt;&amp;lt; Subset(tri &amp;lt;&amp;lt; Get Hull Points); // get data point of boundary
{tri2_xx, tri2_yy} = tri2 &amp;lt;&amp;lt; Get Points();
 
centroid_x = Mean(tri2_xx); // calculate centroid x
centroid_y = Mean(tri2_yy); // calculate centroid y
 
centroid_tri2_xx_ang = []; // get distance between x and centroid
centroid_tri2_yy_ang = []; // get distance between x and centtroid
 
angles = {}; // angles
 
For(i = 1, i &amp;lt;= N Items(tri2_xx), i++,
	x_diff = tri2_xx[i] - centroid_x;
	Insert Into(centroid_tri2_xx_ang, x_diff);
	y_diff = tri2_yy[i] - centroid_y;
	Insert Into(centroid_tri2_yy_ang, y_diff);
);
//sort tri2_xx and tri2_yy to clockwise polygon
For(i = 1, i &amp;lt;= N Items(tri2_xx), i++,
	If(
		centroid_tri2_xx_ang[i] &amp;gt; 0,
			angles[i] = ATan(centroid_tri2_yy_ang[i] / centroid_tri2_xx_ang[i]),
		centroid_tri2_xx_ang[i] &amp;lt; 0 &amp;amp; centroid_tri2_yy_ang[i] &amp;gt;= 0,
			angles[i] = ATan(centroid_tri2_yy_ang[i] / centroid_tri2_xx_ang[i]) + 3.14,
		centroid_tri2_xx_ang[i] &amp;lt; 0 &amp;amp; centroid_tri2_yy_ang[i] &amp;lt; 0,
			angles[i] = ATan(centroid_tri2_yy_ang[i] / centroid_tri2_xx_ang[i]) - 3.14,
		centroid_tri2_xx_ang[i] == 0 &amp;amp; centroid_tri2_yy_ang[i] &amp;gt; 0, angles[i] = 3.14 / 2,
		centroid_tri2_xx_ang[i] == 0 &amp;amp; centroid_tri2_yy_ang[i] &amp;lt; 0, angles[i] = -3.14 / 2,

	)
);
Show(angles);
 
tb = New Table("tb",
	Add Rows(N Items(tri2_xx)),
	New Table Variable("scaleFactor", mahal_max),
	New Column("X", Numeric, "Continuous", Set Values(tri2_xx)),
	New Column("Y", Numeric, "Continuous", Set Values(tri2_yy)),
	New Column("Angle", Numeric, "Continuous", Set Values(angles)),
	New Column("MaxDistance", Numeric, "Continuous", Formula(mahal_max)),
	New Column("OffSet", Numeric, "Continuous", Formula(:scaleFactor + mahal_max))
);
sliderValue = tb &amp;lt;&amp;lt; Get Table Variable("scaleFactor");
 
 
//must be sorted the lists first
tb &amp;lt;&amp;lt; Sort(replace table, By(:Angle), Order(Descending));
tri2_xx_sort = Column(tb, "X") &amp;lt;&amp;lt; GetAsMatrix();
tri2_yy_sort = Column(tb, "Y") &amp;lt;&amp;lt; GetAsMatrix();
x2 = Column(tb, "X") &amp;lt;&amp;lt; GetAsMatrix();
y2 = Column(tb, "Y") &amp;lt;&amp;lt; GetAsMatrix();
 
 
tb &amp;lt;&amp;lt; New Column("OffSetX_temp",
	Numeric,
	"Continuous",
	Formula(CalculateOffsetPoints_X(:scaleFactor))
);
tb &amp;lt;&amp;lt; New Column("OffSetY_temp",
	Numeric,
	"Continuous",
	Formula(CalculateOffsetPoints_Y(:scaleFactor))
);
CalculateOffsetPoints_X = Function({:scaleFactor},
	For(i = 1, i &amp;lt;= N Items(x2), i++,
		j = Mod(i, N Items(x2)) + 1; // Next point index
		dx = x2[j] - x2[i];
		dy = y2[j] - y2[i];
		length = Sqrt(dx ^ 2 + dy ^ 2);
// Perpendicular vector
		perp_dx = -dy / length;
		perp_dy = dx / length;
// Offset points
		offset_x[i] = x2[i] + :scaleFactor * perp_dx;
		offset_y[i] = y2[i] + :scaleFactor * perp_dy;
 
	);
	Return(offset_x[Row()]);
);
CalculateOffsetPoints_Y = Function({:scaleFactor},
	For(i = 1, i &amp;lt;= N Items(x2), i++,
		j = Mod(i, N Items(x2)) + 1; // Next point index
		dx = x2[j] - x2[i];
		dy = y2[j] - y2[i];
		length = Sqrt(dx ^ 2 + dy ^ 2);
// Perpendicular vector
		perp_dx = -dy / length;
		perp_dy = dx / length;
// Offset points
		offset_x[i] = x2[i] + :scaleFactor * perp_dx;
		offset_y[i] = y2[i] + :scaleFactor * perp_dy;
	);
	Return(offset_y[Row()]);
);
 
 
New Window("DrawData",
	Outline Box("Polygon Shape Explorer",
		Panel Box("Slider",
			sb = Slider Box(
				0,
				100,
				sliderValue,
				tb &amp;lt;&amp;lt; Set Table Variable("scaleFactor", sliderValue)
			),
			Lineup Box(N Col(32),
				Text Box("Offset Value: "),
				Text Box(sliderValue),
				Text Box("Offset X: "),
				Text Box((Column(tb, "OffSetX_temp") &amp;lt;&amp;lt; GetAsMatrix())),

			)
		), 
 
 
		chartdisplay = dt &amp;lt;&amp;lt; Graph Builder(
			Size(725, 429),
			Show Control Panel(0),
			Variables(X(:FORCEDROPTIME_3), Y(:ACTUAL_MAXCHASEHOLDFORCE_4)),
			Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4))),
			SendToReport(
				Dispatch({}, "FORCEDROPTIME_3", ScaleBox,
					{Format("Best", 12), Min(Min(xx) - 30), Max(Max(xx) + 30), Inc(200),
					Minor Ticks(1)}
				),
				Dispatch({}, "ACTUAL_MAXCHASEHOLDFORCE_4", ScaleBox,
					{Format("Best", 12), Min(Min(yy) - 30), Max(Max(yy) + 30), Inc(100),
					Minor Ticks(4)}
				),
				Dispatch({}, "Graph Builder", FrameBox,
					{Add Graphics Script(
						2,
						Description(""),
						Transparency(0.5);
						Fill Color({1.0, 0.5, 0.0});
						Polygon(
							(Column(tb, "OffSetX_temp") &amp;lt;&amp;lt; GetAsMatrix()),
							(Column(tb, "OffSetY_temp") &amp;lt;&amp;lt; GetAsMatrix())
						);
						Transparency(0.5);
						Fill Color("Red");
						Polygon(
							(Column(tb, "X") &amp;lt;&amp;lt; GetAsMatrix()),
							(Column(tb, "Y") &amp;lt;&amp;lt; GetAsMatrix())
						);
					)}
				)
			)
		);
 
 
	)
);
 
 
 
sb &amp;lt;&amp;lt; Set Function(
	Function({thisBox},
		((((thisBox) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; Set Text(Char(thisBox &amp;lt;&amp;lt; Get))
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;Hopefully, I could get some help&lt;BR /&gt;&lt;BR /&gt;Appreciates&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 15:15:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-How-to-get-graph-builder-with-polygon-updated-as-slider/m-p/888184#M105048</guid>
      <dc:creator>PhamBao</dc:creator>
      <dc:date>2025-07-20T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: [Help] - How to get graph builder with polygon updated as slider changes</title>
      <link>https://community.jmp.com/t5/Discussions/Help-How-to-get-graph-builder-with-polygon-updated-as-slider/m-p/888211#M105051</link>
      <description>&lt;UL&gt;
&lt;LI&gt;the variables offset_x and _y need to be defined, possibly as arrays&lt;/LI&gt;
&lt;LI&gt;the sb&amp;lt;&amp;lt;setfunction at the end is probably overriding (and throwing away) the important bit "tb &amp;lt;&amp;lt; Set Table Variable( "scaleFactor", sliderValue )"&lt;/LI&gt;
&lt;LI&gt;Possibly something like this will make it more interactive once the offsets are defined&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sb &amp;lt;&amp;lt; Set Function(
	Function( {thisBox},
		((((thisBox) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; Set Text( Char( thisBox &amp;lt;&amp;lt; Get ) );
		tb &amp;lt;&amp;lt; Set Table Variable( "scaleFactor", sliderValue );
		tb &amp;lt;&amp;lt; rerunformulas;
		chartdisplay &amp;lt;&amp;lt; inval &amp;lt;&amp;lt; reshow;
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;edit: added&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;offset_x = j(19999,1,0);
offset_y = j(19999,1,0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;near the top and it does look interesting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6375878221112w960h540r153" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6375878221112" data-account="6058004218001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6058004218001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6375878221112w960h540r153');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.jmp.com/t5/video/gallerypage/video-id/6375878221112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 11:35:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-How-to-get-graph-builder-with-polygon-updated-as-slider/m-p/888211#M105051</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-07-20T11:35:03Z</dc:date>
    </item>
  </channel>
</rss>

