嘿 !
我有三個主要功能,基本上有兩個數據表,其中一個「主表」包含聚合數據,「從表」包含原始測量數據。我想要實現的功能(之前在另一家公司也實現過)是根據主表的行狀態處理程序交互式地更新從表的圖表構建器篩選器。但不知何故,儘管行狀態處理程序運作正常,但篩選器卻沒有更新。功能部分如下:
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 區塊
-伊爾馬裡(我們以前在同一家公司工作)