以下拉菜單形式展示資料的最佳方式?不是資料篩選器。
大家好,
我正在處理兩個數據表,它們通過主鍵和外鍵連接,每個表都有數千條數據。我的目標是在下拉清單中顯示這些表中的值(目前我使用的是組合方塊),並根據使用者的選擇動態產生子集或轉置表。
Currently, I’m using ComboBox to populate unique values from the data tables, but performance is quite slow and especially with larger datasets. I’ve found that JMP’s built-in Data Filter is powerful but not very customizable for UI integration.
有沒有辦法在後台利用資料篩選引擎並將其連接到自訂 UI 下拉選單?或者,有沒有更有效率的方法在 JSL 中實現響應式、動態的下拉式選單篩選?
任何建議或例子都將不勝感激!
提前致謝。
自動化和腳本編寫基礎資料分析與建模回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。請查看 JMP19 中的新篩選視圖。
或許你可以直接使用資料表本身,以及表格右邊的篩選視圖:

如果您對視圖滿意,只需將其作為新表格開啟即可。
更多詳情請參閱此演講: 開發者教學:資料表增強功能,講者: @Mandy_Chambers 。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。我們正在從舊版 JMP 升級到 JMP 19。因此,這個解決方案在舊版本中無法使用。有什麼辦法可以更快地在下拉式選單中顯示大量資料嗎?資料篩選器速度更快,但它們的 UI 自訂程度不高。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。您覺得哪個部分最慢?是構建組合框?搜尋值?還是建立子集?
能否分享一下範例腳本?因為可能有一些可以優化的地方。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。
我正在做的事情:
1. 載入兩個大型資料表(其中一個包含 10 萬行以上資料)
2. 透過匹配鍵將它們連接起來
3. 從所有篩選列中提取唯一值,並將它們儲存在單獨的快取表中。
4. 建立具有多個組合框下拉清單的自訂使用者介面(共 13 個篩選條件)
5. 從快取表中載入組合框值
6. 使用者從下拉式選單中選擇值並點選按鈕以建立篩選後的子集。
// This is simplified version:
Clear Log();
// Step 1-2: Load and join two tables
LoadAndJoinData = Function({},
dt_results = Data Table("Table1");
dt_tracker = Data Table("Table2");
// Join tables by matching key
dt_joined = dt_results << Join(
With(dt_tracker),
By Matching Columns(:key1 = :key2),
Drop multiples(0, 0),
Output Table("Joined_Data")
);
Return(dt_joined);
);
// Step 3: Create cache table with unique values - THIS IS SLOW
CreateFilterCache = Function({dt_source},
Print("Creating filter cache table...");
// Create cache table to store unique values
dt_cache = New Table("Filter_Cache",
New Column("Filter_Name", Character),
New Column("Filter_Value", Character)
);
column_list = {"Column1", "Column2", "Column3", "Column4", "Column5"};
current_row = 0;
For(i = 1, i <= N Items(column_list), i++,
col_name = column_list[i];
Print(" Processing: " || col_name);
// Extract unique values
col = Column(dt_source, col_name);
col_values = col << Get Values;
aa = Associative Array();
For(j = 1, j <= N Items(col_values), j++,
val = col_values[j];
If(!Is Missing(val) & val != "",
aa[val] = 1;
);
);
unique_list = aa << Get Keys;
unique_list = Sort Ascending(unique_list);
// Store in cache table
For(k = 1, k <= N Items(unique_list), k++,
current_row++;
dt_cache << Add Rows(1);
dt_cache:Filter_Name[current_row] = col_name;
dt_cache:Filter_Value[current_row] = unique_list[k];
);
);
Print("Cache table created with " || Char(N Rows(dt_cache)) || " entries");
Return(dt_cache);
);
// Step 5: Load unique values from cache table
GetValuesFromCache = Function({dt_cache, column_name},
value_list = {};
For(i = 1, i <= N Rows(dt_cache), i++,
If(dt_cache:Filter_Name[i] == column_name,
Insert Into(value_list, dt_cache:Filter_Value[i]);
);
);
Insert Into(value_list, "", 1);
Return(value_list);
);
// Step 4-5: Create filter window and load from cache
CreateFilterWindow = Function({dt_final, dt_cache},
Print("Loading dropdowns from cache...");
// Load from cache - STILL SLOW for large lists
unique_col1 = GetValuesFromCache(dt_cache, "Column1");
unique_col2 = GetValuesFromCache(dt_cache, "Column2");
unique_col3 = GetValuesFromCache(dt_cache, "Column3");
unique_col4 = GetValuesFromCache(dt_cache, "Column4");
unique_col5 = GetValuesFromCache(dt_cache, "Column5");
Print("Creating window...");
win = New Window("Custom Filter",
V List Box(
Panel Box("Select Filters",
V List Box(
H List Box(
Text Box("Filter 1:"),
cb_1 = Combo Box(unique_col1, "", <
<SET width="">
0, dt_subset = dt << Subset( Output Table Name("Filtered_" || Format(Today(), "yyyy-mm-dd")), Rows(rowList) ); Print("Subset created: " || Char(N Rows(dt_subset)) || " rows"); ); ) ) ); ); // Main execution dt_joined = LoadAndJoinData(); dt_cache = CreateFilterCache(dt_joined); // Create cache once CreateFilterWindow(dt_joined, dt_cache); // Use cached values
</SET>
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。使用總計表是獲取唯一值的好方法
Names Default To Here(1);
col_of_interest = "age";
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt_summary = dt << Summary(
Group(:age),
Freq("None"),
Weight("None"),
output table name("uniques"),
private
);
unique_ages = dt_summary[0, 1];
Close(dt_summary, no save);
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。感謝您的建議。效能確實有所提升,但下拉式選單仍然很慢,因為每個下拉式選單都包含大量不同的資料。如果我找不到自訂下拉式選單的好解決方案,我可能需要嘗試使用資料篩選器,然後在篩選器中新增按鈕,這可能是最佳選擇。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。使用資料篩選器製表如何?
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
Tabulate(
Show Control Panel( 0 ),
Add Table( Row Table( Grouping Columns( :sex ) ), Row Table( Grouping Columns( :name ) ) ),
Local Data Filter( Mode( Show( 0 ) ), Add Filter( columns( :sex ), Where( :sex == "F" ) ) )
);
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。您可以對資料篩選器進行一些調整,但很快就會遇到限制。除非速度問題出在組合框(顯示組合框)上,否則還有很多地方可以優化。如果您能提供一個腳本來建立範例表格(或多個範例表格),用於測試速度,那麼示範這些可能的最佳化方法將會容易得多。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。或許這個腳本會有幫助,因為這個表也有成千上萬行資料。
您可以移除這部分內容,然後就能看到組合框的問題所在。
// Truncate for testing purposes (Truncated it 50 rows this needs to be removed)
unique_flights = unique_flights[1 :: 50];
Show( N Items( unique_flights ) );
// ========================================
// TEST SCRIPT - Single Column Filter (Table Air Traffic)
// Column - Flight ID
// ========================================
Clear Log();
// Todo: The associative array is not an appropriate method for large datasets with many unique values.
// Perhaps use the summary table or something else. Or find unique column values using hashing and storing in a temp table.
// Open the Air Traffic sample data table
dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );
// Safety check
If( Is Empty( dt ),
Throw( "No data table is open. Please open a data table first." );
);
Print( "Current Data Table: " || (dt << Get Name) );
Print( "Rows: " || Char( N Rows( dt ) ) );
Print( "Columns: " || Char( N Cols( dt ) ) || "\n" );
// METHOD 1: Use Summary table (most efficient for large datasets)
dt_summary = dt << Summary(
Group( :Flight ID ),
Freq( "None" ),
Weight( "None" ),
output table name( "Temp Summary" ),
private
);
unique_flights = dt_summary:Flight ID << Get Values;
Close( dt_summary, No Save );
// Truncate for testing purposes (Truncated it 50 rows this needs to be removed)
unique_flights = unique_flights[1 :: 50];
Show( N Items( unique_flights ) );
// // Sort unique values for faster lookup
// unique_flights = Sort List( unique_flights );
// Store reference to data table
::testDataTable = dt;
// Create filter window
::testFilterWindow = New Window( "Test Filter",
V List Box(
Text Box( "Select Flight ID:" ),
cb_flight = Combo Box( unique_flights, "" ),
H List Box(
Button Box( "Create Filtered Table",
sel_flight = cb_flight << Get Selected;
Print( "\n" || Repeat( "=", 60 ) );
Print( "Button clicked!" );
Print( "Selected Flight ID: " || Char( sel_flight ) );
// Use Where to filter (faster than For Each Row)
If( sel_flight != "",
rowList = ::testDataTable << Get Rows Where( :Flight ID == sel_flight );
Print( "Total rows matching filter: " || Char( N Items( rowList ) ) );
If( N Items( rowList ) > 0,
dt_subset = ::testDataTable << Subset(
Output Table Name( "Test Filtered - " || Format( Today(), "yyyy-mm-dd h:m:s" ) ),
Rows( rowList )
);
Print( "\nSUCCESS: Filtered table created!" );
Print( "Table: " || (dt_subset << Get Name) );
Print( "Rows: " || Char( N Rows( dt_subset ) ) );
Print( Repeat( "=", 60 ) || "\n" );
dt_subset << Bring Window To Front;
Close( ::testFilterWindow );
,
Print( "ERROR: No rows match the selected filter" );
Print( Repeat( "=", 60 ) || "\n" );
);
);
),
Button Box( "Cancel",
Close( ::testFilterWindow );
)
)
)
);
我也遇到了類似的問題,很遺憾,我不得不切換到資料過濾器。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。即使組合框功能正常,讓使用者滾動瀏覽兩萬筆記錄也會是相當糟糕的體驗。例如,您可以改用列錶框並新增搜尋功能,這樣使用者體驗會更好。您可以使用 JSL 實現,例如使用文字編輯框 + 列錶框,或使用資料篩選器或篩選列選擇器。
回覆:以下拉菜單形式顯示資料的最佳方式是什麼?而不是資料篩選器。感謝您分享這個腳本。這個腳本確實準確地描述了我遇到的問題。