cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
ku8809no
Level I

Shared Column Switcher for multiple graphs

Is there any way to have one shared column switcher for multiple graphs?

 

For example, I would like to have 1 column switcher to view two different variability charts...


Thank you for your help in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Shared Column Switcher for multiple graphs

Here is a script that works on JMP 13

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
nw = New Window( "test",
	ob = Outline Box( "Var Charts",
		MyHLB = H List Box(
			vc = Variability Chart( Y( :BP 8M ), X( :Subject ), Std Dev Chart( 0 ) ),
			vc2 = Variability Chart( Y( :BP 8M ), X( :Subject ), Std Dev Chart( 0 ) )
	
		)
	)
);
cs = vc << Column Switcher( :BP 8M, {:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F} );

nw["Var Charts"][listboxbox(1)] << set script(
	VarList = {:BP 8M,:BP 12M,:BP 6M,:BP 8W,:BP 12W,:BP 6W,:BP 8F,:BP 12F,:BP 6F};
	CurVar = word(2,char(vc2<<get script),":)");
	Eval( 
		Substitute( 
			Expr( cs2 = vc2 << Column Switcher( __CurVar__, varlist ) 
			), 
			Expr( __CurVar__ ), Parse( ":" || CurVar ) 		
		) 	
	);
	SwitchVar = Char((nw["Var Charts"][listboxbox(1)] << get selected)[1]);
	For(i=1,i<=N items(VarList),i++,
		If(SwitchVar==Char(VarList[i]),
			Break()
		)
	);
	nw["Var Charts"][listboxbox(2)]<<set selected(i);
	cs2 << remove column switcher;
);

I tested it on JMP 11.1, and it works only for the first selection, then the link to the second Variability Chart gets lost.  I assume this is a JMP bug that was fixed in JMP 12 or 13.  However, all is not lost.  What you can do, is to change my code to not generate a second Column Switcher and then use it to change the second chart, but instead, to delete the VC2 object completly, and then rebuild the chart and to append it to the MyHLB object.

Jim

View solution in original post

11 REPLIES 11
txnelson
Super User

Re: Shared Column Switcher for multiple graphs

The answer is, probably. There is typically a trigger that can be used to determine that something has changed within the first platform, based upon the column switcher, and from that, JSL can be then used to change the columns in the other platforms. If you can provide what JMP platforms you are looking to be using, then the potential triggers can be looked into.
Jim
ku8809no
Level I

Re: Shared Column Switcher for multiple graphs

Thanks Jim..
I am not 100% clear what you mean by "platforms". I am using JSL scripts to plot two variability charts. I was able to add two column switcher to both variability charts (1 each), but I would like to have just one that controls both charts.

V List Box(
dt = Variability Chart(Set Title("Variability Chart 1"),Y(:colA),X(:colB)), dt = Variability Chart(Set Title("Variability Chart 2"),Y(:colA),X(:colB)))
ku8809no
Level I

Re: Shared Column Switcher for multiple graphs

also, i am using JMP 11.1 on Window
txnelson
Super User

Re: Shared Column Switcher for multiple graphs

Here is a script that works on JMP 13

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
nw = New Window( "test",
	ob = Outline Box( "Var Charts",
		MyHLB = H List Box(
			vc = Variability Chart( Y( :BP 8M ), X( :Subject ), Std Dev Chart( 0 ) ),
			vc2 = Variability Chart( Y( :BP 8M ), X( :Subject ), Std Dev Chart( 0 ) )
	
		)
	)
);
cs = vc << Column Switcher( :BP 8M, {:BP 8M, :BP 12M, :BP 6M, :BP 8W, :BP 12W, :BP 6W, :BP 8F, :BP 12F, :BP 6F} );

nw["Var Charts"][listboxbox(1)] << set script(
	VarList = {:BP 8M,:BP 12M,:BP 6M,:BP 8W,:BP 12W,:BP 6W,:BP 8F,:BP 12F,:BP 6F};
	CurVar = word(2,char(vc2<<get script),":)");
	Eval( 
		Substitute( 
			Expr( cs2 = vc2 << Column Switcher( __CurVar__, varlist ) 
			), 
			Expr( __CurVar__ ), Parse( ":" || CurVar ) 		
		) 	
	);
	SwitchVar = Char((nw["Var Charts"][listboxbox(1)] << get selected)[1]);
	For(i=1,i<=N items(VarList),i++,
		If(SwitchVar==Char(VarList[i]),
			Break()
		)
	);
	nw["Var Charts"][listboxbox(2)]<<set selected(i);
	cs2 << remove column switcher;
);

I tested it on JMP 11.1, and it works only for the first selection, then the link to the second Variability Chart gets lost.  I assume this is a JMP bug that was fixed in JMP 12 or 13.  However, all is not lost.  What you can do, is to change my code to not generate a second Column Switcher and then use it to change the second chart, but instead, to delete the VC2 object completly, and then rebuild the chart and to append it to the MyHLB object.

Jim
ku8809no
Level I

Re: Shared Column Switcher for multiple graphs

Jim, Thank you so much. Let me work on this and i will let you know how your suggested workaround turns out!

ku8809no
Level I

Re: Shared Column Switcher for multiple graphs

Jim,

Thanks to your huge help, I was able to resolve the issue.
Rather than using your suggested workaround, I resolved the issue by addressing the bug directly.
Based on the error messaged, it looked to me that the bug on JMP11 was that the scriptable object gets "deleted" when you use Column Switcher.
So i just added readdressing line to reassign the object to the object name after the column has been switched.

For example,

nw["Var Charts"][listboxbox(2)]<<set selected(i);
vc2 =nw["Var Charts"][outline box("chart name")] << Get scriptable object;
cs2 << remove column switcher;
txnelson
Super User

Re: Shared Column Switcher for multiple graphs

Brilliant!

Jim
mikedriscoll
Level VI

Re: Shared Column Switcher for multiple graphs

I just want to highlight how powerful that particular use of << set script() is. I had been wondering for awhile how to get JMP to do something when changing selections in the column switcher, and this fits the bill perfectly.

nw["Var Charts"][listboxbox(1)] << set script(...)

 

Thanks!

Aline
Level I

Re: Shared Column Switcher for multiple graphs

Hi, 

Is it possible to do that without script? 

Thank in advance for responses