dEx
dEx

Reputation: 71

Grafana bar width too small

i would like to know how i could get a bigger bar width in my histogram like bar graph.

This is the graph how it looks rigth now: the graph

And this is the corresponding query in flux: the query

Upvotes: 5

Views: 2584

Answers (2)

Marc
Marc

Reputation: 78

Along the lines of what @cidermole said, I was able to achieve consistent and reasonable width bars by extending the width of my most recent window to a full window. Try adding a stop argument to your range like:

range(start: -1d, stop: date.truncate(t: experimental.addDuration(d: 1h, to: v.timeRangeStop), unit: 1h))

You'll need to import some libraries at the start of your script:

import "experimental"
import "date"

I was using Influx 2.1.1 and Grafana 8.2.4. See this post.

Upvotes: 0

cidermole
cidermole

Reputation: 6078

Encountered the same issue with Grafana 7.3.7 and InfluxDB 1.8.3.

It looks like Grafana bar width is sensitive to the last date interval in the time series (use a Table visualization to verify this).

A workaround is to use _start times instead of _stop times of the windows. One can do this by performing the transformations manually that agregateWindow() would otherwise use (these transformations are described in the docs).

You would then have:

from(bucket: "piMeter")
  |> range(start: -1d)
  |> filter(fn: (r) => (
    r._measurement == "downsampled_energy" and
    r._field == "sum_Gesamt")
  )
  |> fill(value: 0.0)
  |> window(every: 1h)
  |> sum()
  |> duplicate(column: "_start", as: "_time")
  |> window(every: inf)

Upvotes: 1

Related Questions