I have created 5 context flows named Chart0, Chart1 .....Chart5 that stores chart values like so:
[{"series":[""],"data":[[{"x":1680087534038,"y":10},{"x":1680095175649,"y":22.1},{"x":1680095226258,"y":22.1},{"x":1680095276868,"y":22.1},{"x":1680095327498,"y":22.1},{"x":1680095378102,"y":22.1}]],"labels":[""]}]
Then I have incoming json:
{"0":{"T":22.1,"R":1,"P":26,"L":1},"1":{"T":22.1,"R":1,"P":26,"L":1},"2":{"T":22.6,"R":0,"P":26,"L":2},"3":{"R":1},"4":{"R":1}}
Then I made the function node that pushes new data into these flows using following code:
var d = new Date();
var epoch = d.getTime();
var incoming = msg.payload;
/* initial code that should do the batch process
for (var i = 0; i < Object.keys(data).length; i++) {
if (data[i] && data[i].T) {
var Last = flow.get("Chart"+String(i));
var point = {"x": epoch, "y": data[i].T};
Last[0].data[0].push(point);
flow.set("Chart" + String(i), Last);
}
}
*/
// short test flow to narrow the problem > that adds data to Chart1...5 deliberately too!!!
var Last = flow.get("Chart0");
var point = { "x": epoch, "y": incoming[0].T };
Last[0].data[0].push(point);
flow.set("Chart0", Last);
So I found out if I name the flow for instance Chart_x then the function adds data as intended into Chart_x. However if I make number pattern name like Chart0 or Chart_0c then the function will fill up all similar pattern flows while I am not calling these flows in my code.
So what I am missing here?