BookmarkSubscribeRSS Feed
Highlighted
DamionSparhawk

Contributor

Joined:

Jul 13, 2018

Re: Select issue

Trying a slightly different tact, I got rid of the part of the script that adjusts the size and appearance of the dots and simply changed those settings in my preferences for now, I realized that the script I had prior to that was not actually putting the points on to the additional graphs (more than the first) so I came up with this one. However it is doing some rather bizarre thing where it plots out a second graph of the first line completely on it's own in smooth...

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 <= nitems(cols_to_plot), i++,
		new_name = cols_to_plot[i] || "-Chemical Cal";
		insertinto(offset_cols, new_name);
		dt << new column(new_name, Numeric, "Continuous", Format( "Best", 12 ),
			Formula( as column(dt, cols_to_plot[i]) * 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^ ), " );
	);

	elements_txt = elements_txt ||
	"Legend( 7 ) ), 
	Points( 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^ ), " );
	);

	elements_txt = elements_txt || 
	"Legend(8))

	)";
	gb_text = gb_text || elements_txt || "); ";
	Eval( Parse( gb_text ) );
	
);


	

nw = new window("Graph Chemicals",
	panel box("Select channels to graph",
		lineup box(ncol(2), 
			text box("Column"), text box("Chemical Cal"),
			cb1 = checkbox("Ch1"), ch1_neb = number edit box(),
			cb2 = checkbox("Ch2"), ch2_neb = number edit box(),
			cb3 = checkbox("Ch3"), ch3_neb = number edit box(),
			cb4 = checkbox("Ch4"), ch4_neb = number edit box(),
			cb5 = checkbox("Ch5"), ch5_neb = number edit box(),
			cb6 = checkbox("Ch6"), ch6_neb = number edit box(),
			cb7 = checkbox("Ch7"), ch7_neb = number edit box(),
			cb8 = checkbox("Ch8"), ch8_neb = number edit box(),
			cb9 = checkbox("Ch9"), ch9_neb = number edit box(),
		),
	),
	panelbox("Actions",
		hlistbox(
			okb  = button box("OK",
				if (cb1 << get(1), 
					insertinto(cols_to_plot, col_list[8]);
					offset_value = ch1_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb2 << get(1), 
					insertinto(cols_to_plot, col_list[9]);
					offset_value = ch2_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb3 << get(1), 
					insertinto(cols_to_plot, col_list[10]);
					offset_value = ch3_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb4 << get(1), 
					insertinto(cols_to_plot, col_list[11]);
					offset_value = ch4_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb5 << get(1), 
					insertinto(cols_to_plot, col_list[12]);
					offset_value = ch5_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb6 << get(1), 
					insertinto(cols_to_plot, col_list[13]);
					offset_value = ch6_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb7 << get(1), 
					insertinto(cols_to_plot, col_list[14]);
					offset_value = ch7_neb << get;
					insertinto(offset_list, offset_value);
				);
				if (cb8 << get(1), 
					insertinto(cols_to_plot, col_list[15]);
					offset_value = ch8_neb << get;
					insertinto(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 <= nitems(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),
	);
);

smoother.PNG

 

I saved the script for this, and then the script for how I want it to look (just the top graph) but I am not certain what parts I need to edit to get rid of the eroneous graph...

//This is what it graphs
Graph Builder(
	Show Control Panel( 0 ),
	Variables(
		X( :Name( "Time[sec]" ) ),
		Y( :Name( "CH2-Chemical Cal" ) ),
		Y( :Name( "CH4-Chemical Cal" ), Position( 1 ) ),
		Y( :Name( "CH4-Chemical Cal" ), Position( 1 ) ),
		Y( :Name( "CH2-Chemical Cal" ) )
	),
	Elements(
		Position( 1, 1 ),
		Line( X, Y( 1 ), Y( 2 ), Legend( 7 ) ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 8 ) )
	),
	Elements(
		Position( 1, 2 ),
		Points( X, Y, Legend( 11 ) ),
		Smoother( X, Y, Legend( 12 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"CH2-Chemical Cal",
			ScaleBox( 2 ),
			{Min( -125.45871559633 ), Max( 1724.54128440367 ), Inc( 100 ),
			Minor Ticks( 1 )}
		)
	)
);
// This is what I want it to graph
Graph Builder(
	Show Control Panel( 0 ),
	Variables(
		X( :Name( "Time[sec]" ) ),
		Y( :Name( "CH2-Chemical Cal" ) ),
		Y( :Name( "CH4-Chemical Cal" ), Position( 1 ) ),
		Y( :Name( "CH4-Chemical Cal" ), Position( 1 ) )
	),
	Elements(
		Line( X, Y( 1 ), Y( 2 ), Legend( 7 ) ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 8 ) )
	)
);