cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
hogi
Level XI

Local Data Filter Arithmetics (e.g. for Graphlets)

Graphlets are very cool!

The local data filter is great. It automatically adjusts the data of the graphlet to match the subgroup of the main graph.

 

Are there JSL functions to adjust this filter?

I already found the 

Skip Filters() 

in Nascif's post Hover graphlet from another data table 

It removes parts unused parts of the filter such that the filter can also work for other tables without warning messages.
Is there a documentation how it works in detail?


Is there also a JSL function to add or intersect filters?


Application case:

If I generated a graph with a filter ( Bif Class plot restricted to age= 14)

Graph Builder(
	Variables( X( :height ), Y( :weight ), Overlay( :age ) ),
	Elements( Points( X, Y, Legend( 26 ) ) ),
	Local Data Filter(
		Add Filter( columns( :age ), Where( :age == 14 ), Display( :age, N Items( 6 ) ) )
	)
)

and use it as a hover label (via "save Script" - "Hover Label"/"Paste Graphlet") ...

 

the local data filter is still there in the JSL script:

Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Variables( X( :sex ) ),
	Elements( Bar( X, Legend( 3 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					Graph Builder(
						Size( 422, 474 ),
						Show Control Panel( 0 ),
						Variables( X( :height ), Y( :weight ), Overlay( :age ) ),
						Elements( Points( X, Y, Legend( 26 ) ) ),
						Local Data Filter( Add Filter( columns( :age ), Where( :age == 14 ) ) )
					)
				)
			)}
		)
	)
);

but it's function is automatically replaced by the local data filter from the Hover Label Extension Framework (all ages visible):

HolgerSp_0-1658509519553.png

 

So, it would be great to have a "merge" function to combine the manual local data filter with the one from the Hover Label Extension Framework.

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

You can script this, but it would definitely be nice to have option where the local data filters could be merged. This code can be made cleaner, but I just brute-forced it

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:sex)),
	Elements(Bar(X, Legend(3))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					gb = Graph Builder(
						Size(422, 474),
						Show Control Panel(0),
						Variables(X(:height), Y(:weight), Overlay(:age)),
						Elements(Points(X, Y, Legend(26)))
					);
					Insert Into(_filters, Name Expr(:age));
					Eval(Substitute(
						Expr(
							f = gb << Local Data Filter(Add Filter(
								columns(_col_list_), Where(_wheres_)
							))
						),
						Expr(_col_list_),
						_filters,
						Expr(_wheres_),
						Parse(_where)
					));
					f << (Filter Column(:age) << Where(::age == 14));
				),
			)}
		)
	)
);
-Jarmo

View solution in original post

jthi
Super User

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

Might need to use additional data table for that

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:sex)),
	Elements(Bar(X, Legend(3))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					If( Is Empty(dt1),
						dt1 = dt << Subset(All Rows, Selected Columns(0), invisible);
					);
					dt1 << Clear Row States;
					filter_expr = Expr(And());
					Insert Into(filter_expr, Name Expr(_whereExpr));
					Insert Into(filter_expr, Name Expr(:age == 14));
					Insert Into(filter_expr, Name Expr(:height >= 55 & :height <= 70));

					Eval(EvalExpr(dt1 << Select Where(!filter_expr)));
					dt1 << Hide and Exclude(1);
					gb_expr = EvalExpr(dt1 << Graph Builder(
						Size(422, 474),
						Show Control Panel(0),
						Variables(X(:height), Y(:weight), Overlay(:age)),
						Elements(Points(X, Y, Legend(26))),
						Local Data Filter(
							Grouped by AND(1),
							Add Filter(columns(:sex), Where(Expr(NameExpr(_whereExpr)))),
							Add Filter(columns(:age), Where(:age == 14), Display(:age, N Items(6))),
							Add Filter(columns(:height), Where(:height >= 55 & :height <= 70))
						)
					));
					gb_expr;
				),
				Click(
					dt1 << Clear Row States;
					gb2 = gb_expr;
					Eval(EvalExpr(gb2 << On Close(
						Try(Close(Expr(dt1), no save));
					)));
				)
			)}
		)
	)
);
Write();
-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

