如何在不改變資料表中欄位的實際順序的情況下正確排列列切換器中的選項順序?
在提供的 JSL 中,簡單地對清單進行排序不會影響列切換器中選項的順序。
我注意到,有時 DataTable 中列的實際順序會影響列切換器中選項的順序,但有時則不會(我不知道原因)。但是,當處理包含許多列的 DataTable 時,更改列的順序非常耗時,而且似乎毫無意義。有沒有辦法在不改變實際列順序的情況下,實作列切換器中選項所需的排序?
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column( "Column 0", formula( :weight+1 ) );
dt << New Column( "Column 14", formula( :weight+2 ) );
dt << New Column( "Column 3", formula( :weight+3 ) );
dt << New Column( "Column 2", formula( :weight+4 ) );
dt << New Column( "Column 11", formula( :weight+5) );
dt << New Column( "Column 1", formula( :weight+6 ) );
dt << New Column( "Column ", formula( :weight+7 ) );
col = dt << get column names( string );
SwitchOption = {};
For Each( {value, index}, col,
If( Word( 2, value, " " ) != "",
SwitchOption = Insert( SwitchOption, col[index] )
)
);
//The column list before the order arrangement.
Graph = Graph Builder(
Size( 534, 464 ),
Show Control Panel( 0 ),
Variables( X( :name ), Y( :Column 0 ) ),
Elements( Points( X, Y, Legend( 5 ) ) )
);
Graph << Column Switcher(
Column( "column 0" ),
SwitchOption,
Title( "Test" )
);
//The column list after the order arrangement.
orderedSwitchOption = {};
oder = {};
For Each( {value, index}, SwitchOption, oder = Insert( oder, Num( Word( 2, value, " " ) ) ) );
oder = Sort List( oder );
For Each( {value, index}, oder,
orderedSwitchOption = Insert( orderedSwitchOption, "Column " || Char( value ) )
);
Graph2 = Graph Builder(
Size( 534, 464 ),
Show Control Panel( 0 ),
Variables( X( :name ), Y( :Column 0 ) ),
Elements( Points( X, Y, Legend( 5 ) ) )
);
Graph2 << Column Switcher(
Column( "column 0" ),
orderedSwitchOption,
Title( "Ordered Column" )
);
我認為使用列切換器你要么必須依賴表的列順序,要么必須依賴字母順序

我不確定在這種情況下“原始順序”是什麼意思,因為當我們討論 JMP 表中的列時,它可能有不同的含義

但我認為在列切換器的情況下它可能是“表格順序”而不是原始順序。
對於 JMP 表
使用 JMP > 輸入和編輯資料 > 組織資料表中的資料 > 重新排列資料表中的列
原來的 命令
將列還原到資料表上次儲存時的順序。