Changing the color of a lable?

I am using the Timeline addon (part of the Chart addon now) to create graphs. I assign a color to the each line in the graph, and I have created CSS entries in my theme.scss file so I can print some legend info about each line in the color of the corresponding line. All that works fine.

I have recently added a ColorPicker to the page so the user can change the color of any line in the graph. This works because I can set the selected color in the Timeline object. However, unless the user selects one of my pre-defined CSS colors, I can’t set the corresponding label to the new color. Can someone show me how I can dynamically modify the color of a label without having to define millions of CSS entries? I understand a bit of how CSS works, but I am not an expert in this area - so an example would be most appreciated.




You can use Page.getCurrent().getStyles().add() to
inject CSS rules
to the page. One problem is that you can’t remove them, so after some time the page will have a lot of such rules… I could be wrong, but my guess is that it’s not a noticeable performance issue even if there are quite a of them.

I don’t know how you make your labels, but you could also use CssLayout
to color them with CSS