Stacking groups within the bar chart

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

  • What are you trying to achieve?
    In a Bar Graph I am displaying data from a PV system grouped by days ofver the course of a month.
    Some Bars represent incoming energy from different sources (PV and public network), others show consumption (Washing machine, Dryer, Lights, whatever).

I would like to have the bars stack in two groups so there is one bar that includes all sources stacked and one bar that show consumption by the individual devices for each day of the month.

  • How are you trying to achieve it?
    I was hoping there would be a similar mechanism to the Time Series Panel where stacking groups A.B,C can be applied in override properties, but that is not the case (yet?)

If this feature is not possible at the moment I think it would make a great addition to the bar graph panel



What is your datasource and could you please provide sample data?

My datasource is influxDB.
I’m not sure how I can provide sample data so at first here are some screenshots of the panel I am working on at the moment:

There is a lot going on here, so I will try to narrow it down a bit:
Some data is based on simple counters (energy meters) that always increase so I used the queries shown in the picture to extract the difference of the value from one day to the next to get the amount that was generated/consumed for each day.

As you can see in the graph having many values to show for each day of the month results in narrow individual bars which looks a little confusing.

since some of these bars represent incoming energy while others represent outgoing energy it would be nice to group and stack them. So for example I might want to stack “Netzbezug” (Energy received from the network) on top of “PV production” (Energy produced by the solar panels) to form a bar that shows all incoming energy.
Another stack could be “Verbrauch” (Energy consumed) and “Einspeisung” (Energy overhead that was returned to the public network).
In this special case the stack of incoming energy would be the same height as the stack of consumed/exported energy.


Heres a little drawing of what I would hope the result to look like.
I think a good solution from a usability perspective would be to not only allow stacking to be turned on or off (or 100%) but allow to assign stacking groups to queries.
So in this example I would assign Netzbezug and PV Produktion to Stacking Group A and Verbrauch and Einspeisung to Stacking Group B and the result would look like this:



+1. I really want to see that feature implemented!

1 Like

@janfribogar This is possible. What is your datasource? Please provide your data sample as csv

2022-11-08 11:09:00,temp,33
2022-11-08  11:09:00,pressure,133


What I want to achieve is what @Ierwin said. I have this queries:
SELECT sum(“value”) FROM “solar_KWh” WHERE $timeFilter GROUP BY time($__interval) fill(null) tz(‘Europe/Madrid’)
SELECT sum(“value”) FROM “export_KWh” WHERE $timeFilter GROUP BY time($__interval) fill(null) tz(‘Europe/Madrid’)
SELECT sum(“value”) FROM “load_KWh” WHERE $timeFilter GROUP BY time($__interval) fill(null) tz(‘Europe/Madrid’)
SELECT sum(“value”) FROM “import_KWh” WHERE $timeFilter GROUP BY time($__interval) fill(null) tz(‘Europe/Madrid’)
SELECT sum(“value”) FROM “load_auto_KWh” WHERE $timeFilter GROUP BY time($__interval) fill(null) tz(‘Europe/Madrid’)


I want to stack A and B in one bar and C, D and E in another bar.

1 Like

Hi all,

I was looking for this feature for a while. It would be great to have this implemented or solved somehow :+1:


@yosiasz do you have any update on this topic? Thank you for your support :slight_smile:

You can use “Stacking: normal” and “Bar alignment: after” as default for the panel and override this for all PV-earnings with “Bar alignment: before”. This way the consumption is on one stacked bar and the PV-earnings on the other next to it.

I have not yet figured out how to make the bars slim so they do not overlap with the bar for the next day.


Thank you @Lythie !

You are using the time series visualization for generating the bar chart. I was able to reproduce your solution and to achieve the plot you showed. As you said the downside of this is an overlap of the bars of the chart.

I am looking for a solution right in the bar chart visualization. The bar chart visualization is the one I would naturally use to generate a bar chart.

I would also really like to see stacked bar graphs being natively supported in Grafana.

Although not the best example, AWS’ Cost Explorer demonstrates what I would like best, having a breakdown of costs by month, in a stacked bar graph:

It’s not exactly what was asked for, but if you decide to use after and center as bar alignments it comes pretty close:

Hi there,
long time gone, did anyone catch up this topic? I’m very interessted in getting such grouped stacks.
Best Regard, Jürgen


I created a feature request in GitHub for this: Stacking groups within the bar chart · Issue #86868 · grafana/grafana · GitHub .

If you are interested in this feature, please support the feature request :slight_smile: .

1 Like