How to give color to each sub category bar in Bar Chart?

  • What Grafana version and what operating system are you using?
    9.5.1

  • What are you trying to achieve?
    I want to give color to each my education_category bar that grouped in salary_category x-axis

  • How are you trying to achieve it?
    I am using bar chart, and confused how to change the color for each sub category bar. I tried using override, but the result is different.

  • What happened?
    The desired result do not produced

  • What did you expect to happen?
    I want Senior High School, College, Master and Doctorate have different color of bar chart in $40K-$60K up until > $120K category

  • Can you copy/paste the configuration(s) that you are having problems with?
    this is my query and my data

SELECT
cdh.income_category,
edb.education_level,
COUNT(*) AS count
FROM customer_data_history cdh
JOIN education_db edb
ON cdh.educationid = edb.id
WHERE cdh.income_category IN (β€˜Less than $40K’, β€˜$40K - $60K’, β€˜$60K - $80K’, β€˜$80K - $120K’, β€˜$120K +’)
AND cdh.idstatus = 2 AND cdh.gender = β€˜M’
GROUP BY cdh.income_category, edb.education_level
ORDER BY cdh.income_category, edb.education_level;

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    no

  • Did you follow any online instructions? If so, what is the URL?
    Yes, i read override, treshold, mapping but still confused
    Configure thresholds | Grafana documentation

1 Like

Welcome

Your database design approach is a bit worrisome especially

Less than $40K’, β€˜$40K - $60K’, β€˜$60K - $80K’, β€˜$80K - $120K’, β€˜$120K +
. But that is your choice.

Here is what you can try.
image

image

Thanks for the reply @yosiasz , I will try your suggestion right now.

For the salary data, you are absolutely correct. That data is a test for me as I am now currently pursuing certification for data engineering. And the designated Instructor challenge me to learn grafana for the chance working on his company.

1 Like