Schorsch
Schorsch

Reputation: 147

How to mix bar and lines in Grafana in one chart

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

Upvotes: 4

Views: 11588

Answers (3)

choffa
choffa

Reputation: 51

You can do this in the new Timeseries component by selecting a field override for the relevant query.

  1. At the bottom of the sidebar, choose "+ Add Field Override" -> "Fields Returned by Query"
  2. Select the Query you want to override
  3. Select "+ Add override property" -> "Graph styles > Styles"
  4. Select the style for the query.

This will override whatever the Panel settings are for "Graph styles > Styles". This can also be used to override many other properties such as unit. See also the Grafana docs on Configure field overrides

Upvotes: 0

garlicRiso
garlicRiso

Reputation: 1

For those who were asking in the comment section, yes this isn't available in version 8, however, you can still change the time series visualization to graph(old) so you can set the alias/regex.

Upvotes: 0

Henry van Megen
Henry van Megen

Reputation: 2217

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

Upvotes: 10

Related Questions