別のデータテーブルによるローカルデータフィルタの更新おい !
主な機能は3つあり、基本的には2つのデータテーブルがあります。「マスター」データテーブルには集計データがあり、「スレーブ」データテーブルには生の測定データがあります。私がやりたいこと(そして以前別の会社でできていたこと)は、マスターデータテーブルの行状態ハンドラによってスレーブテーブルのグラフビルダーフィルタを対話的に更新することです。何らかの理由で、行状態ハンドラは機能しているにもかかわらず、フィルタが更新されません。機能部分は以下のとおりです。
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編集:JSLブロックに移動しました
自動化とスクリプト作成件名:別のデータテーブルによるローカルデータフィルタの更新Names 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);
行状態ハンドラーを使用するよりも(はるかに)優れた選択肢があるかもしれないが、提供された情報だけでは判断できない。
件名:別のデータテーブルによるローカルデータフィルタの更新おい、
もう少し詳細なコードを以下に示します。全体を通して、機密情報は一切含まれていません。
提案された解決策を試してみましたが、フィルターには何も影響がありませんでした。where句を削除するとフィルターの数が増えましたが、私がやりたいのはフィルターされた値を変更することです。
フィルターを削除して新しいフィルターを作成するダミーのプロトタイプを作成しましたが、動作が遅くなります。
もっと洗練されたものも大歓迎です 
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編集:JSLブロックに移動しました
-イルマリ(私たちは以前同じ会社で働いていました)
件名:別のデータテーブルによるローカルデータフィルタの更新気にしないで、Jarmo、解決したよ。君の解決策がうまくいった。