<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problems with Graph update function in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Problems-with-Graph-update-function/m-p/871906#M103581</link>
    <description>&lt;P&gt;This maybe gives some ideas what you could change (remove old graph, don't mix expression and reference)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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", &amp;lt;&amp;lt;Set Font Style("Bold")),
				Spacer Box(size(20, 1)),
				Text Box("Overlay Variable:"),
				overlayCombo = Combo Box(options, &amp;lt;&amp;lt;Set Width(200))
			)
		),
		Panel Box("Graph",
			gb_test = V List Box() 
		)
	)
);

overlayCombo &amp;lt;&amp;lt; Set Function(
	Function({this},
		overlayVar = this &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; Delete Box);
	gb_test &amp;lt;&amp;lt; Prepend(V List Box(gb_expr));

	Report(gb)[FrameBox(1)] &amp;lt;&amp;lt; Background Color("Light Gray") &amp;lt;&amp;lt; Transparency(0.2);
);

If(N Items(options) &amp;gt; 0,
	updateGraph(options[1]); 
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 May 2025 04:53:07 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-05-06T04:53:07Z</dc:date>
    <item>
      <title>Problems with Graph update function</title>
      <link>https://community.jmp.com/t5/Discussions/Problems-with-Graph-update-function/m-p/871778#M103579</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the sample script below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;BR /&gt;&lt;BR /&gt;// 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", &amp;lt;&amp;lt;Set Font Style("Bold")),
                Spacer Box(size(20, 1)),
                TextBox("Overlay Variable:"),
                overlayCombo = ComboBox(magicalArray, &amp;lt;&amp;lt;Set Width(200))
            )
        ),
        PanelBox("Graph",
            gb_test = V List Box() // Container for the graph
        )
    )
);

// Set change handler
overlayCombo &amp;lt;&amp;lt; Set Function(
    Function({this},
        overlayVar = this &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; Prepend( V List Box( gb ));
            
            // Optional formatting
            Report( gb )[FrameBox(1)] &amp;lt;&amp;lt; 
                Background Color("Light Gray") &amp;lt;&amp;lt; 
                Transparency(0.2);
);

// Initialize with first variable
If( N Items( magicalArray ) &amp;gt; 0,
    overlayCombo &amp;lt;&amp;lt; Select( 1 );
    updateGraph( magicalArray[1] ); // Force initial graph
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could anyone help me out and see what is wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 21:18:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problems-with-Graph-update-function/m-p/871778#M103579</guid>
      <dc:creator>lodey101</dc:creator>
      <dc:date>2025-05-05T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Graph update function</title>
      <link>https://community.jmp.com/t5/Discussions/Problems-with-Graph-update-function/m-p/871906#M103581</link>
      <description>&lt;P&gt;This maybe gives some ideas what you could change (remove old graph, don't mix expression and reference)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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", &amp;lt;&amp;lt;Set Font Style("Bold")),
				Spacer Box(size(20, 1)),
				Text Box("Overlay Variable:"),
				overlayCombo = Combo Box(options, &amp;lt;&amp;lt;Set Width(200))
			)
		),
		Panel Box("Graph",
			gb_test = V List Box() 
		)
	)
);

overlayCombo &amp;lt;&amp;lt; Set Function(
	Function({this},
		overlayVar = this &amp;lt;&amp;lt; 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 &amp;lt;&amp;lt; child) &amp;lt;&amp;lt; Delete Box);
	gb_test &amp;lt;&amp;lt; Prepend(V List Box(gb_expr));

	Report(gb)[FrameBox(1)] &amp;lt;&amp;lt; Background Color("Light Gray") &amp;lt;&amp;lt; Transparency(0.2);
);

If(N Items(options) &amp;gt; 0,
	updateGraph(options[1]); 
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 May 2025 04:53:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problems-with-Graph-update-function/m-p/871906#M103581</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-05-06T04:53:07Z</dc:date>
    </item>
  </channel>
</rss>

