Array in a bar graph over a 24 hour period

Hi all, I am trying to display an array in a bar graph over a 24 hour period. The array has 2 objects, time (hour) and price. how do i go about this?

thanks !

Here is the output from my function node:

msg : Object

object

_msgid: "09a0c486c861654e"

payload: array[24]

[0 … 9]

0: object

Time: "2023-03-08T00:00:00"

Price: 73.61

1: object

Time: "2023-03-08T01:00:00"

Price: 71.01

2: object

Time: "2023-03-08T02:00:00"

Price: 70.07

3: object

Time: "2023-03-08T03:00:00"

Price: 83.32

4: object

5: object

6: object

7: object

8: object

9: object

[10 … 19]

[20 … 23]

topic: ""
// Get the price array from context
var priceArray = flow.get("pArray");

// Create an array of objects with time and price values
var records = [];
for (var i = 0; i < 24; i++) {
    records.push({
        "Time": new Date().toISOString().slice(0, 10) + "T" + i.toString().padStart(2, "0") + ":00:00",
        "Price": Number(priceArray[i])
    });
}

// Create the message payload
msg.payload = {
    "records": records
};

return msg;

The Charts documentation has examples of how you need to format the data.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.