This will be a bit slow due to all selections happening
Names Default To Here(1);
dt = Current Data Table();
dt << show window(0);
For Each Row(dt,
dt << Clear Select;
dt << Select Rows(Row());
dt << Colors(RGB Color(Eval List({:Red, :Green, :Blue}) / 255));
);
dt << show window(1);
if more speed is required it could be made faster by selection multiple rows (all rows which have specific color at the same time) or by setting row states.
Names Default To Here(1);
dt = Current Data Table();
Summarize(dt, uniq = By(:Color), r = Min(:Red), g = Min(:Green), b = Min(:Blue));
For Each({cur_color, idx}, uniq,
dt << Select Where(:Color == cur_color);
dt << Colors(RGB Color(Eval List({r[idx], g[idx], b[idx]}) / 255));
dt << Clear Select;
);
Nice picture!
Edit:
Just came to my mind that you could also use Summary table to set the colors
Names Default To Here(1);
dt = Current Data Table();
dt_summary = dt << Summary(
Group(:Color),
Mean(:Red),
Mean(:Green),
Mean(:Blue),
Freq("None"),
Weight("None"),
statistics column name format("column")
);
For Each Row(dt_summary,
dt_summary << Select Rows(Row());
dt_summary << Colors(RGB Color(Eval List({:Red, :Green, :Blue}) / 255));
dt_summary << Clear Select;
);
Close(dt_summary, no save);
Edit2: One more option looping over the whole table but without selections
Names Default To Here(1);
dt = Current Data Table();
For Each Row(dt,
Row State(Row()) = Color State(Eval List({:Red, :Green, :Blue} / 255));
);
I couldn't figure out how to convert Color State (for example Color State(-15527920)) to number (should be 512.925536155701) so I could have built row state matrix and use << Set Row States.
-Jarmo