Two y axis in Grafana

1.8k views Asked by At

I want to have two y axis with the same x axis time. For example I have one y axis with power in kW and the other y axis with SoC in percentage % ,

This is the code that I have to plot the charging profiles with multiple graphs:

with evses as (
  Select evse_id
  from evses
  where cs_name in ($csName)
)
SELECT
  $__timeGroup(time, '2m', 0) AS time,
  max(power_in_w) AS EVSEID,
  evse_id
FROM
  (
    SELECT
      $__timeGroup(ts, '2m', 0) AS time,
      max(p_outlet_in_w) AS power_in_w,
      evse_id
    FROM
      charging_power_calculated p
      LEFT JOIN charge_operations ops on p.transaction_id = ops.transaction_id
    WHERE
      $__timeFilter(ts)
      AND p_outlet_in_w BETWEEN 0
      AND 350000
      AND ops.evse_id IN (
        Select *
        from evses
      )
    GROUP BY evse_id, time
    ORDER BY evse_id, time
  ) temp
group by time, evse_id
ORDER BY time

And for the SoC it is:

SELECT $__timeGroup(ts, '2m', 0) as time, evse_id, soc
FROM metervalue_updates 
WHERE cs_name in ($csName) AND $__timeFilter(ts) 
order by ts

The graphs looks like this for the power: enter image description here

And for the SoC: enter image description here

How can I combine these two panels in to one and have two y axis in the same panel?

1

There are 1 answers

0
markalex On

To apply two different Y-axis to your graph you need to utilize field override.

  1. Go to panel options,
  2. + Add field override
  3. select Fields returned by query,
  4. select query which produces results that you want to show on the right axis,
  5. With + Add override property add the following:
    1. Axis > Placement: Right
    2. Standard options > Unit: Misc / Percent (select either 0-100 or 0.0-1.0 depending on your situation)