Page 1 of 1

Graph with data with same unit but different magnitude

Posted: Monday 10 October 2022 18:02
by brjhaverkamp
I have a question for which I hope someone already got the solution. It feels like a silly problem.
I am trying to plot my daily gas usage as well as my cumulative year usage in one plot.
However my gas usage varies from 0 to 10 m3 per day
while my cumulative goes up to about 2500 m3 over the year.
I would like to define two axis, but both in m3.
But whatever I try in CONFIG.js, it keeps showing only one axis.
How can I plot these two variables in one plot properly?

Kind regards,

Bert
Screenshot 2022-10-10 at 19-28-09 Dashticz.png
Screenshot 2022-10-10 at 19-28-09 Dashticz.png (79.64 KiB) Viewed 269 times
Hi all,

Code: Select all

locks['graph_gas'] = {
    title: 'Gas',
    devices: [3],
    graph: ['bar','line'],
    custom : {
        "last day": {
            range: 'day',
            filter: '25 hours',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }
        },
        "last week": {
            range: 'week',
            filter: '7 days',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }   
            "last month": {
            range: 'month',
            filter: '31 days',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }
        },
        "last year": {
            range: 'year',
            filter: '12 months',
            data: {
                U: 'd.v_3',
                C: 'd.c_3-11083',
            },
            options: {
              scales: {
                    yAxes: [
                        {
                            ticks: {
                                min: 0,
                                max: 20
		            }
                        },{
                            ticks: {
                                min: 0,
                                max: 3000
                            }
                        }
                    ]
                }
            }
        }
    },
    legend: { 'U':'Gas Usage [m3]','C':'Gas Usage Cumulative [m3]',},
    datasetColors:['red','green']
}


Re: Graph with data with same unit but different magnitude

Posted: Friday 14 October 2022 20:12
by Lokonli
brjhaverkamp wrote: Monday 10 October 2022 18:02 I have a question for which I hope someone already got the solution. It feels like a silly problem.
I am trying to plot my daily gas usage as well as my cumulative year usage in one plot.
However my gas usage varies from 0 to 10 m3 per day
while my cumulative goes up to about 2500 m3 over the year.
I would like to define two axis, but both in m3.
But whatever I try in CONFIG.js, it keeps showing only one axis.
How can I plot these two variables in one plot properly?

Kind regards,

Bert
Screenshot 2022-10-10 at 19-28-09 Dashticz.pngHi all,

Code: Select all

locks['graph_gas'] = {
    title: 'Gas',
    devices: [3],
    graph: ['bar','line'],
    custom : {
        "last day": {
            range: 'day',
            filter: '25 hours',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }
        },
        "last week": {
            range: 'week',
            filter: '7 days',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }   
            "last month": {
            range: 'month',
            filter: '31 days',
            data: {
                U: 'd.v_3',
                C: 'd.c_3',
            }
        },
        "last year": {
            range: 'year',
            filter: '12 months',
            data: {
                U: 'd.v_3',
                C: 'd.c_3-11083',
            },
            options: {
              scales: {
                    yAxes: [
                        {
                            ticks: {
                                min: 0,
                                max: 20
		            }
                        },{
                            ticks: {
                                min: 0,
                                max: 3000
                            }
                        }
                    ]
                }
            }
        }
    },
    legend: { 'U':'Gas Usage [m3]','C':'Gas Usage Cumulative [m3]',},
    datasetColors:['red','green']
}

You can enforce 2 different y-axes by setting the ylabels parameter, for instance as follows:

Code: Select all

      ylabels: ['m3','m3 '],
      legend: { 'U':'Gas Usage','C':'Gas Usage Cumulative'},
There is a space behind the second m3. This makes it different from the first one. Dashticz will create two y-axes.

Additional remarks:
'week' cannot be used as range parameter. It's not supported by Domoticz. You should use 'month'.

For the day graph: Domoticz doesn't provide the cumulative data.

Re: Graph with data with same unit but different magnitude

Posted: Sunday 16 October 2022 8:47
by brjhaverkamp
Hi Lokonli,
Thanks! The (misspelled) ylabels is a good trick.
Meanwhile I circumvented it by putting the cumulative graphs of gas and electricity together. Those sure have different yaxis:-)
But with your tip I can revert back to my original plan.

I am still facing 2 challenges though.
1) I want the cumulative graph to start at zero. For this I need to subtract a variable that is calculated in a separate block. But I have no idea how to get that variable in the graph formula.
2) When I have two graphs with different yaxis, I would like to have them use the same zero line. (same origin) The scaling will of course be different. I couldn't find a way to force this, or trick it:-)

Regards,

Bert