I probably did not present the question well
I'm a rookie in json code and I need to create a canvas graphic with javascript. The queries in php and mysql are made correctly and I convert the results in an array and this in json code to work with the results in a javascript file.
I'm using the Chart Js framework to create the graphics. My conflict is in this part, where manually it is completed like this
labels: ["month1", "month2"], data: [500, 550],
now the labels and data data I get from an sql query
I have the following code
var nom = '';
for(var i in d2){
nom += '"'+d2[i].N+'",';
}
nom = nom.substring(0,nom.length-1);
var punto = '';
for(var j in d2){
punto += d2[j].P+',';
}
punto = punto.substring(0,punto.length-1);
The error occurs when I pass these variables to the corresponding data, that is:
labels: [nom],
data: [punto],
When executing the code, I take each variable as a single string, and I need to take it as several values separated by commas. I do not know what kind of conversion I should do.