Lokaler Datenfilter wird durch eine andere Datentabelle aktualisiertHey !
Ich habe drei Hauptfunktionen und im Wesentlichen zwei Datentabellen: Die „Master“-Tabelle enthält aggregierte Daten, die „Slave“-Tabelle Rohmessdaten. Ich möchte (und konnte dies bereits in einem anderen Unternehmen), den Filter des Graph-Builders der Slave-Tabelle interaktiv anhand des Zeilenstatus-Handlers der Master-Tabelle aktualisieren. Aus irgendeinem Grund wird der Filter jedoch nicht aktualisiert, obwohl der Zeilenstatus-Handler funktioniert. Die funktionalen Teile:
Row state handler:
===
rs = dtMaster << Make RowState Handler(f);
===
Dynamic filtering:
===
filteredKeys = dtMaster:SourceFile[Loc(selectedRows)];
filteredKeys = Associative Array( filteredKeys ) << Get Keys;
Try(
Eval(
Eval Expr(
detailFilter << Select Where(
Expr( filteredKeys ) == :SourceFile
)
)
);
,
Print( "Select Where failed" );
Show( filteredKeys );
);
===
===
Filter creation:
detailFilter = detailPlot << Local Data Filter( Close Outline( 1 ), Add Filter( Columns( :SourceFile ), Display( :SourceFile, N Items( 15 ), Find( Set Text( "" ), Contains Terms( 1 ), Contains Phrase( 0 ) ) ) ) );
txnelson-Bearbeitung: in den JSL-Block verschoben
Automatisierung und SkripterstellungBetreff: Aktualisierung des lokalen Datenfilters durch eine andere DatentabelleNames Default To Here(1);
dt_raw = open("$SAMPLE_DATA/Big Class.jmp");
dt_main = dt_raw << Summary(
Group(:age),
Freq("None"),
Weight("None"),
Link to original data table(0),
output table name("Summary of Big Class grouped by age")
);
gb = dt_raw << Graph Builder(
Size(658, 550),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(Points(X, Y, Legend(4)))
);
ldf = gb << Local Data Filter(
Close Outline(1),
Add Filter(columns(:age), Display(:age, N Items(6)))
);
f = Function({a},
selrows = dt_main << Get Selected Rows;
selvals = As List(dt_main[selrows, "age"]); // drop unique if necessary
ldf << (Filter Column(:age) << Where(:age == selvals));
);
rs = dt_main << Make RowState Handler(f);
Es gäbe möglicherweise (viel) bessere Alternativen zur Verwendung des Zeilenstatus-Handlers, aber das lässt sich anhand der vorliegenden Informationen nicht sagen.
Betreff: Aktualisierung des lokalen Datenfilters durch eine andere DatentabelleHey,
Hier ist der Code etwas detaillierter, das Ganze, da ist nichts Sensibles drin.
Ich habe die vorgeschlagene Lösung getestet, aber sie hat keine Auswirkung auf den Filter. Das Entfernen der WHERE-Klausel führte zwar zu deutlich mehr Filtern, ich möchte aber die gefilterten Werte ändern.
Ich habe einen Dummy-Prototyp erstellt, bei dem ich den Filter lösche und einen neuen erstelle, aber das ist ruckelig.
Alles Anspruchsvollere ist willkommen 
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-Bearbeitung: in den JSL-Block verschoben
-Ilmari (wir haben früher im selben Unternehmen gearbeitet)
Betreff: Aktualisierung des lokalen Datenfilters durch eine andere DatentabelleEgal Jarmo, ich hab's rausgefunden, deine Lösung hat funktioniert.