Aggiornamento del filtro dati locale tramite un'altra tabella datiEHI !
Ho tre funzioni principali e, in sostanza, dispongo di due tabelle dati: la tabella dati "Master" contiene dati aggregati, mentre la tabella dati "Slave" contiene dati di misurazione grezzi. Quello che vorrei fare (e che in passato sono riuscito a fare in un'altra azienda) è aggiornare in modo interattivo il filtro del generatore di grafici della tabella Slave tramite il gestore dello stato di riga nella tabella dati Master. Per qualche motivo, il filtro non viene aggiornato, nonostante il gestore dello stato di riga sia funzionante. Le parti funzionali:
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 modifica: spostato nel blocco JSL
Automazione e scriptingOggetto: Aggiornamento del filtro dati locale da parte di un'altra tabella datiNames 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);
Potrebbero esserci opzioni (molto) migliori rispetto all'utilizzo del gestore dello stato della riga, ma è impossibile stabilirlo con le informazioni fornite.
Oggetto: Aggiornamento del filtro dati locale da parte di un'altra tabella datiEHI,
Ecco un po' più di codice dettagliato, tutto quanto, non c'è niente di sensibile.
Ho testato la soluzione proposta, ma non ha alcun effetto sul filtro. Rimuovendo la clausola WHERE, sono stati creati molti più filtri, ma quello che voglio fare è modificare i valori filtrati.
Ho creato un prototipo di prova in cui elimino il filtro e ne creo uno nuovo, ma è lento.
Qualsiasi cosa più sofisticata è ben accetta 
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 modifica: spostato nel blocco JSL
-Ilmari (lavoravamo nella stessa azienda)
Oggetto: Aggiornamento del filtro dati locale da parte di un'altra tabella datiNon importa Jarmo, ho risolto, la tua soluzione ha funzionato.