<?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 Dynamically Add Element Statements for a Graph using JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907308#M106566</link>
    <description>&lt;P&gt;Hey guys I'm pretty new to JMP and JSL, but am pretty familiar with coding.&amp;nbsp; I'm trying to create a JSL script that will take a list of parameters names (that I define in the "PlotVars" array) and then plot them all in separate plots on the same graph.&amp;nbsp; I want this script to work regardless of how many parameters are defined in this array (in case I want to add or subtract parameters for each use).&amp;nbsp; I can get my script to produce this (using the code below), but all of the plots default to using points, and I would like them to use a line instead.&amp;nbsp; My understanding of how to do this is to use multiple element statements for each position.&amp;nbsp; I believe the problem lies with my second line where I initialize the "var_line" variable.&amp;nbsp; If I initialize it as Expr() then it will produce the element statements but won't run them properly.&amp;nbsp; Same thing if I initialize them as Parse().&amp;nbsp; Open to any ideas to solve this though.&amp;nbsp; I'm using JMP 18.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit (jthi): Added jsl formatting&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;var_expr = Expr(
	Variables(X(As Column("Start Alignment of " || DataSet_1)))
);
var_line = Expr();//Unable to dymanically add elements to the graph.  still unsure why
 
For(i = 1, i &amp;lt;= N Items(PlotVars), i++,
	Insert Into(var_expr, Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_1), )));
	Insert Into(
		var_expr,
		Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_2), Position(Expr(i)), ))
	);
	Insert Into(
		var_line,
		Eval Expr(Elements(Position(1, Expr(i)), Line(X, Y(1), Y(2)), Legend(4)))
	);
);
 
plot = Substitute(
		Expr(
			Data Table("Comparison of" || DataSet_1 || "with" || DataSet_2) &amp;lt;&amp;lt;
			Graph Builder(Size(809, 629), Show Control Panel(0), vvv, yyy)
		),
	Expr(vvv), Name Expr(var_expr),
	Expr(yyy), Name Expr(test)
);
 
Eval(plot);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/P&gt;
&lt;DIV&gt;var_expr = Expr(Variables(X( as column("Start Alignment of " || DataSet_1) )));&lt;/DIV&gt;
&lt;DIV&gt;var_line = Expr();//Unable to dymanically add elements to the graph.&amp;nbsp; still unsure why&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;for(i=1, i&amp;lt;=N Items(PlotVars),i++,&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_expr, Eval Expr(Y( as column(PlotVars[expr(i)] || " of " || DataSet_1),)));&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_expr, Eval Expr(Y( as column(PlotVars[expr(i)] || " of " || DataSet_2), Position(expr(i)),)));&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_line, Eval Expr(Elements(Position(1,expr(i)),Line(X,Y(1),Y(2)),Legend(4))));&lt;/DIV&gt;
&lt;DIV&gt;);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;plot = Substitute(&lt;/DIV&gt;
&lt;DIV&gt;Expr(&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Data Table( "Comparison of" || DataSet_1 || "with" ||DataSet_2 ) &amp;lt;&amp;lt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Graph Builder(&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Size( 809, 629 ),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Show Control Panel( 0 ),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; vvv,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; yyy&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; )),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;Expr(vvv), Name Expr(var_expr),&lt;/DIV&gt;
&lt;DIV&gt;Expr(yyy), Name Expr(test)&lt;/DIV&gt;
&lt;DIV&gt;);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Eval(plot);&lt;/DIV&gt;
&lt;P&gt;&amp;gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Oct 2025 16:59:06 GMT</pubDate>
    <dc:creator>JmpAround182</dc:creator>
    <dc:date>2025-10-13T16:59:06Z</dc:date>
    <item>
      <title>How to Dynamically Add Element Statements for a Graph using JSL</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907308#M106566</link>
      <description>&lt;P&gt;Hey guys I'm pretty new to JMP and JSL, but am pretty familiar with coding.&amp;nbsp; I'm trying to create a JSL script that will take a list of parameters names (that I define in the "PlotVars" array) and then plot them all in separate plots on the same graph.&amp;nbsp; I want this script to work regardless of how many parameters are defined in this array (in case I want to add or subtract parameters for each use).&amp;nbsp; I can get my script to produce this (using the code below), but all of the plots default to using points, and I would like them to use a line instead.&amp;nbsp; My understanding of how to do this is to use multiple element statements for each position.&amp;nbsp; I believe the problem lies with my second line where I initialize the "var_line" variable.&amp;nbsp; If I initialize it as Expr() then it will produce the element statements but won't run them properly.&amp;nbsp; Same thing if I initialize them as Parse().&amp;nbsp; Open to any ideas to solve this though.&amp;nbsp; I'm using JMP 18.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit (jthi): Added jsl formatting&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;var_expr = Expr(
	Variables(X(As Column("Start Alignment of " || DataSet_1)))
);
var_line = Expr();//Unable to dymanically add elements to the graph.  still unsure why
 
