I am producing a time-series chart showing the power input to my inverter. I am running version 13.1 of Grafrana and pulling the data from a Postgres database fed by Homey. The native data is at 15 minute intervals and the graph showing that is just fine.
I’ve created my own variable, called Interval (15m,30m,1h,3h,6h,12h,1d,7d,14d,30d) and all the data queries refer to this, for example:
SELECT time_bucket('$Interval', time) AS time,
AVG(value) AS "Solar Generation"
FROM variables
WHERE variable_id = 'b7c74837-4f8f-4c41-b229-29e20c43cc23'
AND time >= $__timeFrom()::timestamptz
AND time < $__timeTo()::timestamptz
GROUP BY time
ORDER BY time;
The problem occurs when I select any other interval, say 30 minutes, and then the bars just show as vertical lines.
I also have a chart showing the output from the inverter and perversely this displays the opposite behaviour. When the 15 minute interval is selected, I get vertical lines and all other intervals correctly show as bars.
| Bar width factor | Set the width of the bar relative to minimum space between data points. A factor of 0.5 means that the bars take up half of the available space between data points. A factor of 1.0 means that the bars take up all available space.
Since the Bar width factor is already set to 0.8, I’d check what the query is actually returning for the different interval values.
In Query inspector compare the timestamps returned for Interval=15m and Interval=30m.
For 30m, I’d expect the time_bucket() values to be spaced 30 minutes apart .
If the result still contains 15-minute timestamps or duplicate timestamps, Grafana will calculate the bar spacing from those points, which can make the bars render as thin lines.
Could you also share →
the panel JSON (or Time series display options),
whether the panel has Stack series enabled,
and the raw query results for one of the affected queries with Interval=30m?
Thank you for your reply; very informative. Unfortunately I cannot get on the forum this morning; hence the email.
Looking at the data returned by the query in Query Inspector, I can see that for the 30 minute interval I get 2 values at each interval, for 1 hour I get 4. This surprised me because I thought the GROUP BY term in SQL would combine those into 1 value (taking the average). I’ve since made all sort of changes to my SQL but I just can’t get it to work as I would expect. Futhermore, I understand that the date_bin function in PostgreSQL works similarly to time_bucket but I cannot get that to function at all.
However as I mentioned, the queries for the ‘From Inverter’ chart perform similarly but the Charts produced are very different, with 15 minutes shown as lines and 30 minutes as bars. I am totally confused.
I have attached the JSON download and the query results for your perusal. You will see that I have Stack series enabled. Incidently, I tried reducing the graph to just one data set (Solar Generation) and the same behaviour was observed.
Thanks for your help.
Ron Wagstaff
(Attachment Power into Inverter-data-2026-07-10 07_44_27.csv is missing)
From the panel JSON you sent →
this looks like a GROUP BY name collision, not a display setting. Your table has a real column called time, and you also alias time_bucket(...) AS time.
From the official docs → In case of ambiguity, a GROUP BY name will be interpreted as an input column name rather than an output column name. (ORDER BY does the opposite → it prefers the output alias.)
So GROUP BY time is grouping by the time column (15-min rows), not by your bucketed alias → That would explain why your exported CSV shows two unaggregated rows per 30-minute label (e.g. two rows both timestamped 00:00:00, two both timestamped 00:30:00, etc.) instead of one averaged value.
Fix → reference the bucket by position instead of by the clashing name:
sql
SELECT time_bucket('$Interval', time) AS time,
AVG(value) AS "Solar Generation"
FROM variables
WHERE variable_id = 'b7c74837-4f8f-4c41-b229-29e20c43cc23'
AND time >= $__timeFrom()::timestamptz
AND time < $__timeTo()::timestamptz
GROUP BY 1
ORDER BY 1;
Apply the same GROUP BY 1 / ORDER BY 1 to all three queries in the panel (Solar, Discharge, Import) → they all have the identical pattern.
After the fix, Query Inspector should show exactly one row per bucket → that will confirm it.