<?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: How to dynamically change color column in graph builder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755115#M93757</link>
    <description>&lt;P&gt;You can use column switcher for this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1715934151953.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64337i373AEF14E89CB639/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1715934151953.png" alt="jthi_0-1715934151953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1715934160141.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64338i3A8746E58CA1E282/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1715934160141.png" alt="jthi_1-1715934160141.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1715934169049.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64339iDF4DF4EE4FC4DE3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1715934169049.png" alt="jthi_2-1715934169049.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1715934177331.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64340i53C68A16C1BEA932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1715934177331.png" alt="jthi_3-1715934177331.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 08:23:12 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-05-17T08:23:12Z</dc:date>
    <item>
      <title>How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755101#M93756</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;upon creation of an Graph Builder object one can define variables as follows: Variables(X(:x), Y(:y), Color(:color))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is to change the color column dynamically by selecting specific columns from a list. How can this be achieved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 08:13:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755101#M93756</guid>
      <dc:creator>UEJ</dc:creator>
      <dc:date>2024-05-17T08:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755115#M93757</link>
      <description>&lt;P&gt;You can use column switcher for this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1715934151953.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64337i373AEF14E89CB639/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1715934151953.png" alt="jthi_0-1715934151953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1715934160141.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64338i3A8746E58CA1E282/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1715934160141.png" alt="jthi_1-1715934160141.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1715934169049.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64339iDF4DF4EE4FC4DE3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1715934169049.png" alt="jthi_2-1715934169049.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1715934177331.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64340i53C68A16C1BEA932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1715934177331.png" alt="jthi_3-1715934177331.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 08:23:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755115#M93757</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-17T08:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755116#M93758</link>
      <description>&lt;P&gt;Hi Jarmo, this is true, but obviously I have to be more precise: The column switcher would need to affect only the color column, not let's say the x or y column.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:10:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755116#M93758</guid>
      <dc:creator>UEJ</dc:creator>
      <dc:date>2024-05-17T09:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755117#M93759</link>
      <description>&lt;P&gt;Isn't that exactly what column switcher does? Only "issue" with column switcher is that you cannot have same column in multiple roles at the same time.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:15:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755117#M93759</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-17T09:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755130#M93761</link>
      <description>&lt;P&gt;&lt;SPAN&gt;'Only "issue" with column switcher is that you cannot have same column in multiple roles at the same time.': this is EXACTLY what I need, unfortunately.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:25:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755130#M93761</guid>
      <dc:creator>UEJ</dc:creator>
      <dc:date>2024-05-17T09:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755132#M93762</link>
      <description>&lt;P&gt;I did create wish list item for that &lt;LI-MESSAGE title="Add new switcher called Role Switcher" uid="755118" url="https://community.jmp.com/t5/JMP-Wish-List/Add-new-switcher-called-Role-Switcher/m-p/755118#U755118" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;. Currently I think this will require scripting solution, if it just &lt;STRONG&gt;limited to graph builder AND color role&lt;/STRONG&gt; it is bit more easy to create (I will most likely create add-in for this when I have time).&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:28:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755132#M93762</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-17T09:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755143#M93764</link>
      <description>&lt;P&gt;Here is very quick version of the script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

If(Is Empty(Current Report()),
	Throw("No open reports found");
);

cur_report = Current Report() &amp;lt;&amp;lt; XPath("//OutlineBox[@helpKey='Graph Builder']");
If(N Items(cur_report) &amp;lt; 1,
	Throw("No graph builder open");
,
	cur_report = cur_report[1] &amp;lt;&amp;lt; Get Scriptable Object;
	dt = cur_report &amp;lt;&amp;lt; Get Data Table;
);

// Find current Color role
find_role_column = Function({gb, role = "Color"}, {Default Local},
	vars = gb &amp;lt;&amp;lt; Get Variables();
	col = "";
	role_idx = 0;
	For Each({var, idx}, vars,
		role = var["Role"];
		If(role == "Color",
			col = var[1] &amp;lt;&amp;lt; get name;
			role_idx = idx;
			break();
		);
	);
	return(Eval List({col, role_idx}));
);

replace_role_column = function({gb, new_col, role = "Color"}, {Default Local},
	{colname, role_idx} = find_role_column(gb);
	gb &amp;lt;&amp;lt; inval;
	If(role_idx &amp;gt; 0,
		gb &amp;lt;&amp;lt; Remove Variable(role_idx);
	);
	Eval(EvalExpr(
		gb &amp;lt;&amp;lt; Add Variable({Expr(NameExpr(AsColumn(new_col))), Role(Expr(role))});
	));
	wait(0);
	gb &amp;lt;&amp;lt; update window;
	return(1);
);

nw = new window("demo",
	clb = Col List Box(Datatable(dt), width(250), maxSelected(1),
		&amp;lt;&amp;lt; Set Function(function({this},
			replace_role_column(cur_report, this &amp;lt;&amp;lt; get selected, "Color");
		));
	)
);
clb &amp;lt;&amp;lt; Set Items(dt &amp;lt;&amp;lt; Get Column Names("String"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Creating better one will take some time and I might have enough time during weekend to create one (it is fairly similar to my &lt;LI-MESSAGE title="Column Quick Swapper - easily change multiple Y and X-axis columns in Graph Builder" uid="724616" url="https://community.jmp.com/t5/JMP-Add-Ins/Column-Quick-Swapper-easily-change-multiple-Y-and-X-axis-columns/m-p/724616#U724616" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;)&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:44:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755143#M93764</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-17T09:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically change color column in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755145#M93765</link>
      <description>&lt;P&gt;Interesting. I think I got the bits and pieces from your script, but I will need some time to work on this next week.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 09:53:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-dynamically-change-color-column-in-graph-builder/m-p/755145#M93765</guid>
      <dc:creator>UEJ</dc:creator>
      <dc:date>2024-05-17T09:53:39Z</dc:date>
    </item>
  </channel>
</rss>

