Chart Dashboard 2 two series of data

Hello everyone, I'm trying to insert two data series into chart.dashboard 2.0, but without success...

Can anyone help me?

Function code:

const inp = msg.payload;

//Criar um objecto para gráficos.
var outObj = [
    {
    "series": ["Eletricidade"],
    "data": [ [  ] ], 
    "labels": ["1"]    
    }
    ,
    {
    "series": ["Gás"],
    "data": [ [  ] ],
    "labels": ["2"]
    }
    ]

for (let item of inp ) 
{
    outObj [0].data[0].push(
        {
            x: item.Data,
            y: item.PreçoPortugal
        });
    outObj[1].data[0].push(
        {
            x: item.Data,
            y: 100
        });
}

msg.topic="";
msg.payload= outObj;
return msg;

Boa noite @mancebo77, bem vindo ao Forum :slightly_smiling_face:

Charts in dashboard 2 are simpler than in node-red-dashboard.
You probably don't need your function node to reformat the data.

Please copy and paste here a sample of the msg.payload that you pass into the function. (Paste it as text using the </> button, not as a picture)

Hi @jbudd,
The payload comes from mysql, it only has one series of data, in the function I added the second series (only one line with value 100).

[{"Data":"2024-11-21T23:00:00.000Z","PreçoPortugal":107.74},{"Data":"2024-11-21T22:00:00.000Z","PreçoPortugal":116.92},{"Data":"2024-11-21T21:00:00.000Z","PreçoPortugal":122.11},{"Data":"2024-11-21T20:00:00.000Z","PreçoPortugal":125.01},{"Data":"2024-11-21T19:00:00.000Z","PreçoPortugal":116.49},{"Data":"2024-11-21T18:00:00.000Z","PreçoPortugal":84.99},{"Data":"2024-11-21T17:00:00.000Z","PreçoPortugal":64.78},{"Data":"2024-11-21T16:00:00.000Z","PreçoPortugal":33.2},{"Data":"2024-11-21T15:00:00.000Z","PreçoPortugal":29.8},{"Data":"2024-11-21T14:00:00.000Z","PreçoPortugal":33.2},{"Data":"2024-11-21T13:00:00.000Z","PreçoPortugal":33.2},{"Data":"2024-11-21T12:00:00.000Z","PreçoPortugal":50},{"Data":"2024-11-21T11:00:00.000Z","PreçoPortugal":69.39},{"Data":"2024-11-21T10:00:00.000Z","PreçoPortugal":87.8},{"Data":"2024-11-21T09:00:00.000Z","PreçoPortugal":107.99},{"Data":"2024-11-21T08:00:00.000Z","PreçoPortugal":95},{"Data":"2024-11-21T07:00:00.000Z","PreçoPortugal":75.2},{"Data":"2024-11-21T06:00:00.000Z","PreçoPortugal":65.18},{"Data":"2024-11-21T05:00:00.000Z","PreçoPortugal":64.89},{"Data":"2024-11-21T04:00:00.000Z","PreçoPortugal":65.1},{"Data":"2024-11-21T03:00:00.000Z","PreçoPortugal":75},{"Data":"2024-11-21T02:00:00.000Z","PreçoPortugal":84.99},{"Data":"2024-11-21T01:00:00.000Z","PreçoPortugal":93.96},{"Data":"2024-11-21T00:00:00.000Z","PreçoPortugal":103.5}]

Thanks