cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Vicki36
Level I

Column Switcher, Local Data Filter and Ref Line Automatically Update

I have created a bar chart using the graph builder and want to apply a local data filter, column switcher and ref line to the chart. Is it possible to automatically switch the local data filter and reference line depending on which column is selected. At the moment my reference line just completed disappears when I swap between columns. I have 2 possible columns to select, Cpk and Ppk. I want to include a reference line at Cpk = 1.333 and Ppk = 1.333, respective of which is currently being displayed. Similarly, I want to add a local data filter to show only values between the min Cpk/Ppk value and a max value of 1.5 depending on which column is being displayed. Is it possible to do this in the simple graph builder by scripting it or will I need to look in to a dashboard/application? This is what I currently have:

 

Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Feature ID, Order By( :Cpk , Ascending, Order Statistic( "Mean" ) ) ),
		Y( :Cpk )
	),
	Column Switcher( :Cpk , {: Cpk , :Ppk }),
	Elements( Bar( X, Y, Legend( 4 ) ) ),
	Local Data Filter(
		Add Filter( columns( :Cpk ), Where( :Cpk >= floor(Col Min(:Cpk )) & :Cpk <= 1.5 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Cpk ",
			ScaleBox,
			{Add Ref Line( 1.333, "Solid", "Red", "", 3 )}
		),
	)
);
4 REPLIES 4
txnelson
Super User

Re: Column Switcher, Local Data Filter and Ref Line Automatically Update

Yes it is possible to do what you want.  Here is a simple example

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
gb = dt << Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

ColSwitcher = gb << Column switcher( :weight, {:weight, :height} );

Report( gb )[framebox( 1 )] << add graphics script(
	theCol = ColSwitcher << Get Current;
	If(
		theCol == "weight",
			Report( gb )[AxisBox( 2 )] << add ref line(
				Col Mean( :weight ),
				"solid",
				red,
				"Mean",
				2
			),
		theCol == "height",
			Report( gb )[AxisBox( 2 )] << add ref line(
				Col Mean( :height ),
				"solid",
				red,
				"Mean",
				2
			)
	);
);
Jim
Vicki36
Level I

Re: Column Switcher, Local Data Filter and Ref Line Automatically Update

Hi, 

When I've copied that into a script it doesn't appear to work correctly. The graph has an error message stating 'Graphics script reported errors in log'. And the error reported in the log states 'Name Unresolved: weight{21} in access or evaluation of 'weight' , weight/*###*/'. I'm using JMP 13, I don't know if this may be an issue?

 

I've managed to add a reference line which remains at 1.333 regardless of what is displayed on the y-axis as follows:

 

obj = dt_sum << Graph Builder(
	Size( 534, 464 ),
	Show Control Panel( 0 ),
	Variables(
	X( :Feature ID, Order By( :Cpk, Ascending, Order Statistic( "Mean" ) ) ),
	Y( :Cpk)
	),
	Column Switcher( :Cpk, {: Cpk, :Ppk}),
	Elements( Bar( X, Y, Legend( 4 ) ) ),
	);

Report(obj)[FrameBox(1)] << 
	Add Graphics Script(
		1, Description( "Pen Script"),
		Pen Color("red");
		Pen Size(3);
		Y Function(1.333, Feature ID);
);

However I'm still unsure how to link the column switcher with a local data filter so that only values below a certain y-value are displayed and updated when the column is switched. 

 

txnelson
Super User

Re: Column Switcher, Local Data Filter and Ref Line Automatically Update

The first issue with running the script in JMP 13, is that what is returned from the
ColSwitcher << get Current
is not a literal string, so it has to be changed to
char( ColSwitcher << get Current )
but when one does that, JMP goes into an infinite loop
I believe this was a known error, and is related to the when the Add Graphics Script is called by the Column Switcher change.
I tried a bunch of things, but wasn't able to come up with a solution. Upgrading to 15 is the only option I am sure will fix it.
Jim
Vicki36
Level I

Re: Column Switcher, Local Data Filter and Ref Line Automatically Update

Ok thank you no worries!

I'm using company software so don't think I'll be able to upgrade so will just have to think of a different way to display the data. I assume I will run into a similar problem if trying to just change the axis limits depending on the column selected, rather than trying to update the local data filter? Cheers