This may be a JSON or JS issue but I can't find a soution yet.
My single series bar chart shows different colours for the first 30 data points but no colour after that. Any suggestions welcome!
var date = new Date();
var mon = date.getMonth() + 1;
var x = 0; var dv = 0;
var t = [0,0,0]; var title = ["","",""]
var myData = msg.payload;
global.set("myData", myData);
var chart = [{
"series":["Gate"],
"data": [new Array(64)],
"labels":[""]
},
{
"series": ["Site"],
"data": [new Array(64).fill(0)],
"labels": [""]
},
{
"series": ["Total"],
"data": [new Array(64).fill(0)],
"labels": [""]
}]
for (let m = 5; m <= mon; m++) {
for (let j = 0; j < 2; j++) {
//var m=6;
var mo = m.toString();
for (var i = 0; i < 32; i++) {
x = ((m - 5) * 31) + i;
// x = i;
dv = myData[j][mo][i] || 0;
chart[j].data[0][x] = dv;
t[j] = t[j] + dv;
t[2] = t[2] + dv;
chart[j].labels[x] = mo + "." + i.toString();
chart[2].data[0][x] = chart[2].data[0][x] + chart[j].data[0][x];
chart[2].labels[x] = mo + "." + i.toString();
}
}
}
title[0] = "Gate " + t[0].toLocaleString() + " Gal";
title[1] = "Site " + t[1].toLocaleString() + " Gal";
title[2] = "Total " + t[2].toLocaleString() + " Gal";
return [{ title: title[0], payload: [chart[0]] }, {title: title[1], payload: [chart[1]]}, {title: title[2], payload: [chart[2]]}, {payload: t}]