Chart colors not consistent

Hi all! New to Retool and the community so forgive me for such a basic question.

  • Goal: I need colors to be consistent across charts.

  • Details: I have a dashboard that I recently built to assist in reporting various metrics. I have set the colors of the charts for one customer but when I select a different customer, the colors in the charts will reset to random colors even though it's the same exact data being shown. Ideally, I could somehow hardcode these colors so no matter the customer that is chosen, the charts will be consistent to keep with our branding. For example, Value A will always be 335AF1, Value B will always be A8F4FF, etc.

I appreciate the help and happy to share screenshots if needed!

Hi Kevin, welcome!

Without seeing your exact setup, I suspect this is due to something I encountered recently when attempting to use a "Manual" Color selection method: the underlying data-source object passed into the chart with labels and values fields likely has inconsistent ordering, despite being otherwise consistent from entry to entry.

Screenshot 2025-02-25 at 12.50.06 PM

I solved this using a Javascript Map object to power my chart's labels & values, as it guarantees key order. This StackOverflow answer helped put me on the right path.

While this worked, it would be nice if Retool offered a simpler way to map the same keys/labels to the same colors consistently instead of it being a toss-up based on key ordering.

1 Like

I agree with @dguzzo!

Here's a post I made previously with an example app. Let me know if you have questions.

As I mentioned there, in the near future we’ll have a ton more preset chart types and that you’ll be able to do this in the UI soon! :slight_smile: