<?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: Using JSL to add reference lines to Page By graphs in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-JSL-to-add-reference-lines-to-Page-By-graphs/m-p/321427#M57147</link>
    <description>&lt;P&gt;Graph Builder is using a hybrid sort.&amp;nbsp; Here is a little script that will do that for your list values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;refList = {"B100", "A50", "B50"};
For( i = 1, i &amp;lt;= N Items( refList ), i++,
	If( Length( refList[i] ) &amp;lt; 4,
		refList[i] = Substr( refList[i], 1, 1 ) ||
		Substr( "00", Length( refList[i] ) - 1 ) ||
		Substr( refList[i], 2 )
	);

);
refList = Sort List( refList );

For( i = 1, i &amp;lt;= N Items( refList ), i++,
	While( Length( Word( 1, refList[i], "0" ) ) == 1,
		refList[i] = Substr( refList[i], 1, 1 ) ||
		Substr( refList[i], 3 )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also suggest that you take a look at using a simpler method in setting your reference lines.&amp;nbsp; If you go directly to the AxisBox that you want the reference line added to, it is done with simpler code.&amp;nbsp; Below is an example.&amp;nbsp; Also, the Scripting Guide has a complete section on working with Display Trees, and the Scripting Index has definitions and examples for all of the functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

refList = {60,65};

gb =  dt &amp;lt;&amp;lt; Graph Builder(
	Size( 528, 956 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Page( :sex ) ),
	Elements( Points( X, Y, Legend( 8 ) ), Smoother( X, Y, Legend( 9 ) ) )
);
Summarize( dt, groups = by( :Sex ) );
For( i = 1, i &amp;lt;= N Items( groups ), i++,
	Report( gb )[axisbox( i * 2 )] &amp;lt;&amp;lt; Add Ref Line(
		refList[i],
		"Solid",
		"Black",
		"",
		1
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Oct 2020 22:30:30 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-10-13T22:30:30Z</dc:date>
    <item>
      <title>Using JSL to add reference lines to Page By graphs</title>
      <link>https://community.jmp.com/t5/Discussions/Using-JSL-to-add-reference-lines-to-Page-By-graphs/m-p/321396#M57144</link>
      <description>&lt;P&gt;I have a script where I use Page By to create a set of graphs. I want to add different reference lines to each graph, pulled from a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently the only way I know how to specify which graphs to add the reference lines to is by referring to the graph by its integer index (which seems to start at 2) using ScaleBox. (Please let me know if there's a better way than using the integer index.) E.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i= 1, i&amp;lt;= n, i+=1,
	RefLineValue= RefLineList[i];
	mygraph &amp;lt;&amp;lt; SendToReport(
		Dispatch(
			{},
			"Data",
			ScaleBox( i+1 ),
			{Add Ref Line( RefLineValue, "Solid", "Black", "", 1 )}
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This almost works, but my issue is that I don't know how to get the integer index specified properly for the ScaleBox function. The Page By function seems to put the graphs into &lt;EM&gt;some kind&lt;/EM&gt; of alphabetical order, so I thought if I use Sort List( RefLineList ) then the ordering of the list would match the ordering of the graphs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But ordering doesn't quite match: E.g. if the variables in the Page By role are [A50, B50, B100] then the graphs will be ordered [A50, B50, &lt;STRONG&gt;B100&lt;/STRONG&gt;] but the list created using Sort List will be ordered [A50, &lt;STRONG&gt;B100&lt;/STRONG&gt;, B50].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to specify the Page By graph by name instead of by integer index? And if not, is there a way to sort my list so the list order matches the graph order?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:40:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-JSL-to-add-reference-lines-to-Page-By-graphs/m-p/321396#M57144</guid>
      <dc:creator>markschwab</dc:creator>
      <dc:date>2023-06-09T23:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using JSL to add reference lines to Page By graphs</title>
      <link>https://community.jmp.com/t5/Discussions/Using-JSL-to-add-reference-lines-to-Page-By-graphs/m-p/321427#M57147</link>
      <description>&lt;P&gt;Graph Builder is using a hybrid sort.&amp;nbsp; Here is a little script that will do that for your list values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;refList = {"B100", "A50", "B50"};
For( i = 1, i &amp;lt;= N Items( refList ), i++,
	If( Length( refList[i] ) &amp;lt; 4,
		refList[i] = Substr( refList[i], 1, 1 ) ||
		Substr( "00", Length( refList[i] ) - 1 ) ||
		Substr( refList[i], 2 )
	);

);
refList = Sort List( refList );

For( i = 1, i &amp;lt;= N Items( refList ), i++,
	While( Length( Word( 1, refList[i], "0" ) ) == 1,
		refList[i] = Substr( refList[i], 1, 1 ) ||
		Substr( refList[i], 3 )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also suggest that you take a look at using a simpler method in setting your reference lines.&amp;nbsp; If you go directly to the AxisBox that you want the reference line added to, it is done with simpler code.&amp;nbsp; Below is an example.&amp;nbsp; Also, the Scripting Guide has a complete section on working with Display Trees, and the Scripting Index has definitions and examples for all of the functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

refList = {60,65};

gb =  dt &amp;lt;&amp;lt; Graph Builder(
	Size( 528, 956 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Page( :sex ) ),
	Elements( Points( X, Y, Legend( 8 ) ), Smoother( X, Y, Legend( 9 ) ) )
);
Summarize( dt, groups = by( :Sex ) );
For( i = 1, i &amp;lt;= N Items( groups ), i++,
	Report( gb )[axisbox( i * 2 )] &amp;lt;&amp;lt; Add Ref Line(
		refList[i],
		"Solid",
		"Black",
		"",
		1
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Oct 2020 22:30:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-JSL-to-add-reference-lines-to-Page-By-graphs/m-p/321427#M57147</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-13T22:30:30Z</dc:date>
    </item>
  </channel>
</rss>

