Hey,
Heres a bit more detail code, the whole thing, theres nothing sensitive in it.
I tested the proposed solution but it does nothing to the filter. Removing the where clausule had the effect that it made many more filters but what I want to do is change the filtered values.
I made a dummy proto where I delete the filter and create a new one but that is laggy.
Anything more sophisticated is welcome :)
Names Default To Here( 1 );
/*
USER SETTINGS
-------------
Change these names to match your open JMP data tables and columns.
*/
dtMaster = Data Table( "peak_summary" ); // Table containing the master XY plot
dtDetail = Data Table( "all_parsed_data" ); // Table containing raw/calculated data
sourceColMaster = "SourceFile";
sourceColDetail = "SourceFile";
// Master plot columns
masterXCol = "X";
masterYCol = "Y";
masterColourCol = "MasterValue";
// Detail plot columns
detailXCol = "X";
detailYCol = "Y";
detailColourCol = "CalculatedValue";
// Helper column in detail table
linkColName = "_Selected_By_Master";
// Behaviour when nothing is selected in master plot:
// 1 = show all detail rows
// 0 = show no detail rows
showAllWhenNothingSelected = 1;
/*
CREATE / RESET HELPER COLUMN IN DETAIL TABLE
*/
If(
Try( Is Missing( Column( dtDetail, linkColName ) << Get Name ), 1 ),
dtDetail << New Column(
linkColName,
Numeric,
Nominal,
Set Each Value( 1 )
)
);
colLink = Column( dtDetail, linkColName );
/*
FUNCTION:
Update detail-table helper column based on selected SourceFile values
in the master table.
*/
rs = dtMaster << Make RowState Handler(f);
Update Detail Filter = Function( {},
{selRows, selectedSources, i, r, sf, detailRows},
selectedSources = {};
selectedRows = dtMaster << Get Row States;
filteredKeys = dtMaster:SourceFile[Loc(selectedRows)];
filteredKeys = Associative Array( filteredKeys ) << Get Keys;
detailFilter << (
Filter Column( :SourceFile ) <<
Where(
:SourceFile == "filteredKeys" // Not performing anything
)
);
);
/*
CREATE MASTER PLOT
Selection in this plot drives the second plot.
*/
masterPlot = dtMaster << Graph Builder(
Size( 700, 600 ),
Show Control Panel( 0 ),
Variables(
X( Column( dtMaster, masterXCol ) ),
Y( Column( dtMaster, masterYCol ) ),
Color( Column( dtMaster, masterColourCol ) )
),
Elements(
Points( X, Y, Legend( 1 ) )
)
);
f = Function( {a}, Print( a ) );
/*
CREATE DETAIL PLOT WITH LOCAL DATA FILTER
The Local Data Filter keeps only rows where _Selected_By_Master == 1.
*/
detailPlot = dtDetail << Graph Builder(
Size( 657, 556 ),
Show Control Panel( 0 ),
Variables( X( :Frequency_GHz ), Y( :S11Mag_dB ) ),
Elements( Smoother( X, Y, Legend( 7 ), Lambda( 0.000001 ) ) ),
);
detailFilter = detailPlot << Local Data Filter(
Close Outline(1),
Add Filter(columns(:SourceFile), Display(:SourceFile, N Items(6)))
);
/*
ROW STATE HANDLER
This fires whenever row states change in the master table,
including point selection from the master XY plot.
IMPORTANT:
Keep this handler variable alive.
If it goes out of scope, the handler may stop working.
*/
::MasterToDetail_RowStateHandler = dtMaster << Make Row State Handler(
Function( {changedRows},
Update Detail Filter();
)
);
/*
Initial update
*/
Update Detail Filter();
txnelson edit: moved to JSL block
-Ilmari (we used to work in the same company)