For(i = 1, i &amp;lt;= N Items(PlotVars), i++,
	Insert Into(var_expr, Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_1), )));
	Insert Into(
		var_expr,
		Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_2), Position(Expr(i)), ))
	);
	Insert Into(
		var_line,
		Eval Expr(Elements(Position(1, Expr(i)), Line(X, Y(1), Y(2)), Legend(4)))
	);
);
 
plot = Substitute(
		Expr(
			Data Table("Comparison of" || DataSet_1 || "with" || DataSet_2) &amp;lt;&amp;lt;
			Graph Builder(Size(809, 629), Show Control Panel(0), vvv, yyy)
		),
	Expr(vvv), Name Expr(var_expr),
	Expr(yyy), Name Expr(test)
);
 
Eval(plot);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/P&gt;
&lt;DIV&gt;var_expr = Expr(Variables(X( as column("Start Alignment of " || DataSet_1) )));&lt;/DIV&gt;
&lt;DIV&gt;var_line = Expr();//Unable to dymanically add elements to the graph.&amp;nbsp; still unsure why&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;for(i=1, i&amp;lt;=N Items(PlotVars),i++,&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_expr, Eval Expr(Y( as column(PlotVars[expr(i)] || " of " || DataSet_1),)));&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_expr, Eval Expr(Y( as column(PlotVars[expr(i)] || " of " || DataSet_2), Position(expr(i)),)));&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Insert Into(var_line, Eval Expr(Elements(Position(1,expr(i)),Line(X,Y(1),Y(2)),Legend(4))));&lt;/DIV&gt;
&lt;DIV&gt;);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;plot = Substitute(&lt;/DIV&gt;
&lt;DIV&gt;Expr(&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Data Table( "Comparison of" || DataSet_1 || "with" ||DataSet_2 ) &amp;lt;&amp;lt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Graph Builder(&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Size( 809, 629 ),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Show Control Panel( 0 ),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; vvv,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; yyy&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; )),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;Expr(vvv), Name Expr(var_expr),&lt;/DIV&gt;
&lt;DIV&gt;Expr(yyy), Name Expr(test)&lt;/DIV&gt;
&lt;DIV&gt;);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Eval(plot);&lt;/DIV&gt;
&lt;P&gt;&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 16:59:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907308#M106566</guid>
      <dc:creator>JmpAround182</dc:creator>
      <dc:date>2025-10-13T16:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Add Element Statements for a Graph using JSL</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907320#M106567</link>
      <description>&lt;P&gt;What do you wish your graph to look like? How does the script look like when JMP creates it? How does it compare to your script which you create with JSL?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table("Comparison of" || DataSet_1 || "with" || DataSet_2) &amp;lt;&amp;lt;
