cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ankitgssingh
Level III

JSL loop to create multiple graphs with dynamic range slider boxes at once?

I have a code "sample.jsl" which has a loop to create a bi-var plot for each column. I am trying to add a range slider box to this loop so that once I run the script it creates one graph for all the columns with separate range slider box for each graph. 

 

The limits for all the x-axis columns are in "limits.jmp" and the datafile is "Data.jmp". The code "sample.jsl" creates one graph each for all the parameters at once. I want to modifly the code so that it also adds a range slider box to all the graphs. 

 

The range slider box should have the upper control limits (ucl) and lcl as the two dynamic sliders. 

 

I have this code which creates the range slider box but it just works for a single graph. I need a script which creates all the graphs together with the dynamic range slider boxes. 

 

Any help would be appreciated. Thanks in advance

 

 

myFinalDisplay = expr(
	
	myLimitCol = column(dt, "ColA");  //new
	myLimitMin = colMinimum(myLimitCol); show(myLimitMin); //new
	myLimitMax = colMaximum(myLimitCol); show(myLimitMax);  //new
	mylcl = globalLCL["ColA];  
	myucl = globalUCL["ColA]; 

	myGbDispObj = dt << Bivariate(
	Size( 550, 400 ),
	Y( "res" ),
	X( "ColA" ),
	Automatic Recalc( 1 ),
	Histogram Borders( 1 ),
	Summary Statistics( 1 ),
	Fit Spline( 2, {Line Color( {212, 73, 88} )} ),
	SendToReport(	
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Row Legend(
				"Grouping",
				Color( 1 ),
				Color Theme( "JMP Default" ),
				Marker( 1 ),
				Marker Theme( "Solid" ),
				Continuous Scale( 1 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		),
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Add Ref Line({mylcl, myucl}, "Solid", "Light YellowGreen", "", 1, 0.20 )}
		),			
		Dispatch( {}, "Summary Statistics", OutlineBox, {Close( 1 )} )
	)
);

	myTbLo = textBox(Char(round(myLimitMin, 2)) || " (OOC = " || char(0.00, 10, 2) || "%)");
	myTbHi = textBox(Char(round(myLimitMax, 2)) || " (OOC = " || char(0.00, 10, 2) || "%)");
	
	mySbDispObj = rangeSliderBox();
	mySbDispObj = rangeSliderBox(
		myLimitMin,
		myLimitMax,
		mylcl,
		myucl,
					
		//script

		mySelectedLower = mySbDispObj << getLower;
		mySelectedUpper = mySbDispObj << getUpper;
		
		myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedLower, "Dashed", "blue", "LCL", 4 )} );
		myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedUpper, "Dashed", "blue", "UCL", 4 )} );
		
		rUpper = dt << Get Rows Where( myLimitCol[] > mySelectedUpper );
		OOC_valUpper = (N Items(rUpper) / Col Number( Column(dt, "ColA") ))*100;
		myTbHi << setText(Char(round(mySelectedUpper, 1)) || " (OOC = " || char(OOC_valUpper, 10, 2) || "%)");

		rLower = dt << Get Rows Where( myLimitCol[] < mySelectedLower );
		OOC_valLower = (N Items(rLower) / Col Number( Column(dt,  "ColA") ))*100;
		myTbLo << setText(Char(round(mySelectedLower, 1)) || " (OOC = " || char(OOC_valLower, 10, 2) || "%)");
	);
	mySbDispObj << Set Width( 275 );
		
	myLayout = vListBox(
		myGbDispObj,
		hListBox(myTbLo, spacerBox(size(50,0)), myTbHi),
		mySbDispObj
	);
);

@pmroz 

@txnelson 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

Here's an example of it affecting some reference lines with a sliderbox for each list. It doesn't delete the previous reference line so you'd have to figure out how you want to do that if that's what you're going for.  

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age)); // just some list

