我有两个数据源,它们会定期更新,从而产生新的列。这些是通过 JSL 脚本合并的,效果很好。但我想嵌入一个带有列切换器的图表,该切换器会随着列的添加而不断变化。
例如,假设 HPLC 数据来自仪器 A 和仪器 B。每列代表一个单独的样本,随着时间的推移,会添加更多样本。我想在最终数据表中为“A”样本创建一个简单的 XY 图表,这样随着更多列的添加,列切换器也会随之增大。(B 和 C 也类似,如果稍后添加第三个仪器)。

在将数据与 B 合并之前,我已经从 A 表创建了一个变量,但是如何传递列表(或对其进行评估)以便最终表识别变量或具有明确的列名?
A_columns = dt_A <<GET column="" names=""></GET><BR />//Merge A and B based on time column<BR /><BR />Final_Table =dt_B << Update(<BR />With(dt_A)),<BR />Match Columns( :Time = :Time)<BR />);<BR />Final_Table <<NEW script=""></NEW>Graph Builder(<BR />Size( 546, 565 ),<BR />Show Control Panel( 0 ),<BR />Variables( X( :Time ), Y( A_columns[1] ) ),<BR />Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),<BR />Column Switcher( A_columns[1], A_columns)<BR />);
当我从最终表中获取列的列表时,这似乎运行良好,但尝试使用从另一个表创建的变量会导致问题。
您是否总是希望使用列切换器中除第一列(:时间)之外的所有内容?
在这种情况下是的 - 始终是第一列,并且始终具有相同的名称。
在这种情况下,我考虑在表脚本中动态构建列表
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
table_script_expr = Expr(
cols = Current Data Table() << Get Column Names();
Remove From(cols, 1); // drop first column
gb = Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:lot_id), Y(Eval(cols[1]))),
Elements(Points(X, Y, Legend(3)))
);
gb << Column Switcher(
cols[1],
Remove(cols, 1)
)
);
Eval(EvalExpr(
dt << New Script("Graph",
Expr(NameExpr(table_script_expr))
);
));
如果您仅创建图表并将其保存为脚本,则可以避免评估(我经常使用这个“技巧”)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
cols = dt << Get Column Names();
Remove From(cols, 1); // drop first column
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:lot_id), Y(Eval(cols[1]))),
Elements(Points(X, Y, Legend(3))),
Column Switcher(
cols[1],
Remove(cols, 1)
),
Invisible
);
gb << Save Script to Data Table("Graph"); // this will remove the need for evaluation
wait(0);
gb << close window;
如果你想评估
// If you wish to evaluate, this should work even though the script will look a bit weird due to lack of ":" in columns
// If it doesn't you for some reason, you will have to build the list in a bit different manner for evaluation
Eval(EvalExpr(
dt << New Script("Graph2",
Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:lot_id), Y(Expr(cols[1]))),
Elements(Points(X, Y, Legend(3))),
Column Switcher(
Expr(cols[1]),
Expr(Remove(cols, 1))
)
)
)
));