<?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: Create multiple charts with different reference lines in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589051#M79397</link>
    <description>&lt;P&gt;How did you modify For Each? It should be changed to something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(idx = 1, idx &amp;lt;= N Items(groups), idx++,
	group = groups[idx];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Full script&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/example.jmp");

// get groups and limits
Summarize(dt, groups = By(:group), limits = Min(:limit));

nw = New Window("Trends", &amp;lt;&amp;lt; journal,
	tb = Tab Box()
);

//For Each({group, idx}, groups,
For(idx = 1, idx &amp;lt;= N Items(groups), idx++,
	group = groups[idx];
	biv_expr = EvalExpr(
		temp_biv = dt &amp;lt;&amp;lt; Bivariate(
			Y( :y_val ),
			X( :date ),
			Automatic Recalc( 1 ),
			Where(:group == Expr(group))
		);
		rbiv = temp_biv &amp;lt;&amp;lt; report;
		axisbox = rbiv[axis box(1)];
		axisbox &amp;lt;&amp;lt; Add Ref Line(
			limits[idx], "Solid", "Black", "", 1
		);
	);
	tb &amp;lt;&amp;lt; Add(group, V List Box(biv_expr));
);

tb &amp;lt;&amp;lt; Set Selected(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
    <pubDate>Wed, 11 Jan 2023 20:15:53 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-01-11T20:15:53Z</dc:date>
    <item>
      <title>Create multiple charts with different reference lines</title>
      <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589020#M79390</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to accomplish the following task using &lt;STRONG&gt;JSL code&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;I have an example file (attached) with 4 columns: date (numeric), y_val (numeric), limit (numeric), group (character).&lt;/P&gt;&lt;P&gt;The "group" column contains 3 distinct values: A,B,C&lt;/P&gt;&lt;P&gt;Each group has a unique value in "limit" column. For example, all group A rows have a value of 67 in the "limit" column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The task:&lt;/P&gt;&lt;P&gt;1. I would like to create 3 charts (one for each group), each of them in different tab.&lt;/P&gt;&lt;P&gt;2. The tabs names should be according to groups. So A,B,C.&lt;/P&gt;&lt;P&gt;3. Each chart (Y by X) should have "date" in X axis, "y_val" in Y axis, and value of "limit" as a reference line on the y axis (that matches the specific group).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached an example data table, as well as simple JSL script that gives the output I want.&lt;/P&gt;&lt;P&gt;However, the code has 3 drawbacks:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;I specified the reference line values manually, instead of reading them from "limit" column.&lt;/P&gt;&lt;P&gt;2. I named the tabs "A","B","C" manually, instead of reading them from "group" column.&lt;/P&gt;&lt;P&gt;3. I manually created 3 tabs, instead of automatically counting how many tabs I need (according to the number of distinct values in "group" column).&lt;/P&gt;&lt;P&gt;I would like the solution to address the drawbacks above, as it should generalize for any number of groups (for example A-Z, which means 26 groups and 26 different values for reference lines).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:43:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589020#M79390</guid>
      <dc:creator>YotamS1</dc:creator>
      <dc:date>2023-06-08T16:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple charts with different reference lines</title>
      <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589041#M79392</link>
      <description>&lt;P&gt;Below is one possible example script. If you don't have JMP16+ you will have to change For Each to For loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/example.jmp");

// get groups and limits
Summarize(dt, groups = By(:group), limits = Min(:limit));

nw = New Window("Trends", &amp;lt;&amp;lt; journal,
	tb = Tab Box()
);

For Each({group, idx}, groups,
	biv_expr = EvalExpr(
		temp_biv = dt &amp;lt;&amp;lt; Bivariate(
			Y( :y_val ),
			X( :date ),
			Automatic Recalc( 1 ),
			Where(:group == Expr(group))
		);
		rbiv = temp_biv &amp;lt;&amp;lt; report;
		axisbox = rbiv[axis box(1)];
		axisbox &amp;lt;&amp;lt; Add Ref Line(
			limits[idx], "Solid", "Black", "", 1
		);
	);
	tb &amp;lt;&amp;lt; Add(group, V List Box(biv_expr));
);

tb &amp;lt;&amp;lt; Set Selected(1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2023 19:44:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589041#M79392</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-11T19:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple charts with different reference lines</title>
      <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589049#M79395</link>
      <description>&lt;P&gt;Thank you for the quick response!&lt;/P&gt;&lt;P&gt;I have JMP 14.&lt;/P&gt;&lt;P&gt;I copied your script and changed the "For Each" to "For", but got an empty window after running (no error messages).&lt;/P&gt;&lt;P&gt;Maybe there's something else that needs to be changed?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 20:00:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589049#M79395</guid>
      <dc:creator>YotamS1</dc:creator>
      <dc:date>2023-01-11T20:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple charts with different reference lines</title>
      <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589051#M79397</link>
      <description>&lt;P&gt;How did you modify For Each? It should be changed to something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(idx = 1, idx &amp;lt;= N Items(groups), idx++,
	group = groups[idx];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Full script&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/example.jmp");

// get groups and limits
Summarize(dt, groups = By(:group), limits = Min(:limit));

nw = New Window("Trends", &amp;lt;&amp;lt; journal,
	tb = Tab Box()
);

//For Each({group, idx}, groups,
For(idx = 1, idx &amp;lt;= N Items(groups), idx++,
	group = groups[idx];
	biv_expr = EvalExpr(
		temp_biv = dt &amp;lt;&amp;lt; Bivariate(
			Y( :y_val ),
			X( :date ),
			Automatic Recalc( 1 ),
			Where(:group == Expr(group))
		);
		rbiv = temp_biv &amp;lt;&amp;lt; report;
		axisbox = rbiv[axis box(1)];
		axisbox &amp;lt;&amp;lt; Add Ref Line(
			limits[idx], "Solid", "Black", "", 1
		);
	);
	tb &amp;lt;&amp;lt; Add(group, V List Box(biv_expr));
);

tb &amp;lt;&amp;lt; Set Selected(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 11 Jan 2023 20:15:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589051#M79397</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-11T20:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple charts with different reference lines</title>
      <link>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589053#M79398</link>
      <description>&lt;P&gt;Great, now it works!&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 20:22:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-multiple-charts-with-different-reference-lines/m-p/589053#M79398</guid>
      <dc:creator>YotamS1</dc:creator>
      <dc:date>2023-01-11T20:22:16Z</dc:date>
    </item>
  </channel>
</rss>

