names Default To Here(1);
MyGraph = Function ({yCol,xCol},{default local},
	
	vlb = VListBox(
		Graph Builder(
	Size( 1255, 981 ),
	Show Control Panel( 0 ),
	Variables(
		X( Eval(xCol) ),
		For(j = 1, j <= Min(8, N Items(yCol)), j++,
                Y( Eval(yCol[j]))  // Evaluate each yVar
            ),
		Group X( :Temperature )
	),
	Elements( Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ), Y( 6 ), Y( 7 ), Y( 8 ), Legend( 11 ) ) ),
	Local Data Filter(
		Add Filter(
			columns( :Test Stage, :Sublot, :Temperature, :Soft Bin ),
			Display( :Test Stage, N Items( 4 ) ),
			Display( :Soft Bin, N Items( 15 ) )
		)
	)
)
		);
	
	
	return(vlb);
);
dt = CurrentDatatable();
nw = NewWindow("Column Selection", <<modal,
	<<onClose(
		lstX = clbX << getItems;
		lstY = clbY << getItems;
	),
	BorderBox(top(10),bottom(10),left(10),right(10),
		VListBox(
			TextBox("Select X and Y variables"),
			HListBox(
				PanelBox("Select Columns",
					fcs = FilterColSelector()
				),
				SpacerBox(size(10,0)),
				PanelBox("Cast Selected Columns into Roles",
					HListBox(
						ButtonBox("Y,Response",
							sel = fcs << getSelected; 
							clbY << append(sel);
						),
						SpacerBox(size(6,0)),
						clbY = CollistBox(numeric,maxitems(8),minitems(1),nlines(8))
					
					),
					HListBox(
						ButtonBox("X,Variable",
							sel = fcs << getSelected; 
							clbX << append(sel);
							
						),
						SpacerBox(size(6,0)),
						clbX = CollistBox(maxitems(2),minitems(1),nlines(2))	
				
					)
				)	
			)
		) 	
	)
);
if (nw["Button"]==-1,throw());
if (Nitems(lstX)==0,throw());
if (Nitems(lstY)==0,throw());
yColName = lstY; 
xColName = lstX;
show(lstY,lstX);
NewWindow("My report",
	VListBox(
		MyGraph(yColName,xColName),
		HCenterBox(
		btn = ButtonBox("show distribution")
		)
	)
);
btn << setScript(
MyHistograms()
);