SqlLite and BarGraph

Hi, I'm new to this forum. I have also been using node red for some time now, I'm trying to display the consumption and production values ​​(by month) in a bar graph. Selected data from a SqlLite DB. I can extract and correctly display data on two separate graphs. I've tried to combine them into one graph but I can't display the data correctly. is help possible?

What are you using to create the graphs?
What version of NR and node.js?
What version of the dashboard?

Please provide a sample flow (with hard coded data) that displays the problem you are having.

pls share the data as requested by @zenofmud.
you can review the thread discussed here to start with, there are few example codes in there also.

Sorry, I had entered the data but not requested but they have not been saved in the forum.
version 3.0.2 with the default dashboard.

The first is SQL which I use to pull data from the DB. The second is in a function node that I use to create the bar graph. this is just to view the production every single day,
I would also like to insert consumption data in the same bar graph (for a single day).

if (monthnumber==0){
    msg.topic = "select day,month, max(kwh_p), max(kwh_c) from ENERGIA_C GROUP BY (day)"
    msg.mytest = "Tutto"
}else {
    msg.topic = "select day,month, max(kwh_p), max(kwh_c) from ENERGIA_C WHERE month=" + monthnumber + " GROUP BY (day)"
    msg.mytest = monthnumber
}
var data_out = [];
var data_out1 = [];
var data_out2 = [];
var consumokw
var produzionekw
var a1 = [];
var a2 = [];
var a3 = [];
var temp1=[];
var temp2 = [];
var temp3 = [];
var kp="Kw/h+";
var kc = "Kw/h-";

for (var i = 0; i < msg.payload.length; i++) {
    var dt = msg.payload[i].day;   
    produzionekw = parseInt(msg.payload[i]["max(kwh_p)"]);
    //consumokw = parseInt(msg.payload[i]["max(kwh_c)"]);
    temp1 =[dt];   
    temp2 = produzionekw;  
    temp3 = [kp]; 
    a1.push(temp1);
    a2.push(temp2);
    a3.push(temp3);
  
}
temp1.concat
temp2.concat
temp3.concat

data_out=a1;
data_out1 = [a2];
data_out2 = a3;

msg.payload=[{
    "series": data_out2,  
    "data": data_out1,
    "labels": data_out
}];

return msg;

Add a file-out node to the output of one of the DB nodes and create a file.

Now you should be able to use an inject node connected to the file-in and send the output to the two function nodes to create a test case showing the current results.

That is the best way to get quick help from any of us that are volunteering to help you.

I'll do some testing, thanks.

Sorry...

can two arrays (such as a1 and a2 ) be merged together into one array which should result in a3?

array a1     [1,2,3,4,5,6,7,8,9,10,11,12]
array a2     [10,20,30,40,50,60,70,80,90,100,110,120] 

array 3       [ [1,2,3,4,5,6,7,8,9,10,11,12], [10,20,30,40,50,60,70,80,90,100,110,120] ],

I think this will work:
Array3 = [a1,a2]

Perfect, thank you very much

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