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
AlanBell
Level II

Preset filters as button boxes

I am trying to create button boxes where I can have set parameters that the global filter is assigned to.

 

For the example below I would like a button for females only and another one with male and height greater than 60

 

	dt = Open( "$SAMPLE_DATA/big class.jmp" );
	
	gra1=hlistbox(dt<<Graph Builder(
	Size( 528, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 11 ) ), Smoother( X, Y, Legend( 12 ) ) )
));

tab1=hlistbox(dt<<Tabulate(
	Show Control Panel( 0 ),
	Full Path Column Name( 1 ),
	Add Table(
		Column Table( Analysis Columns( :height ) ),
		Row Table( Grouping Columns( :name, :sex ) )
	)
));

fil1=hlistbox(dt<<Data Filter(
	Auto clear( 1 ),
	Show Histograms and Bars( 0 ),
	Mode( Show( 0 ) ),
	Add Filter(
		columns( :sex, :age, :height ),
		Display( :age, N Items( 6 ) ),
		Display( :height, Height( 20 ) )
	)
));

win1=New Window("Example", hlistbox(fil1, vlistbox(gra1, tab1)));
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Preset filters as button boxes

This does show few different options

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/big class.jmp");
	
gra1 = H List Box(
	dt << Graph Builder(
		Size(528, 450),
		Show Control Panel(0),
		Variables(X(:height), Y(:weight), Overlay(:sex)),
		Elements(Points(X, Y, Legend(11)), Smoother(X, Y, Legend(12)))
	)
);

tab1 = H List Box(
	dt << Tabulate(
		Show Control Panel(0),
		Full Path Column Name(1),
		Add Table(Column Table(Analysis Columns(:height)), Row Table(Grouping Columns(:name, :sex)))
	)
);

fil1 = H List Box(
	df = dt << Data Filter(
		Auto clear(1),
		Show Histograms and Bars(0),
		Mode(Show(0)),
		Add Filter(columns(:sex, :age, :height), Display(:age, N Items(6)), Display(:height, Height(20)))
	)
);

df << Match(Filter Columns(:sex, :age, :height), Where(:sex == "F"));
df << add favorites("F only");
df << Clear;

win1 = New Window("Example", 
	V List Box(
		Lineup Box(N Col(2),
			Button Box("F Only",
				df << Apply Favorites("F only")
			),
			Button Box("M, height >= 60",
				df << (Filter Column(:sex) << Where(:sex == "M"));
				df << (Filter Column(:height) << Extend Where(:height >= 60));
			)
		),
		H List Box(
			fil1, 
			V List Box(
				gra1
				, tab1
			)
		)
	)
);
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Preset filters as button boxes

Could you maybe just utilize Favorites?

jthi_0-1735930448126.png

 

If you wish to have buttons, you could still utilize favorites (add them first and then make buttons apply those favorites). Look for Data Filter (on the left) from scripting index for all sorts of useful options:

Using favorite (this example gives pretty good idea of what you could do)

jthi_2-1735930534378.png

Using Where:

jthi_3-1735930556447.png

https://www.jmp.com/support/help/en/18.0/#page/jmp/data-filter-messages.shtml#

 

And for buttons you can use Button Box()

https://www.jmp.com/support/help/en/18.0/#page/jmp/construct-display-boxes-for-new-windows.shtml#ww4...

-Jarmo
AlanBell
Level II

Re: Preset filters as button boxes

Thanks, I would like to have buttons visible rather than favorites. 

 

I was trying to use filter columns and match in a function to no avail! 

 

I have gone through the scripting index and searched everywhere, used the new learnbot from the store as well as ChatGPT!

 

Seems odd it has not been implemented before.

jthi
Super User

Re: Preset filters as button boxes

This does show few different options

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/big class.jmp");
	
gra1 = H List Box(
	dt << Graph Builder(
		Size(528, 450),
		Show Control Panel(0),
		Variables(X(:height), Y(:weight), Overlay(:sex)),
		Elements(Points(X, Y, Legend(11)), Smoother(X, Y, Legend(12)))
	)
);

tab1 = H List Box(
	dt << Tabulate(
		Show Control Panel(0),
		Full Path Column Name(1),
		Add Table(Column Table(Analysis Columns(:height)), Row Table(Grouping Columns(:name, :sex)))
	)
);

fil1 = H List Box(
	df = dt << Data Filter(
		Auto clear(1),
		Show Histograms and Bars(0),
		Mode(Show(0)),
		Add Filter(columns(:sex, :age, :height), Display(:age, N Items(6)), Display(:height, Height(20)))
	)
);

df << Match(Filter Columns(:sex, :age, :height), Where(:sex == "F"));
df << add favorites("F only");
df << Clear;

win1 = New Window("Example", 
	V List Box(
		Lineup Box(N Col(2),
			Button Box("F Only",
				df << Apply Favorites("F only")
			),
			Button Box("M, height >= 60",
				df << (Filter Column(:sex) << Where(:sex == "M"));
				df << (Filter Column(:height) << Extend Where(:height >= 60));
			)
		),
		H List Box(
			fil1, 
			V List Box(
				gra1
				, tab1
			)
		)
	)
);
-Jarmo
AlanBell
Level II

Re: Preset filters as button boxes

Thank you so much!!!