cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
neelsrejan
Level III

JSL alternating row legend for multiple variability charts in one window

Hi all, 

 

I'm stuck with a scenario. I have a variability graph that has 8 different graphs in one window by using the by clause twice. One case has two options and I want to add a row legend with for one column for one case and another for the other as one has the value colors set differently for one case. 

 

Below is the JSL code that I am attempting but is not working to even display the row legends. Any help would be appreciated.

dt = Open("$SAMPLE_DATA/Cars.jmp");
Column(dt, "Size" ) << Set Property( "Value Colors", {"It" = 0} );

vc = Variability Chart(
	Y( :Wt ),
	X( :Model ),
	Show Range Bars( 0 ),
	Show Cell Means( 0 ),
	Std Dev Chart( 0 ),
	By( :"D/P"n, :Protection )
);

If (Column(dt, "D/P"n)[1] == "Driver",
    vc << Row Legend("Doors");
);


If (Column(dt, "D/P"n)[1] == "Passenger",
    vc << Row Legend("Size");
);

neelsrejan_0-1694588517415.png

neelsrejan_1-1694588545416.png

The examples above would be the ideal case where if d/p="Driver" then doors is added as the row legend and uses regular colors. But if d/p="passenger" size is added as the row legend and since size has the value colors of It set as black it will automatically add it as it should be as shown from my previous question at: https://community.jmp.com/t5/Discussions/JSL-coloring-single-element-of-legend-to-a-custom-color/m-p...

 

Thanks and I am ideally looking for JSL code to do this if possible!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JSL alternating row legend for multiple variability charts in one window

Row Legend is set to Frame Box

jthi_0-1694589121856.png

 

So you have to set the row legend to different frameboxes. You can either loop over the frameboxes or use some other method of getting references to those (XPath). Below is example using loop

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Cars.jmp");
Column(dt, "Size") << Set Property("Value Colors",
	{"comp" = -15113984, "hev" = -5682409, "lt" = 0, "med" = -29362, "mini"
	 = -13983232, "mpv" = -13400487, "pu" = -16442434, "van" = -9282864}
);
wait(0);

vcs = dt << Variability Chart(
	Y(:Wt),
	X(:Model),
	Show Range Bars(0),
	Show Cell Means(0),
	Std Dev Chart(0),
	By(:"D/P"n, :Protection)
);

obs = vcs << report;
// ob_titles = obs << get title;

For Each({cur_ob, idx}, obs,
	//cur_ob = obs[1];
	cur_title = cur_ob << get title;
	If(Contains(cur_title, "Variability Gauge D/P=Driver"),
		cur_ob[FrameBox(1)] << Row Legend("Doors");
	, Contains(cur_title, "Variability Gauge D/P=Passenger"),
		cur_ob[FrameBox(1)] << Row Legend("Size", Color Theme(""));
	, // else (do nothing)
		continue();
	);
	// show(cur_title, idx);
);
-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: JSL alternating row legend for multiple variability charts in one window

Row Legend is set to Frame Box

jthi_0-1694589121856.png

 

So you have to set the row legend to different frameboxes. You can either loop over the frameboxes or use some other method of getting references to those (XPath). Below is example using loop

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Cars.jmp");
Column(dt, "Size") << Set Property("Value Colors",
	{"comp" = -15113984, "hev" = -5682409, "lt" = 0, "med" = -29362, "mini"
	 = -13983232, "mpv" = -13400487, "pu" = -16442434, "van" = -9282864}
);
wait(0);

vcs = dt << Variability Chart(
	Y(:Wt),
	X(:Model),
	Show Range Bars(0),
	Show Cell Means(0),
	Std Dev Chart(0),
	By(:"D/P"n, :Protection)
);

obs = vcs << report;
// ob_titles = obs << get title;

For Each({cur_ob, idx}, obs,
	//cur_ob = obs[1];
	cur_title = cur_ob << get title;
	If(Contains(cur_title, "Variability Gauge D/P=Driver"),
		cur_ob[FrameBox(1)] << Row Legend("Doors");
	, Contains(cur_title, "Variability Gauge D/P=Passenger"),
		cur_ob[FrameBox(1)] << Row Legend("Size", Color Theme(""));
	, // else (do nothing)
		continue();
	);
	// show(cur_title, idx);
);
-Jarmo