Charts, show difference between two series?

I’m trying to figur out if it is possible to chart the difference between two series. I have two series with temperatur that I want to compare by having one series subtracted from the other, and show the result as a singel series/line.

I have looked at Apache Echarts examples Examples - Apache ECharts but can’t se if it is possible.

Anyone that have any insight?

I’ve no idea if it’s possible to do it in the chart like that. I suspect it’s not as I’m not certain even special purpose graphing services like Grafana can handle that.

However, you can create a new Item and a rule that subtracts the one value from the other when one of them changes. Persist that Item and add it to the chart.

Some databases like InfluxDB can let you set up standing queries and you might be able to create the raw data that way, but you’d still need to tie it to an Item to display.

At least before Grafana couldn’t do it, at least not as a line. You could stack the second series inverted and cloud somewhat get the result.

Yea that’s one way of course, but I don’t like to collect more data then needed.

In RRDtool it is possible. I used it in my previous setup with OH2, and custom logging. I like Main UI OH3 with the graphic UI to configure the charts but lack some possibilities.

If what you’re looking after is the ability to compare e.g. the current day’s measurements with the previous day, that at least is possible.

Check for example the Comparison tab of https://demo.openhab.org/page/chart_tabs

You can have a look at https://demo.openhab.org/settings/pages/chart/chart_example, especially the Code tab (provided you’re logged in) to figure out how it’s done.

You can define multiple series in a chart:

  series:
    - component: oh-aggregate-series
      config:
        name: Living Room (Day Before)
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: line
        item: Temperature_GF_Living
        dimension1: hour
        offsetAmount: 1
        offsetUnit: day
        smooth: true
        lineStyle:
          type: dotted
          opacity: 0.5
    - component: oh-aggregate-series
      config:
        name: Living Room (Current)
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: line
        item: Temperature_GF_Living
        dimension1: hour
        smooth: true
        lineStyle:
          width: 3
        areaStyle:
          opacity: 0.2
        markLine:
          data:
            - type: average
        markPoint:
          data:
            - type: min
              name: min
            - type: max
              name: max

The key parameters here are the offsetAmount and offsetUnit parameters. They allow you to graph a series based on the data from a previous period on the same axis as a current series.

It might not do exactly what you want - graphing a difference - but it might do the trick if that’s what you’re after.

Thanks! Yes that I know. My problem is that I have two series in sync, no timeshift.