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
BHarris
Level VI

Connect Local Data Filters between Graph Builder Windows from different data tables

Suppose I have two Graph Builder windows from different data tables, each with a Local Data Filter filtering on "run number" and "time".

 

Is it possible to connect the two Local Data Filters so they stay in sync?

 

Or perhaps with JSL to pull the current settings from Local Data Filter #1 and apply them to Local Data Filter #2?

 

(I guess step 1 is getting a reference to the Local Data Filters, I haven't even figured out how to do that yet -- here's what I have so far:

 

// get the last Graph Builder
win = Get Window List();
graphs = Filter Each({w}, win,
	If(Length(w << XPath("//OutlineBox[@helpKey='Graph Builder']")) > 0, 1, 0)
);
last_gb = graphs[N Items(graphs)][OutlineBox("Graph Builder")] << Get Scriptable Object;
localDataFilter = last_gb << XPath("//OutlineBox[text()='Local Data Filter']");

)

11 REPLIES 11
jthi
Super User

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

Could you concatenate the tables together and then use some sort of grouping column to separate them to different graphs? It might be easier than messing with filter change handler(s).

-Jarmo
BHarris
Level VI

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

Not really -- one table is a high-level summary of the run results, and we identify problems from that summary, then switch to the detailed-run plot and select the specific run in the data filter.  It's not obvious to me how merging those two tables would enable that type of behavior.

jthi
Super User

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

How about virtual joins?

-Jarmo
hogi
Level XII

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

hogi
Level XII

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

I guess one needs not-local data filters such that the Dispatch/Receive functionality of virtual links will broadcast the filter settings.

For my case, this was too slow.

 

hogi
Level XII

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

At the end, I switched back to local data filters and added a Filter Change Handler to the first Data Filter.
It works quite well - If you don't forget the

rs=

Filter Change Handler 

broadcastFilter=Function({x}, // Make Filter Change Handler need a function with 1 Argument
//get the script
filterScript = DataFilter1 << get Script();
//search for the "Add filter" part
		For( i = 1, i <= N Arg( filterScript ), i++,
			If( Head( Arg( filterScript, i ) ) == Expr( Add Filter() ),
				filterExpression = Arg( filterScript, i )
			)
		);
// broadcast it to the other Data filter
Eval( Substitute( Expr( Datafilter2 << Start Over << _filter_ ), Expr( _filter_ ), 
Name Expr( filterExpression ) ) );		

// activate the Filter Change Handler
rs = DataFilter1 << Make Filter Change Handler( broadcastFilter); // will call broadcastFilter() with 1 Argument: # of selected rows


edit:argument x added and commented. A Function 

broadcastFilter=Function({},

-without arguments - doesn't work.

hogi
Level XII

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

And if you want to copy the whole filter, you could use copy/paste:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb1 = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);

gb2 = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :sex ), X( :age, Position( 1 ) ), Y( :weight ), Overlay( :sex ) ),
	Elements( Bar( X( 1 ), X( 2 ), Y, Legend( 3 ) ) )
);

df1 = gb1 <<  Local Data Filter(
	Add Filter(
		columns( :age ),
		Where( :age == 15 ),
		Display( :age, N Items( 6 ) )
	)
);

df1 << copy local data filter();

gb2 << paste local data filter();
BHarris
Level VI

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

I like the idea, but obviously there's something I don't understand in your solution, as it crashes when I try to run it. 

 

Here's what I have so far:

 

Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb1 = dt << Graph Builder(
	Graph Spacing( 5 ),
	Variables( X( :sex ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 5 ) ) )
);

gb2 = dt << Graph Builder(
	Graph Spacing( 5 ),
	Variables( X( :sex ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 5 ) ) )
);

df1 = gb1 <<  Local Data Filter(
	Add Filter(
		columns( :sex ),
		Where( :sex == "M" ),
		Display( :sex, N Items( 2 ) )
	)
);

df2 = gb2 <<  Local Data Filter(
	Add Filter(
		columns( :sex ),
		Where( :sex == "F" ),
		Display( :sex, N Items( 2 ) )
	)
);


broadcastFilter = Function( {}, 
//get the script
	filterScript = df1 << get Script();
//search for the "Add filter" part
	For( i = 1, i <= N Arg( filterScript ), i++,
		If( Head( Arg( filterScript, i ) ) == Expr( Add Filter() ),
			filterExpression = Arg( filterScript, i )
		)
	);
// broadcast it to the other Data filter
	Eval(
		Substitute(
				Expr(
					df2 << Start Over << _filter_
				),
			Expr( _filter_ ), Name Expr( filterExpression )
		)
	);
);		

// activate the Filter Change Handler
rs = df1 << Make Filter Change Handler( broadcastFilter );

Here's the error:  "broadcastFilter has 0 parameters () but 1 arguments (18) were supplied".  Any idea what it's talking about?  I don't think I'm supplying any arguments in that last line...

hogi
Level XII

Re: Connect Local Data Filters between Graph Builder Windows from different data tables

Oh. sorry.

broadcastFilter = Function( {x},