nw = new window("Some box");
for(i=1, i<=nitems(ages), i++, 
	olb = outlinebox("Age = " || char(ages[i]), 
		hlistbox(
			rsb = rangesliderbox(colmin(:height), colmax(:height), colquantile(:height, .25), colquantile(:height, .75)), 
			gb = dt << Graph Builder(
				Show Control Panel( 0 ),
				Variables( X( :weight ), Y( :height ) ),
				where(char(:age) == ages[i])
			);
		)
	);
	(gb<<Parent)[Textbox(1)] << Delete(); // delete the where textbox()
	nw << append(olb);
	self = rsb;
	rsb << Set Function(
		Function({self}, 
			{DEFAULT LOCAL}, 
			gb_report = (self << Parent())[OutlineBox(1)]; // getting the graph builder report
			gb = gb_report << Get Scriptable Object(); // in case you want to send stuff to the actual platform
			axis = gb_report[axisbox(2)]; // get the axis
			upper = self << Get upper();
			lower = self << Get Lower();
			axis << Add Ref Line(lower, "Dashed", "blue", "LCL", 4);
			axis << Add Ref Line(upper, "Dashed", "blue", "UCL", 4);
		)
	)
);
Vince Faller - Predictum

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

...

Jim
ankitgssingh
Level III

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

I think the message you posted is not being displayed? 

ErraticAttack
Level VI

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

seems clear enough to me

Jordan
ih
Super User (Alumni) ih
Super User (Alumni)

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

You might try creating a window first with an empty list box where you want the graphs to go, and then append your graphs to that list box using a for loop.

ankitgssingh
Level III

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

The graphs are working fine and appending into the new window. But I am not able to add  a range slider box() object to each of the graphs created using the loop;. 

vince_faller
Super User (Alumni)

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

Here's an example of it affecting some reference lines with a sliderbox for each list. It doesn't delete the previous reference line so you'd have to figure out how you want to do that if that's what you're going for.  

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age)); // just some list

nw = new window("Some box");
for(i=1, i<=nitems(ages), i++, 
	olb = outlinebox("Age = " || char(ages[i]), 
		hlistbox(
			rsb = rangesliderbox(colmin(:height), colmax(:height), colquantile(:height, .25), colquantile(:height, .75)), 
			gb = dt << Graph Builder(
				Show Control Panel( 0 ),
				Variables( X( :weight ), Y( :height ) ),
				where(char(:age) == ages[i])
			);
		)
	);
	(gb<<Parent)[Textbox(1)] << Delete(); // delete the where textbox()
	nw << append(olb);
	self = rsb;
	rsb << Set Function(
		Function({self}, 
			{DEFAULT LOCAL}, 
			gb_report = (self << Parent())[OutlineBox(1)]; // getting the graph builder report
			gb = gb_report << Get Scriptable Object(); // in case you want to send stuff to the actual platform
			axis = gb_report[axisbox(2)]; // get the axis
			upper = self << Get upper();
			lower = self << Get Lower();
			axis << Add Ref Line(lower, "Dashed", "blue", "LCL", 4);
			axis << Add Ref Line(upper, "Dashed", "blue", "UCL", 4);
		)
	)
);
Vince Faller - Predictum
ErraticAttack
Level VI

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

OP, this can be relatively easily done, but I don't think many people will want to help you with this as you're asking too much and seem to be too inexperienced to really understand it all.

 

Some things to look into while you're filling out your experience level here is the following

  1. JSL doesn't really do much automatic scope control -- in particular, it doesn't remember scope states and hierarchies for functions and such -- if you're used to Python for example, then JSL will be quite frustrating and cause you great pains until you internalize this and start doing all of your own scope control
  2. For multiple interactive and mostly identical elements (like graphs with slider boxes, where only the graph X/Y / Grouping are changing), expressions will not serve you well.  Use instead a function generator or something as you will need to distinguish the slider boxes and which object they link to.  Of course this can be done with expressions, but in general it is the more complicated setup with only negligible speed gains in most circumstances
  3. Start small, with only one graph and one rangeSliderBox.  Learn how to link them using explicit scoping
  4. You will need a separate data table for each plot as a table can only have one row state per row
    1. With this, if you create multiple sub-tables for each plot, it would be best to make them invisible to prevent the user being flooded with data tables.  But keep in mind that data table are never implicitly deleted by JMP.  You need to tie the closing of the window to the cleanup of the script -- close all relevant data tables and delete any namespaces used for scoping.
  5. Many people on the community pages here are willing to help but questions should be small and succinct.
Jordan
ankitgssingh
Level III

Re: JSL loop to create multiple graphs with dynamic range slider boxes at once?

Thank you for explaining this. 

Yes I am experienced in python and new to jsl. Learning on the go.