Hello friends, I have a warning " bad data inject " while I am importing data from DB and show it on bar chart. The point is all the process is done perfectly and also data represented correctly on bar chart but I don't understamd the source of this warning!
This is my imported data from DB:
[{"Date":"2023-04-12T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"},{"Date":"2023-04-13T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"},{"Date":"2023-04-16T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"},{"Date":"2023-04-17T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"},{"Date":"2023-04-18T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"},{"Date":"2023-04-19T22:00:00.000Z","Avg_var2":"73.0","Avg_var3":"61.0","Avg_var6":"11.0"}]
and I respect the chart format such this:
var bar = [{
"series": [],
"data": [],
"labels": []
}];
let columns = 0;
for (var series in msg.payload[0]) {
if (series !== "Date") {
bar[0].series.push(series);
bar[0].data.push([]);
columns++;
}
}
for (var j = 0; j < msg.payload.length; j++) {
for (var i = 0; i < columns; i++) {
bar[0].data[i].push( msg.payload[j][bar[0].series[i]]);
}
bar[0].labels.push(msg.payload[j].Date.toLocaleString('en-us', { weekday: 'short' }));
}
msg.payload = bar;
return msg;
and this is the final data injecting to chart:
[{"series":["Avg_var2","Avg_var3","Avg_var6"],
"data":[["73.0","73.0","73.0","73.0","73.0","73.0"],
["61.0","61.0","61.0","61.0","61.0","61.0"],
["11.0","11.0","11.0","11.0","11.0","11.0"]],
"labels":["Thu","Fri","Mon","Tue","Wed","Thu"]}]
As I mentioned this is the result :
and this is the warning I get
I would appreciate it if give me an idea to fix the problem.