如何在一张图表中混合Grafana中的条形和线形 [英] How to mix bar and lines in Grafana in one chart

查看:1010
本文介绍了如何在一张图表中混合Grafana中的条形和线形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个图形中将一个数据系列显示为条形,将另一个数据系列显示为线形,就像在以下内容的最后注释中使用的那样:

解决方案

简短答案:



(仅)不能通过手工操作使用Grafana UI。



长答案:



<据我所知,使用UI开关无法做到这一点。您将必须使用可视化配置下方的别名或正则表达式字段。



准备数据



开始之前,请确保查询A和B检索到实际数据。您不会看到您的数据,并且会困惑为什么它们不显示。



为别名添加字段和值



选择了要显示的正确数据后,只需在图形的可视化部分的别名或正则表达式字段中添加以下内容:


  1. 添加2个替代,对于每个要使用添加系列替代按钮显示的值,一个。

  2. 添加 Bars:false选项标志

  3. 请确保为条形使用完全相反的值( Bars:true和 Lines:false )

  4. 在图形的右侧添加一个 Y轴:2。

  5. 您可以为要放在顶部的值添加 Z-index:3(我在行中添加了此选项,以确保它始终在条形图的顶部)。



享受



您现在应该拥有一个不错的gr aph包含两种类型的数据和可视化;像这样的东西:




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

解决方案

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:

这篇关于如何在一张图表中混合Grafana中的条形和线形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