I reworked your code a bit.
1. I added in the code to change the marker size and transparency
2. You may not have noticed the following issue, however, in the new columns you were creating, the formulas had the values of dt and i in them. Those are memory variables that can possibly change. (i.e. you save the table, start up a JMP session in the future, open the data table, and the columns would cause an error, because the variables dt and i are no longer available). So I changed the code to make the formulas to have hardwired values.
Here is the code. I made a mockup data table to test the code out, so there still maybe as issue or two.
dt = Open();
col_list = dt << get column names( string );
Remove From( col_list, 1 ); // Remove time[sec] from list
cols_to_plot = {};
offset_list = {};
offset_cols = {};
// Define the graph builder commands in an expression for use by the OK button
graph_expr = Expr(
For( i = 1, i <= N Items( cols_to_plot ), i++,
new_name = cols_to_plot[i] || "-Chemical Cal";
// If used before, delete the column and then recreate it
If( Try( Column( dt, new_name ) << get name, "" ) != "",
dt << delete columns( new_name )
);
Insert Into( offset_cols, new_name );
// The variable i and the column name need to be changed to their
// static value for the column formulas to be correct
Eval(
Substitute(
Expr(
dt << New Column( new_name,
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( __cols_to_plot__ * __offset_list__ )
)
),
Expr( __cols_to_plot__ ), Parse( ":" || cols_to_plot[i] ),
Expr( __offset_list__ ), offset_list[i]
)
);
);
// Now for the graph - build a text string and then execute it
gb_text = "\[gb = graph builder(
show control panel(0),
variables(
X( :Name( "Time[sec]" ) ),]\";
elements_txt = " ),
Elements( Line( X, ";
For( i = 1, i <= N Items( cols_to_plot ), i++,
If( i == 1,
// then
gb_text = gb_text || Eval Insert( "\!N\[ Y( :Name( "^offset_cols[i]^" ) ), ]\" )
,
// else
gb_text = gb_text || Eval Insert( "\!N\[ Y( :Name( "^offset_cols[i]^" ), Position( 1 ) ),]\" )
);
elements_txt = elements_txt || Eval Insert( "Y ( ^i^ ), " );
);
// add in the marker and transparency code
elements_txt = elements_txt ||
"Legend( 7 ) ), Points( X, Y, Legend(8))),
SendToReport(
Dispatch(
{},
\!"400\!",
ScaleBox,
{Legend Model(
8,
Properties( 0, {Marker Size( 0 ), Transparency( 0 )}, Item ID( \!""
|| offset_cols[1] || "\!", 1 ) )
)}
)
)";
gb_text = gb_text || elements_txt || "); ";
Eval( Parse( gb_text ) );
);
nw = New Window( "Graph Chemicals",
Panel Box( "Select channels to graph",
Lineup Box( N Col( 2 ),
Text Box( "Column" ),
Text Box( "Chemical Cal" ),
cb1 = Check Box( "Ch1" ),
ch1_neb = Number Edit Box(),
cb2 = Check Box( "Ch2" ),
ch2_neb = Number Edit Box(),
cb3 = Check Box( "Ch3" ),
ch3_neb = Number Edit Box(),
cb4 = Check Box( "Ch4" ),
ch4_neb = Number Edit Box(),
cb5 = Check Box( "Ch5" ),
ch5_neb = Number Edit Box(),
cb6 = Check Box( "Ch6" ),
ch6_neb = Number Edit Box(),
cb7 = Check Box( "Ch7" ),
ch7_neb = Number Edit Box(),
cb8 = Check Box( "Ch8" ),
ch8_neb = Number Edit Box(),
cb9 = Check Box( "Ch9" ),
ch9_neb = Number Edit Box(),
),
),
Panel Box( "Actions",
H List Box(
okb = Button Box( "OK",
If( cb1 << get( 1 ),
Insert Into( cols_to_plot, col_list[8] );
offset_value = ch1_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb2 << get( 1 ),
Insert Into( cols_to_plot, col_list[9] );
offset_value = ch2_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb3 << get( 1 ),
Insert Into( cols_to_plot, col_list[10] );
offset_value = ch3_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb4 << get( 1 ),
Insert Into( cols_to_plot, col_list[11] );
offset_value = ch4_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb5 << get( 1 ),
Insert Into( cols_to_plot, col_list[12] );
offset_value = ch5_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb6 << get( 1 ),
Insert Into( cols_to_plot, col_list[13] );
offset_value = ch6_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb7 << get( 1 ),
Insert Into( cols_to_plot, col_list[14] );
offset_value = ch7_neb << get;
Insert Into( offset_list, offset_value );
);
If( cb8 << get( 1 ),
Insert Into( cols_to_plot, col_list[15] );
offset_value = ch8_neb << get;
Insert Into( offset_list, offset_value );
);
graph_expr;
nw << close window;
),
canb = Button Box( "Cancel", nw << close window ),
)
),
);
// Pre-check checkboxes if column exists
For( i = 1, i <= N Items( col_list ), i++,
If(
col_list[i] == "Ch1", cb1 << set( 1, 1 ),
col_list[i] == "Ch2", cb2 << set( 1, 1 ),
col_list[i] == "Ch3", cb3 << set( 1, 1 ),
col_list[i] == "Ch4", cb4 << set( 1, 1 ),
col_list[i] == "Ch5", cb5 << set( 1, 1 ),
col_list[i] == "Ch6", cb6 << set( 1, 1 ),
col_list[i] == "Ch7", cb7 << set( 1, 1 ),
col_list[i] == "Ch8", cb8 << set( 1, 1 ),
col_list[i] == "Ch9", cb9 << set( 1, 1 ),
)
);
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Name( "Time[sec]" ) ), Y( :Name( "CH2-Offset" ) ) ),
Elements( Line( X, Y, Legend( 7 ) ), Points( X, Y, Legend( 8 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 8, Properties( 0, {Marker Size( 0 )}, Item ID( "CH2-Offset", 1 ) ) )}
)
)
);
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Name( "Time[sec]" ) ), Y( :Name( "CH2-Offset" ) ) ),
Elements( Line( X, Y, Legend( 7 ) ), Points( X, Y, Legend( 8 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
8,
Properties( 0, {Marker Size( 0 ), Transparency( 0 )}, Item ID( "^offset_cols[i]^", 1 ) )
)}
)
)
);
Jim