cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lodey101
Level II

Problems with Graph update function

Hi there - I have a script that works to a certain point - It gets a list of specfic columns, assigns these to a list and then uses a combobox to let the user select which column to use for a graph creation. This works fine but the problem is now that when the graph is created it will display outside the window and also appends the new graph - i just need to update the window with the new version. 

 

See the sample script below

 

 



// Create the dialog window win = New Window("Count Analysis by EXPSORTWW_XETA", V List Box( header_text, Text Box( " " ) ), VListBox( PanelBox("Controls", HListBox( TextBox("X-axis: EXP_XETA", <<Set Font Style("Bold")), Spacer Box(size(20, 1)), TextBox("Overlay Variable:"), overlayCombo = ComboBox(magicalArray, <<Set Width(200)) ) ), PanelBox("Graph", gb_test = V List Box() // Container for the graph ) ) ); // Set change handler overlayCombo << Set Function( Function({this}, overlayVar = this << Get Selected; Show( "Selected: " || overlayVar ); // Debug updateGraph( overlayVar ); ) ); updateGraph = Function({overlayVar}, // Create new graph if variable is selected write(overlayVar); gb = expr(Graph Builder( Size( 550, 450 ), Show Control Panel( 0 ), Variables( X( :EXPSORTWW_XETA ), // Explicit column reference Overlay( Column( pc_inline, overlayVar ) ) ), Elements( Bar( X, Legend(5), Summary Statistic("N"), Bar Style("Stack") ) ) )); // Add the graph to the window gb_test << Prepend( V List Box( gb )); // Optional formatting Report( gb )[FrameBox(1)] << Background Color("Light Gray") << Transparency(0.2); ); // Initialize with first variable If( N Items( magicalArray ) > 0, overlayCombo << Select( 1 ); updateGraph( magicalArray[1] ); // Force initial graph );

Could anyone help me out and see what is wrong?

 

1 REPLY 1
jthi
Super User

Re: Problems with Graph update function

This maybe gives some ideas what you could change (remove old graph, don't mix expression and reference)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
options = {"height", "weight"};

win = New Window("Count Analysis by EXPSORTWW_XETA",
	V List Box("", Text Box(" ")),
	V List Box(
		Panel Box("Controls",
			H List Box(
				Text Box("X-axis: EXP_XETA", <<Set Font Style("Bold")),
				Spacer Box(size(20, 1)),
				Text Box("Overlay Variable:"),
				overlayCombo = Combo Box(options, <<Set Width(200))
			)
		),
		Panel Box("Graph",
			gb_test = V List Box() 
		)
	)
);

overlayCombo << Set Function(
	Function({this},
		overlayVar = this << Get Selected;
		updateGraph(overlayVar);
	)
);

updateGraph = Function({overlayVar}, 
	gb_expr = Expr(
		gb = Graph Builder(
			Size(550, 450),
			Show Control Panel(0),
			Variables(
				X(:age), 
				Overlay(Eval(overlayVar))
			),
			Elements(Bar(X, Legend(5), Summary Statistic("N"), Bar Style("Stack")))
		)
	);
	Try((gb_test << child) << Delete Box);
	gb_test << Prepend(V List Box(gb_expr));

	Report(gb)[FrameBox(1)] << Background Color("Light Gray") << Transparency(0.2);
);

If(N Items(options) > 0,
	updateGraph(options[1]); 
);
-Jarmo

Recommended Articles