Threshold color for Bar Chart not working

Hi guys,

I have multiple energy meter kWh counters recorded from which i build via spread() hourly consumption values and I add them then via a transform to a total energy counter.
This works fine and the total kWh of all meters are shown correctly.

Then I tried to color all bars which are positive in green and all which are negative in red via threshold color, but for some reason it does not work.

It colors allways all in the same color, depending on the threshold value:

How can I achive that every single bar gets colored by its threashold value?

1 Like

Not sure if it has something to do with it, but I noticed that it shows all bars very thin and with a gap (as if there are other bars still active) when I hide all other bars execept of the total one.

The size of the bars only change back to normal if i activate the replace all option, even that should be that same from my understanding as if I turn all others invisible via hide in area:

It is the same when I calculate my fields without transform actions.
It does not color the bars for some reason, but it fills the regions if I chose that option.

What could be wrong that it does not change the color of the bars depending on the given threshold?

Hello, I am encountering the same issue.
I upgraded from Grafana 8.4.1 to 9.1.7 and the color schemes in all my bar charts stopped working and only show a single color.

Before (8.4.1):

After (9.1.7):

My first thought was that the whole chart got corrupted, but i created a completely new one and the issue still occurs.

Can you please show us youelr threshholds

I do not have thresholds set. I just use(d), under “Color Scheme”, “Green-Yellow-Red (by value)”

1 Like

Hi @originschnudl

Before updating Grafana, were the Threshold settings defined?

No. It was exactly like depicted above. No threshold, just a color scheme.

In the JSON Model it is like this (before and after update):

        "defaults": {
          "color": {
            "mode": "continuous-GrYlRd"
          },
          "custom": {
            "axisGridShow": true,
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "fillOpacity": 100,
            "gradientMode": "scheme",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 0,
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "mappings": [],
          "min": 10000,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "watth"
        }

Thanks for sharing more info.

I tried to reproduce it using TestDB Data source while deploying Grafana v.8.4.1 on Docker but not able to reproduce it.

In my case I selected the CSV File from the TestDB Data source and while using Bar chart and it shows the green color as default (as based on the threshold value).

I will suggest that if you can reproduce it by creating a test env. where version 8.4.1 is running and after update to 9.1.7 then please share the step by step instructions (will also prefer to use Data source like a TestDB or a CSV file as easy to reproduce).

Then share it with us.

If you cannot able to reproduce the issue with TestDB and only happens in your selected Data source then share a detailed screencast.

Thank you,
Usman

I am facing the same issue. I have Grafana v10 and my Bar chart doesn’t update colours based on the threshold values.

Thanks.

Now, after I tried I also cannot define any color in the bar chart bars even setting up different threshold values.

I have reported this to our Engineers. Here is the link to the issue:

Please subscribe to it so as to remain up to date and also add your comments if you feel that some information is missing.

2 Likes

This is why I did not fully upgrade to v10
I ran into wsy too many issues

I just add the info that i am running Grafana in Docker

i dont think this issue exists in the most recent version of Grafana. make sure you have the correct options set. see my reply here:

2 Likes

You are a genius! You fixed my issue! Thank you!

That’s interesting, at one of my bar charts I have Gradient mode set to None, but it is working:

On the other one it does not work with None

and I had to set it to Schema to get it working.

So, what’s the difference between both?

So, what’s the difference between both?

might be a bug in when we should apply it. i would not expect it to work with None.

if you open an issue and attach Send a panel to Grafana Labs support | Grafana documentation we can take a look at the exact cause.