Advice for Chart colors

Hey community!

We are currently implementing some dashboards in our apps, and we are struggling with the chart colors as we can’t find any way of overriding them.

My understanding is that they are determined by the theme colors, and our theme results in some very bright and dark colors at the same time, which makes it really difficult to ensure sufficient contrast. We have worked our way around this by using a grey background, but this is not ideal either as you can see with this example graph:

This does not scale very well either, as grey is also one of the chart colors that will eventually appear as more datasets are added. I know we can control chart color through enums, but we need to use the user object (as well as other object) as the dataset property, and would prefer not to mirror those objects into an enum :stuck_out_tongue:

Is there anyone in the community who have some good suggestions as to how we can handle the chart colors in a scalable way?

As usual, a workaround presents itself right after posting the question. If anyone in the future have the same issue I managed to solve it by:

  1. Add an enum in the data model and assign a lot of colors to it

  2. Add a run time property to the dataset object, and set type to this enum:

  3. Set this as the color value in the chart. The chart will then pick each color in the order defined by the enum, even if none of the records have been assigned a value.

Would love to know if anyone have found a better solution? :slight_smile:

2 Likes