Bar and line chart with different time aggregations

I’m trying to setup a time series graph that has both a bar chart showing the total water usage per hour, as well as a line chart showing the flow rate over time (using TimeScaleDB/Postgres) if I aggregate both of these at 1 hour, I get a chart like this - which is sorta what I’m after but i’d like to aggegate the line chart by 1 min so it shows more information:

(yellow = total, green = flow rate)

1

If I change aggregation for the line to 1 min like I want, then this is the result, where now the bar graph only covers 1 minute also with large gaps in between

2

Here are my queries for each:

Flow Rate:

WITH t as (
    SELECT
        time_bucket('1 minute'::interval, ts) as time,
        time_weight('LOCF', ts, val_real) AS tw -- get a time weight summary
    FROM historian
    WHERE $__timeFilter(ts) AND tag = 'FIT_1_FLOW_RATE'
    GROUP BY time_bucket('1 minute'::interval, ts)
)
SELECT
    time,
    average(tw) AS flow_rate -- extract the average from the time weight summary
FROM t;

Total Flow:

WITH t as (
    SELECT
        time_bucket('1 hour'::interval, ts) as time,
        time_weight('LOCF', ts, val_real) AS tw -- get a time weight summary
    FROM historian
    WHERE $__timeFilter(ts) AND tag = 'FIT_1_FLOW_RATE'
    GROUP BY time_bucket('1 hour'::interval, ts)
)
SELECT
    time,
    average(tw)*60 AS flow_total -- extract the average from the time weight summary
FROM t;

Is this something grafana can do? I can’t seem to find any way to get these to show together like I’m after.

Hi @jsteinm1

I’m not sure I understand exactly what you’re after here, but what does your second graph look like when you are zoomed in over just one of those spikes?q

I’m trying to construct a graph that has 1 hour wide (yellow) bars like the top image, but has the 1 minute granular line graph (green) like the bottom image. If I set my query with

GROUP BY time_bucket('1 minute'::interval, ts)

on the green line graph to get that granular view, then my yellow bars are very narrow as if they are for 1 minute of data, even though they represent a totalized flow for the entire hour.

EDIT: Here is a zoomed in graph of the bottom image. The yellow bar should represent the entire hour from 0900 to 1000, but as graphed it would appear to only represent 0900 to 0901

I don’t know if you can set two queries to two different timescales inside the same panel. You can have multiple y axes (more than 2) but only one x-axis.