Dashboard 2 ui-chart data format - no data key names

Hi,

I am migrating from dashboard 1 to dashboard 2. Like others I had to format the incoming data for dashboard 1. I've read in other posts that this is no longer needed. The issue I have is that my data does not have key names to reference.

How should I set up my chart node or reformat my data so that I can visualise it?

{"status":"OK","name":"Smart Meter, electricity consumption","resourceTypeId":"ea02304a-2820-4ea0-8399-f1d1b430c3a0","resourceId":"e45cbfcf-92fe-49c1-8c2a-fe0319c513e3","query":{"from":"2025-01-02T00:00:00","to":"2025-02-02T00:00:00","period":"P1D","function":"sum"},"data":[[1735776000,19.494],[1735862400,18.592],[1735948800,18.976],[1736035200,20.121],[1736121600,19.906],[1736208000,19.596],[1736294400,16.312],[1736380800,19.35],[1736467200,19.234],[1736553600,20.813],[1736640000,21.133],[1736726400,14.791],[1736812800,15.17],[1736899200,14.121],[1736985600,15.14],[1737072000,13.847],[1737158400,13.364],[1737244800,22.012],[1737331200,16.174],[1737417600,18.724],[1737504000,15.015],[1737590400,14.953],[1737676800,22.999],[1737763200,12.563],[1737849600,15.315],[1737936000,15.327],[1738022400,13.219],[1738108800,19.611],[1738195200,14.962],[1738281600,18.78],[1738368000,17.477],[1738454400,0.311]],"units":"kWh","classifier":"electricity.consumption"}

There are some tutorials at Getting Started | Node-RED Dashboard 2.0 you should take a look at.

You will need to convert the data and put it in payload

in a function, before the chart:

msg.payload = msg.payload.data.map(e => {
    return {
        x: new Date(e[0] * 1000).toLocaleDateString(),
        y: e[1],
    }
})
return msg;

Chart setup:

Result:

1 Like

Thank you Steve

That works perfectly.

Jon