Graph Builder(
	Size(809, 629),
	Show Control Panel(0),
	Variables(
		X(As Column("Start Alignment of " || DataSet_1)),
		Y(As Column(PlotVars[1] || " of " || DataSet_1)),
		Y(As Column(PlotVars[1] || " of " || DataSet_2), Position(1)),
		Y(As Column(PlotVars[2] || " of " || DataSet_1)),
		Y(As Column(PlotVars[2] || " of " || DataSet_2), Position(2))
	),
	test
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There is also quite a lot of material related to this, dynamically building graph builder. Here are few&amp;nbsp;&lt;LI-MESSAGE title="Scripters Club Recording: JSL in Graph Builder" uid="800152" url="https://community.jmp.com/t5/JMP-Scripters-Club-Discussions/Scripters-Club-Recording-JSL-in-Graph-Builder/m-p/800152#U800152" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;,&amp;nbsp;&lt;LI-MESSAGE title="Reply All: How to script dynamic content for Graph Builder" uid="21092" url="https://community.jmp.com/t5/The-Plot-Thickens/Reply-All-How-to-script-dynamic-content-for-Graph-Builder/m-p/21092#U21092" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 17:07:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907320#M106567</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-13T17:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Add Element Statements for a Graph using JSL</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907323#M106568</link>
      <description>&lt;P&gt;The script creates the graph's exactly as I want them, except it creates them using points/smoother in the element statements (note that variables are removed to shorten the script length).&amp;nbsp; This is the graph code from the script output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 809, 629 ),
	Show Control Panel( 0 ),
	Variables(
		...
		)
	),
	Elements(
		Position( 1, 1 ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 1 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 2 ) )
	),
	Elements(
		Position( 1, 2 ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 3 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 4 ) )
	),
	Elements(
		Position( 1, 3 ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) )
	),
	Elements(
		Position( 1, 4 ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 7 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 8 ) )
	),
	Elements(
		Position( 1, 5 ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 9 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 10 ) )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And I would prefer it to use Lines instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 696, 590 ),
	Show Control Panel( 0 ),
	Variables(
		...
		)
	),
	Elements( Position( 1, 1 ), Line( X, Y( 1 ), Y( 2 ), Legend( 11 ) ) ),
	Elements( Position( 1, 2 ), Line( X, Y( 1 ), Y( 2 ), Legend( 12 ) ) ),
	Elements( Position( 1, 3 ), Line( X, Y( 1 ), Y( 2 ), Legend( 13 ) ) ),
	Elements( Position( 1, 4 ), Line( X, Y( 1 ), Y( 2 ), Legend( 14 ) ) ),
	Elements( Position( 1, 5 ), Line( X, Y( 1 ), Y( 2 ), Legend( 15 ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Whenever try to "Insert Into" the elements statement it just adds a nested elements statement instead of separate elements statements.&amp;nbsp; And the graph builder seems to just ignore those nested elements statements.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 17:56:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907323#M106568</guid>
      <dc:creator>JmpAround182</dc:creator>
      <dc:date>2025-10-13T17:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Add Element Statements for a Graph using JSL</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907324#M106569</link>
      <description>&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
plotvars = {"NPN1", "NPN2", "NPN3", "NPN4", "PNP1"};
xcol = "wafer";

gb_expr = Expr(Graph Builder(Size(809, 629), Show Control Panel(0)));
var_expr = EvalExpr(Variables(X(Expr(NameExpr(As Column(dt, xcol))))));
For Each({colname, idx}, plotvars,
	Insert Into(var_expr, Eval Expr(Y(Expr(NameExpr(As Column(dt, colname))))));
);
Insert Into(gb_expr, Name Expr(var_expr));

For(idx = 1, idx &amp;lt;= N Items(plotvars), idx++,
	elem_expr = Substitute(
		Expr(Elements(Position(1, _pos_), Line(X, Y, Legend(_lgnd_)))),
		Expr(_pos_), idx, 
		Expr(_lgnd_), idx
	);
	Insert Into(gb_expr, Name Expr(elem_expr));
);
// Show(gb_expr);

gb = Eval(EvalExpr((Send(dt, Expr(gb_expr)))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb_expr = Graph Builder(
	Size(809, 629),
	Show Control Panel(0),
	Variables(X(:wafer), Y(:NPN1), Y(:NPN2), Y(:NPN3), Y(:NPN4), Y(:PNP1)),
	Elements(Position(1, 1), Line(X, Y, Legend(1))),
	Elements(Position(1, 2), Line(X, Y, Legend(2))),
	Elements(Position(1, 3), Line(X, Y, Legend(3))),
	Elements(Position(1, 4), Line(X, Y, Legend(4))),
	Elements(Position(1, 5), Line(X, Y, Legend(5)))
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Oct 2025 18:45:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907324#M106569</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-13T18:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Add Element Statements for a Graph using JSL</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907328#M106571</link>
      <description>&lt;P&gt;Awesome this idea worked.&amp;nbsp; I needed to just insert the Elements command at the graph builder level, not try to build the elements commands into an expression on its own.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 19:54:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-Add-Element-Statements-for-a-Graph-using-JSL/m-p/907328#M106571</guid>
      <dc:creator>JmpAround182</dc:creator>
      <dc:date>2025-10-13T19:54:01Z</dc:date>
    </item>
  </channel>
</rss>

