Hi All,
So, I was able to find a previous discussion thread here where @ms helped another user do something similar. I was able to work off of that idea and modify it to get it to more or less work as I intend. below is the code allowing for that functionality, except for one minor "flaw".
The code allows the user to select the X, Y items to graph, and updates the graph when the Combo Boxes are changed, or when the Prev/Next buttons are pressed. So, in this regard, the code works as intended.
After making a change to plot something different, the graph builder content box swaps positions with the selection Lineup Box that contains the Combo Boxes/Button Boxes. I'd like to keep the Lineup Box that contains the options for modifying the graph at the bottom of the window and not sure how to do that.
Any suggestions on how to get this to work out are much appreciated! (code at end).
Thanks!,
DS
Starting window (with option below):
Updated window after making a change to either the X or Y Combo Boxes, or the Prev/Next buttons:
Here's the code:
Names Default To Here( 1 );
//dt = open("$sample_data\Boston Housing.jmp");//In case the file isn't already open.
dt = Data Table( "Boston Housing" );
xlist = dt << Get Column Names( String );
gb_default = Expr(
Graph builder( Show Control Panel( 0 ), Variables( X( Column( dt, 1 ) ), Y( Column( dt, 2 ) ) ), Elements( Points( X, Y, Legend( 3 ) ) ) )
);
gb_change = Expr(
Graph builder( Show Control Panel( 0 ), Variables( X( Column( dt, xcol ) ), Y( Column( dt, ycol ) ) ), Elements( Points( X, Y, Legend( 3 ) ) ) )
);
nw = New Window( "Interactive Graph",
gb = gb_default;
lbcontent = Lineup Box( N Col( 5 ),
Spacer Box( Size( 1, 0 ) ),
Text Box( "X", <<Justify Text( "Center" ) ),
Text Box( "Y", <<Justify Text( "Center" ) ),
Spacer Box( Size( 1, 0 ) ),
Spacer Box( Size( 1, 0 ) ),
Text Box( "Select Params", <<Set Font Size( 11 ) ),
xcb = Combo Box(
xlist,
<<Set( 1 ),
<<Set Function(
Function( {},
xcol = xcb << Get;
ycol = ycb << Get;
gb << delete;
nw << Append( gb = gb_change );
)
)
),
ycb = Combo Box(
xlist,
<<Set( 2 ),
<<Set Function(
Function( {},
xcol = xcb << Get;
ycol = ycb << Get;
gb << delete;
nw << Append( gb = gb_change );
)
)
),
pbb = Button Box( "Prev",
<<SetIcon( "PrevSeq" ),
<<Set Icon Location( "left" ),
<<Set Function(
Function( {},
ycb << Set( ycol - 1 );
xcol = xcb << Get;
ycol = ycb << Get;
gb << delete;
nw << Append( gb = gb_change );
)
)
),
nbb = Button Box( "Next",
<<Set Icon( "NextSeq" ),
<<Set Icon Location( "right" ),
<<Set Function(
Function( {},
ycb << Set( ycol + 1 );
xcol = xcb << Get;
ycol = ycb << Get;
gb << delete;
nw << Append( gb = gb_change );
)
)
)
);
);