<?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: JSL - dynamic chart legend change in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/255725#M50229</link>
    <description>&lt;P&gt;I think i found a way to run this on variability chart.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What need to add if i want multiple(using by:***) variability chart with dynamic legend?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Begin Script;
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
variables = {"age", "sex"};
// Initial nlevels is the number of levels of 'age', as it is the first by-group used.
fitVar = "age";
nlevels = 6;

// Creating the legend. For each selection, the previous spline fits are removed, then
// new ones are generated.
BC_legend = Panel Box( "Choose Legend",
	legend = Radio Box(
		{"age", "sex"},
		fitVar = legend &amp;lt;&amp;lt; Get Selected;

		Match( fitVar, 

			"age",
				(Summarize( vals = By( :age ), c = count ) ; Report( obj )[Border Box( 2 )] &amp;lt;&amp;lt; Delete ;
				Report( obj )[FrameBox( 1 )] &amp;lt;&amp;lt; Row Legend( "age", color( 1 ), Marker( 1 ) ) ; 
// obj &amp;lt;&amp;lt; Group By( :sex );
				nlevels = N Items( vals ) ; ; 

				), 

			"sex",
				(Summarize( vals = By( :sex ), c = count ) ; Report( obj )[Border Box( 2 )] &amp;lt;&amp;lt; Delete ;
				Report( obj )[FrameBox( 1 )] &amp;lt;&amp;lt; Row Legend( "sex", color( 1 ), Marker( 1 ) ) ; 
// obj &amp;lt;&amp;lt; Group By( :sex );
				nlevels = N Items( vals ) ; )
		);
	)
);

// Fitting the initial Bivariate fit with 'age' as the by-group, adding the legend
// to control the selections.
nw = New Window( "BigClassBivariate",
	H List Box(

		obj = dt &amp;lt;&amp;lt; 

		Variability Chart(
			Y( :weight ),
			X( :height ),
			Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
			Connect Cell Means( 1 ),
			Std Dev Chart( 0 ),
			Points Jittered( 1 ),
			SendToReport(
				Dispatch(
					{},
					"Variability Chart",
					FrameBox,
					{Marker Size( 8 ), Marker Drawing Mode( "Normal" ) ;
					Row Legend(
						dt:(fitVar),
						Color( 1 ),
						Color Theme( "JMP Default" ),
						Marker( 0 ),
						Marker Theme( "Classic" ),
						Continuous Scale( Cont ),
						Reverse Scale( 0 ),
						Excluded Rows( 0 )
					)}
				)
			)
		), 

		BC_legend
	)
);

//End Script;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Apr 2020 18:39:02 GMT</pubDate>
    <dc:creator>Ilan</dc:creator>
    <dc:date>2020-04-02T18:39:02Z</dc:date>
    <item>
      <title>JSL - dynamic chart legend change</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/213845#M42758</link>
      <description>&lt;P&gt;Hello friends,&lt;/P&gt;&lt;P&gt;I'm using code below to change legend &amp;amp; splines in bivirate chart per radio box user selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The splines part works fine but the legend won't change :(&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bivirate.bmp" style="width: 764px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/17825i9EB635CF34BF4111/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bivirate.bmp" alt="Bivirate.bmp" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Begin Script;
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
variables = {"age", "sex"};
// Initial nlevels is the number of levels of 'age', as it is the first by-group used.
nlevels=6;  
 
// Creating the legend. For each selection, the previous spline fits are removed, then
// new ones are generated.
BC_legend = Panel Box( "Choose Legend", 
     legend = Radio Box(
           {"age", "sex"},
       fitVar = legend &amp;lt;&amp;lt; Get Selected;

       Match( fitVar,

           "age",
			(Summarize(vals = By( :age ), c=count );
			For(ii = 1, ii &amp;lt;=nlevels, ii++,
			obj &amp;lt;&amp;lt; (Curve[1] &amp;lt;&amp;lt; Remove Fit );
				);
			obj &amp;lt;&amp;lt; Group By( :age ) &amp;lt;&amp;lt; Fit Spline( 0.1, standardized );
			nlevels = nItems(vals); 
				
			),

           "sex",
			(Summarize(vals = By( :sex ), c=count );
			For(ii = 1, ii &amp;lt;=nlevels, ii++,
			obj &amp;lt;&amp;lt; (Curve[1] &amp;lt;&amp;lt; Remove Fit );
				);
			obj &amp;lt;&amp;lt; Group By( :sex ) &amp;lt;&amp;lt; Fit Spline( 0.1, standardized );
			nlevels = nItems(vals); )
           );
           
           ));
           
// Fitting the initial Bivariate fit with 'age' as the by-group, adding the legend
// to control the selections.           
nw = New Window( "BigClassBivariate", 
	HListBox( 
           
	obj = dt &amp;lt;&amp;lt; Bivariate(
		Y( :weight ),
		X( :height ),
		Group By( :age ),
		Fit Spline( 0.1, standardized ),
		SendToReport(
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Frame Size( 493, 354 ),Marker Size( 2 ), Marker Drawing Mode( "Normal" ), Row Legend(
                                                            dt:(fitVar),
                                                            Color( 1 ),
                                                            Color Theme( "JMP Default" ),
                                                            Marker( 0 ),
                                                            Marker Theme( "Standard" ),
                                                            Continuous Scale( Cont ),
                                                            Reverse Scale( 0 ),
                                                            Excluded Rows( 0 )
                                                     )}

		)
	)
		);   ,
           
    
    BC_legend
    ));      
    
