JMP 社群您好!
我有以下程式碼作為我製作的加載項的一部分:
Report7 = Platform(
dt,
gb7 = Graph Builder(
Size( 632, 571 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Order No. ),
Y( :S0a value, Position( 1 ) ),
Y( :S1a value, Position( 1 ) ),
Y( :S1b value, Position( 1 ) ),
Y( :S1c value, Position( 1 ) ),
Y( :S2a value, Position( 1 ) ),
Y( :S3a value, Position( 1 ) ),
Y( :S4b value, Position( 1 ) ) ),
Elements(
Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ),
Y( 6 ), Y( 7 ), Legend( 11 ) )
),
)
);問題是我並不總是擁有要求加載項在 y 軸上繪製的所有列(例如,資料表可能只有 S0a - S1c 而不是 S0a - S4b)。 在這種情況下,產生的圖只是 x 軸列(即「訂單號碼」)的直方圖。
有沒有一種方法可以使程式碼繪製任何可用的列並自動忽略不可用的列? 我也對其他想法持開放態度。
先感謝您!
艾哈邁德
這可能是一個選項,您需要使用您想要包含的實際清單填充變數 cols:
Names default to here(1);
dt = Open("$Sample_data/probe.jmp");
//Variables to hold the dynamic parts of the graph builder expresssion
Expr1 = "";
Expr2 = "";
// Pick columns to include
cols = ( dt << get column names() )[random shuffle(8::397)[1::5]];
//Populate expressions
for(c=1, c<= n items(cols), c++,
Expr1 = Expr1 || "Y( Column( \!"" || cols[c] || "\!" ), Position(1) ),";
Expr2 = Expr2 || "Y( " || char( c ) || " ),";
);
Eval( Parse( substitute(
//the graph builder script as a string with 'dummy variables' where the
//expressions created earlier will go
"gb = Graph Builder(
Size( 838, 391 ),
Variables(
X( :DELL_RPPBR ),
Expr1_
),
Elements( Line( X, Expr2_ Legend( 10 ) ) ),
Local Data Filter(
Add Filter(
columns( :DELL_RPPBR ),
Where( :DELL_RPPBR >= -1 & :DELL_RPPBR <= 0.483837991952896 )
)
)
)",
//replace the 'dummy variables'
"Expr1_",
Expr1,
"Expr2_",
Expr2
) ) );