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

How do i get the list box to work?

I am new to JMP and I came across the List Box which allows us to filter data based on the selection, but it is currently not working for me. I am getting the list box to display, but it doesn't change anything in the graph. I would expect the time to change based on arrival or departure.Any suggestions?

 

dt = Open("$sample_data/Air Traffic.jmp");
m_name = dt:Event << get values << As List(m_name);

gb_default = Expr(
	Graph Builder(
		Size(550, 372),
		Show Control Panel(0),
		Fit to Window("Off"),
		Variables(X(:Airline), Y(:Original Time)),
		Elements(Box Plot(X, Y, Legend(19)))
	);
);

nw = New Window("Traffic Monitor ",
	gb = gb_default;
	lbcontent = Lineup Box(N Col(10),
		Spacer Box(Size(1, 0)),
		Spacer Box(Size(1, 0)),
		Spacer Box(Size(1, 0)),
		Text Box("Airline: ", <<Set Font Size(10)),
		List1 = List Box(m_name, nlines(3), width(50)),
		List1 << Set Items(m_name) << Get Selected
	);
);
dk
6 REPLIES 6
jthi
Super User

Re: How do i get the list box to work?

I would suggest using Local Data Filter for this instead of building list box with some custom jsl.

 

You can add local data filter from Toolbar

jthi_0-1666946406405.png

or red triangle menu

jthi_1-1666946422639.png

 

Names Default To Here(1);

dt = Open("$sample_data/Air Traffic.jmp");

gb = dt << Graph Builder(
	Size(550, 406),
	Show Control Panel(0),
	Fit to Window("Off"),
	Variables(X(:Airline), Y(:Original Time), Group X(:Event)),
	Elements(Box Plot(X, Y, Legend(19))),
	Local Data Filter(
		Add Filter(columns(:Event), Where(:Event == {"Arrive", "Depart"}))
	)
);

jthi_2-1666946444979.png

 

-Jarmo
AbbWorld27
Level II

Re: How do i get the list box to work?

Many thanks for this, this certainly helps! Would you know if it's possible to have local data filter positioned below the graph instead of on the left?

dk
jthi
Super User

Re: How do i get the list box to work?

I think you can do it at least by using Data Filter Context Box and data filter source box

Names Default To Here(1);
dt = Open("$sample_data/Air Traffic.jmp");

nw = New Window("Selection Filter",
	Data Filter Context Box(
		V List Box(
			gb = dt << Graph Builder(
				Size(550, 406),
				Show Control Panel(0),
				Fit to Window("Off"),
				Variables(X(:Airline), Y(:Original Time), Group X(:Event)),
				Elements(Box Plot(X, Y, Legend(19)))
			),
			dfsb = Data Filter Source Box(
				dt << Data Filter(
					Local,
					Mode(Show(1), Include(1)),
					Add Filter(columns(:Event), Where(:Event == {"Arrive", "Depart"}))
				)
			)
		)
	)
);
-Jarmo
AbbWorld27
Level II

Re: How do i get the list box to work?

Having some issues with both the local data filter & combo box fitting in. I am trying to build a tool for my company so I need the legend to be interactive, at the same time I want some to be able to put filters based on a column "season" in this example. But as I soon as I change the legend, the local data filter keeps expanding to down the graph. Would you know what I can do to improve this? 

 

I've taken the animals data table as it's very small

 

dt = Open("$sample_data/Animals.jmp");
xlist = dt << Get Column Names( String );

gb_default = Expr(
Graph Builder(
Size( 544, 356 ),
Show Control Panel( 0 ),
Legend Position( "Bottom" ),
Fit to Window( "Off" ),
Variables( X( :species ), Y( :miles ), Color( :subject ) ),
Local Data Filter(
Add Filter(
columns( :season ),
Display( :season, Size( 160, 60 ), List Display )
)
),
Elements( Points( X, Y, Legend( 23 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Orientation( "Horizontal" ), Sides( "Left" )}
)
)
));


gb_change = Expr(
Graph Builder(
Size( 544, 356 ),
Show Control Panel( 0 ),
Legend Position( "Bottom" ),
Fit to Window( "Off" ),
Variables( X( :species ), Y( :miles ), Color( Column( dt, ycol )) ),
Local Data Filter(
Add Filter(
columns( :season ),
Display( :season, Size( 160, 60 ), List Display )
)
),
Elements( Points( X, Y, Legend( 23 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Orientation( "Horizontal" ), Sides( "Left" )}
)
)
));

nw = New Window( "Animal test ",
gb = gb_default;
lbcontent = Lineup Box( N Col( 10 ),
Spacer Box( Size( 1, 0 ) ),
Text Box( "Color: ", <<Set Font Size( 10 ) ),
ycb = Combo Box(
xlist,
<<Set( 2 ),
<<Set Function(
Function( {},
ycol = ycb << Get;
gb << delete;
nw << Prepend( gb = gb_change );
)
)
),
);
);

dk
AbbWorld27
Level II

Re: How do i get the list box to work?

On the above, would you advise me to use data filters for both of them?

dk

Re: How do i get the list box to work?

When using the Data Filter, it should not be necessary to add the Data Filter Source Box().  Thought it does work on desktop JMP, it can affect other output such as to JMP Live.  The Data Filter Source Box should be added when you want to use a platform to filter one (or more) other platforms.  This modifies the script from @jthi  to demonstrate both.

dt = Open("$sample_data/Air Traffic.jmp");

nw = New Window("Filter examples",
	H List Box(
		Tab Page Box("Data Filter",
			Data Filter Context Box(
				V List Box(
					gb = dt << Graph Builder(
						Size(550, 406),
						Show Control Panel(0),
						Fit to Window("Off"),
						Variables(X(:Airline), Y(:Original Time), Group X(:Event)),
						Elements(Box Plot(X, Y, Legend(19)))
					),
					dt << Data Filter(
						Local,
						Mode(Show(1), Include(1)),
						Add Filter(columns(:Event), Where(:Event == {"Arrive", "Depart"}))
					)
				)
			)
		),
		Tab Page Box("Selection Filter",
			Data Filter Context Box(
				V List Box(
					gb = dt << Graph Builder(
						Size(550, 406),
						Show Control Panel(0),
						Fit to Window("Off"),
						Variables(X(:Airline), Y(:Original Time), Group X(:Event)),
						Elements(Box Plot(X, Y, Legend(19)))
					),
					Data Filter Source Box(
						dt << Graph Builder(
							Size( 343, 132 ),
							Show Control Panel( 0 ),
							Fit to Window( "Off" ),
							Variables( Y( :Event ) ),
							Elements( Bar( Y, Legend( 2 ) ) )
						)
					)
				)
			)
		)
	)
);