How can I create a column switcher in a final merged data table from a list variable created in one of the source tables?I have two data sources that being updated on a regular basis, resulting in new columns. These are are merged via JSL scripting which works well but, I'd like to embed a graph with a column switcher that grows as more columns are added.
For example, say HPLC data comes from Instrument A and Instrument B. Each column is a separate sample, with more samples being added over time. I'd like to create a simple XY chart in the final data table for my 'A' samples, so that as more columns are added, the column switcher grows as well. (Similar with B and even C, if a third instrument is added later).

I've created a variable from the A table before I merge the data with B, but how can I pass the list (or evaluate it ) so that the final table recognizes the variable or has explicit column names?
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 />);
This seems to work well when I obtain a list of columns from the final table, but trying to use a variable created from another table is causing issues.
Automation and ScriptingData Exploration and VisualizationWindowsRe: How can I create a column switcher in a final merged data table from a list variable created in one of the source tables?Do you always wish to use all expect for the first column (:Time) in the column switcher?
Re: How can I create a column switcher in a final merged data table from a list variable created in one of the source tables?In this case yes - always the first column which will always have the same name.
Re: How can I create a column switcher in a final merged data table from a list variable created in one of the source tables?In that case I consider building the column list dynamically within the table script
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))
);
));
You can avoid evaluation if you just create the graph and save that as script (I use this "trick" quite often)
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;
and if you wish to evaluate
// 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))
)
)
)
));
Re: How can I create a column switcher in a final merged data table from a list variable created in one of the source tables?Thank you!