Data filter script<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I am filtering data using values in a column. Is it possible to attach a script to the data filter so that the script runs whenever the a new column value is selected in the filter?
Thanks.
Re: Data filter scriptIn JMP 11, the << close command would not have an effect on a filter that was visible. Changes in JMP 12 have made this work.
As a workaround for JMP 11 you could use:
gb << Remove Local Data Filter;
Re: Data filter scriptBoth of your solutions will work, but you do need to assign the result to something:
rsh = DataFilter1 << Make Row State Handler(DataFilter1_handler);
The row state handler is an object that is returned to you. Since it wasn't stored anywhere it went away!
Re: Data filter scriptOne further question about the local data filter in your example:
How can you remove the filter by code ("remove local data filter" if you do it manually)?
I tried these commands:
// works
ldf << clear;
// does not work
ldf << close;
ldf << remove;
ldf << close window;
ldf << delete;
Re: Data filter scriptThank you, that works. It is really easy if you know how to do it
My next question is probably also quite easy for you:
I have a local data filter in an application. I want to set a row state handler for it.
That's my code:
DataFilter1 << Add Filter(
Columns(Eval(filter_parameter)),
Display(Size( 100, 150 ),List Display)
);
// set OutlineCloseOrientation and title
ldfr = DataFilter1 << report;
ldfr[Outline Box( 1 )] << OutlineCloseOrientation( "Horizontal" );
ldfr[Outline Box( 1 )] << Set Title("Filter");
// set row state handler - both versions do not work
DataFilter1 << Make Row State Handler(DataFilter1_handler);
ldfr[Outline Box( 1 )] << Make Row State Handler(DataFilter1_handler);
DataFilter1_handler = function({x},
show("row state handler function");
);
Re: Data filter scriptTo message the local data filter, you need to get a reference to it. Try something like:
NamesDefaultToHere(1);
// Some data
dt = New Table( "Fruits",
Add Rows( 3 ),
New Column( "Fruit",
Character,
"Nominal",
Set Values( {"Pear", "Apple", "Orange"} )
)
);
// A report with a local data filter
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :Fruit ) ),
Elements( Bar( X, Legend( 3 ) ) )
);
ldf = gb << Local Data Filter( Mode, Add Filter( columns( :Fruit ) ) );
// Row state handler function
doSomethingWithSelection = Function({x}, {Default Local},
currentScript = ldf << getScript;
ClearLog();
Print(currentScript);
);
// Get a reference to the report
gbReport = gb << Report;
// Assign the row state handler to the local data filter display box
rsh = gbReport[OutlineBox(1)] << MakeRowStateHandler(doSomethingWithSelection);
Re: Data filter scriptI have a similar problem. I would like to store the script of a local data filter of a graph builder in a string variable every time the filter changes. My problem with the script above is how to access the local data filter in the doSomethingWithSelection function.
The following line does not work, it does not give the data filter script:
string = gbreport[outlinebox(1)] << get script
Re: Data filter scriptBrilliant - thanks.
Re: Data filter scriptBuilding on Dan's reply, try:
NamesDefaultToHere(1);
// Some data
dt = New Table( "Fruits",
Add Rows( 3 ),
New Column( "Fruit",
Character,
"Nominal",
Set Values( {"Pear", "Apple", "Orange"} )
)
);
// A report with a local data filter
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :Fruit ) ),
Elements( Bar( X, Legend( 3 ) ) ),
Local Data Filter( Mode, Add Filter( columns( :Fruit ) ) )
);
// Row state handler function
doSomethingWithSelection = Function({x}, {Default Local}, Beep(); Wait(0.1); Beep() );
// Get a reference to the report
gbReport = gb << Report;
// See what messages the data filter display box understands (prints to the log)
ShowProperties(gbReport[OutlineBox(1)]);
// Assign the row state handler to the local data filter display box
rsh = gbReport[OutlineBox(1)] << MakeRowStateHandler(doSomethingWithSelection);
Re: Data filter scriptThe data filter manipulates the row states of the data table (global filter) or a private set of row states (local filter). You can use dt<