You can script this, but it would definitely be nice to have option where the local data filters could be merged. This code can be made cleaner, but I just brute-forced it

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:sex)),
	Elements(Bar(X, Legend(3))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					gb = Graph Builder(
						Size(422, 474),
						Show Control Panel(0),
						Variables(X(:height), Y(:weight), Overlay(:age)),
						Elements(Points(X, Y, Legend(26)))
					);
					Insert Into(_filters, Name Expr(:age));
					Eval(Substitute(
						Expr(
							f = gb << Local Data Filter(Add Filter(
								columns(_col_list_), Where(_wheres_)
							))
						),
						Expr(_col_list_),
						_filters,
						Expr(_wheres_),
						Parse(_where)
					));
					f << (Filter Column(:age) << Where(::age == 14));
				),
			)}
		)
	)
);
-Jarmo
hogi
Level XI

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

Hi Jarmo.
Thanks a lot for the JSL sniplet - a lot to learn from it ...

 

It's interesting:

  1. If the Local Data Filter is created inside the Graph Builder part (my code), it's overwritten by the Local Data Filter from the Hover Label Extension Framework.
  2. If the Local Data Filter is created after the Graph Builder (your code), it overwrites the Local Data Filter from the Hover Label Extrension Framework. *)

 

*) Looking closer:

This just holds for the graph that opens after clicking on the miniature graph in the hover label.
The miniature graph itself still shows all ages, so case 1)

-> surprising that there are two distinct graphs generated. With different ways of overwriting the Local Data Filter?

A last question:
Is there a tutorial that explains the different Local Data Filter Functions.
e.g. why do you have to use

f << (Filter Column(:age) << Where(::age == 14));

an why does 

f << Add Filter(Columns(:age), Where(::age == 14));

add the same filter, but without any effect?

jthi
Super User

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

I think the later one should also work if you modify the script otherwise (like I said, I just brute-forced to get it working). If I were to clean it up, first iteration of that would be maybe something like this where I first apply the filters from hover label and then add additional filters

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:sex)),
	Elements(Bar(X, Legend(3))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					Local({gb, f},
						gb = Graph Builder(
							Size(422, 474),
							Show Control Panel(0),
							Variables(X(:height), Y(:weight), Overlay(:age)),
							Elements(Points(X, Y, Legend(26)))
						);
						Eval(EvalExpr(
							f = gb << Local Data Filter(
								Add Filter(
									columns(expr(_filters)), Where(expr(NameExpr(_whereExpr)))
								)
							)
						));
						//f << Conditional(1);
						f << Grouped By And(1);
						f << Add Filter(Columns(:age), Where(:age == 14));
						f << Add Filter(Columns(:height), Where(:height >= 55));
					)
				),
			)}
		)
	)
);
Write();

 

-Jarmo
hogi
Level XI

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

Ah, "Add filter" adds a new "OR" group - I missed this detail:

HolgerSp_1-1658590589546.png

 

So, we just need a solution to fix the miniature graph in the hover label.
Hm ...

 

jthi
Super User

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

Might need to use additional data table for that

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:sex)),
	Elements(Bar(X, Legend(3))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Set Graphlet(
				Picture(
					If( Is Empty(dt1),
						dt1 = dt << Subset(All Rows, Selected Columns(0), invisible);
					);
					dt1 << Clear Row States;
					filter_expr = Expr(And());
					Insert Into(filter_expr, Name Expr(_whereExpr));
					Insert Into(filter_expr, Name Expr(:age == 14));
					Insert Into(filter_expr, Name Expr(:height >= 55 & :height <= 70));

					Eval(EvalExpr(dt1 << Select Where(!filter_expr)));
					dt1 << Hide and Exclude(1);
					gb_expr = EvalExpr(dt1 << Graph Builder(
						Size(422, 474),
						Show Control Panel(0),
						Variables(X(:height), Y(:weight), Overlay(:age)),
						Elements(Points(X, Y, Legend(26))),
						Local Data Filter(
							Grouped by AND(1),
							Add Filter(columns(:sex), Where(Expr(NameExpr(_whereExpr)))),
							Add Filter(columns(:age), Where(:age == 14), Display(:age, N Items(6))),
							Add Filter(columns(:height), Where(:height >= 55 & :height <= 70))
						)
					));
					gb_expr;
				),
				Click(
					dt1 << Clear Row States;
					gb2 = gb_expr;
					Eval(EvalExpr(gb2 << On Close(
						Try(Close(Expr(dt1), no save));
					)));
				)
			)}
		)
	)
);
Write();
-Jarmo
hogi
Level XI

Re: Local Data Filter Arithmetics (e.g. for Graphlets)

That's a solution!

no chance for the Hover Label Extension Framework Local Data Filter handling to escape.