How to dynamically change color column in graph builderHi,
upon creation of an Graph Builder object one can define variables as follows: Variables(X(:x), Y(:y), Color(:color))
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?
Thank you in advance.
Data Exploration and VisualizationRe: How to dynamically change color column in graph builderInteresting. I think I got the bits and pieces from your script, but I will need some time to work on this next week.
Re: How to dynamically change color column in graph builderHere is very quick version of the script
Names Default To Here(1);
If(Is Empty(Current Report()),
Throw("No open reports found");
);
cur_report = Current Report() << XPath("//OutlineBox[@helpKey='Graph Builder']");
If(N Items(cur_report) < 1,
Throw("No graph builder open");
,
cur_report = cur_report[1] << Get Scriptable Object;
dt = cur_report << Get Data Table;
);
// Find current Color role
find_role_column = Function({gb, role = "Color"}, {Default Local},
vars = gb << Get Variables();
col = "";
role_idx = 0;
For Each({var, idx}, vars,
role = var["Role"];
If(role == "Color",
col = var[1] << 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 << inval;
If(role_idx > 0,
gb << Remove Variable(role_idx);
);
Eval(EvalExpr(
gb << Add Variable({Expr(NameExpr(AsColumn(new_col))), Role(Expr(role))});
));
wait(0);
gb << update window;
return(1);
);
nw = new window("demo",
clb = Col List Box(Datatable(dt), width(250), maxSelected(1),
<< Set Function(function({this},
replace_role_column(cur_report, this << get selected, "Color");
));
)
);
clb << Set Items(dt << Get Column Names("String"));
Creating better one will take some time and I might have enough time during weekend to create one (it is fairly similar to my Column Quick Swapper - easily change multiple Y and X-axis columns in Graph Builder )
Re: How to dynamically change color column in graph builderI did create wish list item for that Add new switcher called Role Switcher . Currently I think this will require scripting solution, if it just limited to graph builder AND color role it is bit more easy to create (I will most likely create add-in for this when I have time).
Re: How to dynamically change color column in graph builder'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.
Re: How to dynamically change color column in graph builderIsn'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.
Re: How to dynamically change color column in graph builderHi 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.
Re: How to dynamically change color column in graph builderYou can use column switcher for this



