question

Claire Krupp avatar image
0 Likes"
Claire Krupp asked Claire Krupp commented

Using Color Pallette for State Charts

I want to set up a standard list of colors for all my State Charts. It really bugs me that two charts next to each-other can have a totally different set of colors for "idle" or "processing" etc., and the only way I can find to change colors is to laboriously go into every color on every chart and change it manually.

I am using Color Pallettes for colors on other charts, e.g. Milestone charts, but I don't see any way to choose a color pallette for the standard State Chart templates.

Does anyone know how to do it?

Thanks!

FlexSim 21.1.4
flexsim 21.1.4state chartcolor palette
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Claire Krupp commented

In the 21.2 Beta the color tab was added to the state chart template, allowing you to use palettes the same way as in other charts.

In 21.1 you can still make the chart use a custom palette by assigning it to the "palette" node in the charts variables in the tree. Insert the name of the chart and palette and run the following code in the script window.

string chartName = "<Name of the chart>";
string paletteName = "<Name of the palette>";

treenode chartPalette = Model.find("/Tools/Statistics/" + chartName + ">variables/palette");
treenode statePalette = Model.find("/Tools/ColorPalettes/" + paletteName);
chartPalette.value = statePalette;

This will take priority over the internal palette of the chart.

The custom palette should be formatted like in the picture; the order of the states does not matter, states that are missing from the palette will be filled in automatically the first time the chart is populated.

Note that the properties of the chart still shows the internal palette, but the colors used are the custom ones.

customstatepalette.png


Addendum: I also tried overwriting the color values of the internal palette via code, but ran into issues with the alpha value staying at/resetting back to the default value. This can be circumvented by having the properties open when assigning the new colors and clicking on each color after running the code to properly update it. As this would still be a lot of work if you have a lot of charts the method above seems to be the easier one.


· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Claire Krupp avatar image Claire Krupp commented ·
Thank you @Felix Möhlmann , that doesn't look too hard!

To clarify, I only need to do this once for each chart, and then save the model and the new pallette will stay?


Looking forward to 21.2!

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Claire Krupp commented ·
Yes, in my tests the custom color palette persisted through saving and reloading.
0 Likes 0 ·
Claire Krupp avatar image Claire Krupp Felix Möhlmann commented ·
Thank you!
0 Likes 0 ·