//End Script;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 08:38:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/213845#M42758</guid>
      <dc:creator>RB</dc:creator>
      <dc:date>2019-06-20T08:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - dynamic chart legend change</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/214500#M42900</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15101"&gt;@RB&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The legend must be removed and added by your script. Also, I think it is safer to remove items from last to first.&lt;/P&gt;
&lt;P&gt;Attached are 2 scripts:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;DynamicChartLegend_Working.jsl which is makes a few changes to your script.&lt;/LI&gt;
&lt;LI&gt;DynamicChartLegend_Generic.jsl makes more changes so that you do not have to use "cookie cutter" code for each of your variables. This is done by using reference variables and by creating and using the function GetLevels().&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You did not mention which version of JMP that you are currently using. If these scripts do not work, please provide information about version of JMP.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 10:44:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/214500#M42900</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-06-25T10:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - dynamic chart legend change</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/255709#M50224</link>
      <description>&lt;P&gt;Hi Great Script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i use this script on simple variability chart?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best R&lt;/P&gt;&lt;P&gt;Ilan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 16:44:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/255709#M50224</guid>
      <dc:creator>Ilan</dc:creator>
      <dc:date>2020-04-02T16:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - dynamic chart legend change</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/255725#M50229</link>
      <description>&lt;P&gt;I think i found a way to run this on variability chart.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What need to add if i want multiple(using by:***) variability chart with dynamic legend?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Begin Script;
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
variables = {"age", "sex"};
// Initial nlevels is the number of levels of 'age', as it is the first by-group used.
fitVar = "age";
nlevels = 6;

// Creating the legend. For each selection, the previous spline fits are removed, then
// new ones are generated.
BC_legend = Panel Box( "Choose Legend",
	legend = Radio Box(
		{"age", "sex"},
		fitVar = legend &amp;lt;&amp;lt; Get Selected;

		Match( fitVar, 

			"age",
				(Summarize( vals = By( :age ), c = count ) ; Report( obj )[Border Box( 2 )] &amp;lt;&amp;lt; Delete ;
				Report( obj )[FrameBox( 1 )] &amp;lt;&amp;lt; Row Legend( "age", color( 1 ), Marker( 1 ) ) ; 
// obj &amp;lt;&amp;lt; Group By( :sex );
				nlevels = N Items( vals ) ; ; 

				), 

			"sex",
				(Summarize( vals = By( :sex ), c = count ) ; Report( obj )[Border Box( 2 )] &amp;lt;&amp;lt; Delete ;
				Report( obj )[FrameBox( 1 )] &amp;lt;&amp;lt; Row Legend( "sex", color( 1 ), Marker( 1 ) ) ; 
// obj &amp;lt;&amp;lt; Group By( :sex );
				nlevels = N Items( vals ) ; )
		);
	)
);

// Fitting the initial Bivariate fit with 'age' as the by-group, adding the legend
// to control the selections.
nw = New Window( "BigClassBivariate",
	H List Box(

		obj = dt &amp;lt;&amp;lt; 

		Variability Chart(
			Y( :weight ),
			X( :height ),
			Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
			Connect Cell Means( 1 ),
			Std Dev Chart( 0 ),
			Points Jittered( 1 ),
			SendToReport(
				Dispatch(
					{},
					"Variability Chart",
					FrameBox,
					{Marker Size( 8 ), Marker Drawing Mode( "Normal" ) ;
					Row Legend(
						dt:(fitVar),
						Color( 1 ),
						Color Theme( "JMP Default" ),
						Marker( 0 ),
						Marker Theme( "Classic" ),
						Continuous Scale( Cont ),
						Reverse Scale( 0 ),
						Excluded Rows( 0 )
					)}
				)
			)
		), 

		BC_legend
	)
);

//End Script;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 18:39:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-dynamic-chart-legend-change/m-p/255725#M50229</guid>
      <dc:creator>Ilan</dc:creator>
      <dc:date>2020-04-02T18:39:02Z</dc:date>
    </item>
  </channel>
</rss>

