Change Bar Colors in a Grafana Bar Gauge Dynamically Based on a Field (No Manual Overrides)

Hi everyone,

I’m working on a Bar Gauge panel in Grafana that displays the top 10 most frequent stops. The data comes from the following SQL query :

select count(*), "machine", "Message", "type"
from union_with_active_alarms
where 
  (
     ($excl) is null or 
     "AlarmId" not in ($excl)
  ) 
group by "machine", "Message", "type"
order by count(*) desc
limit 10

The chart itself is working fine, but currently, all the bars are displayed in the same color. What I’d like to achieve is for each bar to have a unique color based on the “machine” field.

Important : I do not want to use manual overrides since I won’t know the machine names or their exact count in advance (this can change dynamically). I’m looking for a fully dynamic solution where colors are automatically assigned based on unique values in the “machine” field.

If anyone has encountered this issue or knows how to configure this, I’d greatly appreciate your input !

Thanks in advance for your help ! :blush: