I am using Grafana v8.3.2 (afb9e8e5f) on Debian 11 connected to InfluxDB 2.1.1
I want to create a graph, which always shows the solar power generation for the current day. I want the graph to always zoom onto the data available, when the solar inverter turned on, and turned off.
I am using the following flux query to get the data for today by first searching the start and end date when I have data:
starttime = from(bucket: "nodered")
|> range(start: today())
|> filter(fn: (r) => r["_measurement"] == "solar")
|> filter(fn: (r) => r["_field"] == "outputpower")
|> group()
|> first()
|> group(columns: ["_field", "_measurement"], mode:"by")
|> tableFind(fn: (key) => key._field == "outputpower")
|> getRecord(idx: 0)
endtime = from(bucket: "nodered")
|> range(start: today())
|> filter(fn: (r) => r["_measurement"] == "solar")
|> filter(fn: (r) => r["_field"] == "outputpower")
|> group()
|> last()
|> group(columns: ["_field", "_measurement"], mode:"by")
|> tableFind(fn: (key) => key._field == "outputpower")
|> getRecord(idx: 0)
from(bucket: "nodered")
|> range(start: starttime._time, stop: endtime._time)
|> filter(fn: (r) => r["_measurement"] == "solar")
|> filter(fn: (r) => r["_field"] == "outputpower")
And this is working because if I pick a 7 day period, I only see data for the current day:
But somehow I want to tell this specific panel to zoom onto this data automatically and do not use the time filter of the dashboard.
I understand that I can specify a Relative Time here:
But of course that time will depend on when I view the report. In the morning this could be just a few hours, at the end of the day, it can be up to 10 hours.
So essentially I need an option for the graph to automatically zoom onto the available data. I don’t see any such options in the graph properties.