Randomize state timeline color by state name


I have basically the same problem to solve like Scot Minor who wrote that post on stackoverflow.

I am using Grafana v9.2.4 (64017e8ca6)

I am trying to show the active recipe the machine has loaded on a state timeline chart. In order to visually make out different recipes they should differ in color. I have (currently) 92 possible recipes that are partly nested.

The result on indicated link is exactly what I am looking for. But I am not going to manually map 92 values to a seperate color.

Any ideas how to automate the color randomization?


My first impression is that each of the 92 recipes would have a tag in the database (I use InfluxDB) and then each “block” on the State Timeline would represent a different tag value, and thus could be randomized in color.

What is your datasource and what does your query look like?

Thanks you for the quick response.

I have a timescaleDB and indeed the recepies are tagged values. The query is rather simple.

  "time" AS "time",
FROM mytable

→ no idea how this has to be set up.