Create Graph with Static Range

This is my dashboard. I want the 3 graphs at the top (temp/humidity, gauge, gauge), and the bottom left graph (weight) to honor the time range selected in the upper right. This works fine.

I also want the graph labeled ‘A’ (Beehive Weight (7d)) to ignore the time range and always show the previous 7 days aggregate. I can’t seem to get this working.

This is the definition of graph ‘A’:

from(bucket: "beehive")
  |> range(start: -7d)
  |> filter(fn: (r) => r["_measurement"] == "weight")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
  |> yield(name: "weight")

No matter what, graph ‘A’ keeps scaling to the time range selected. How do I get this to be ignored for this specific graph?

Hi @jackt

Try changing the range in your query to this:

from(bucket: "beehive")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)

and then change the Query Options to this:

Doing the above will override (for that panel only) the time selector:

1 Like

Hi @grant2,
Thanks! It works. Can you explain how the “relative time” field and range(start: v.timeRangeStart) relate when you do this?

Hi @jackt

Glad it worked.

I think you already know this, but the way Grafana works is that you choose the time-range at the top of the screen, and then the visualizations use that time-range. With Flux queries, you assign the variables v.timeRangeStart and v.timeRangeEnd to be used in the chosen time picker range (in the top-right corner of the dashboard), like this:

from(bucket: "beehive")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)

Relative time (as explained here) is a setting that overrides the time picker range for individual panels, which causes them to be different than what is selected in the dashboard time picker.

Ahh. I never read that part on Relative time, and thus didn’t realize it was an override to the standard range selector. Thank you for the explanation.