Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mix bar and lines in Grafana in one chart

Tags:

charts

grafana

How can I display one dataseries as bar and another as a line in one graph like it is used in the last comment of: see last picture

Graph from the question linked above

like image 558
Schorsch Avatar asked Oct 27 '25 05:10

Schorsch


1 Answers

Short answer:

It's not possible (yet) using the Grafana UI, only by hand.

Long answer:

As far as I know there is no way of doing this using the UI switches; you'll have to use the use the "alias or regex" fields below the visualisation configuration.

Prepare your data

Before you start, make sure that your queries A and B retrieve actual data. You won't see your data otherwise and be confused why they're not showing.

Adding fields and values to the aliases

Once you are selecting the correct data you want to display, just add the following on the visualisation section of the graph at the 'alias or regex' fields:

  1. Add 2 overrides, one for each value you want to display using the 'Add series override' button.
  2. Add a "Bars:false" option flag and a "Lines:true" for the value you want as a line.
  3. Be sure to use the exact opposite values for your bars ("Bars:true" & "Lines:false")
  4. Add a 'Y-axis: 2' to the value you want to have on the right side of your graph.
  5. Optionally, you can add a "Z-index: 3" for the value that you want to have on top (I added this option to the line to make sure it's always drawing on top of the bars).

Enjoy

You should now have a nice graph with 2 types of data and visualisations in one; something like this:

example of a grafana graph with 2 visualisation types

like image 116
Henry van Megen Avatar answered Oct 30 '25 13:10

Henry van Megen