I am trying to feed the highcharts diagram with input data but face one problem. I get the data via json and then add them to data just like this:
function getGraphValues() {
period.deviceID = user.deviceID;
var postData = JSON.stringify(period);
var postArray = {json:postData};
$.ajax({
type: 'POST',
url: "getData.php",
data: postArray,
success: function(data)
{
data1 = JSON.parse(data);
if (data1.status == "ok" )
{
var stats = data1.metrics.split("/");
$(function () {
$('#container').highcharts(
{
chart: {type: 'bubble',zoomType: 'xy'},
title: {text: 'Highcharts Bubbles'},
series: [{data: [getData(stats)]}]
});});
}
else
{
alert("error");
}}
});}
function getData(stats)
{
var data;
var stats;
for (var j = 0; j < stats.length; j++)
{
data += "[" + j + "," + stats[j] + "," + stats[j]*8 + "],";
}
stats = data.split(",");
return stats;
}
So, in a way like this I do get the stats in this form: [47,47,21],[20,12,4],[6,76,91],[38,30,60],[57,98,64],[61,17,80],[83,60,13],[67,78,75] stored in string variable. My problem is that I can't pass this string for the data input as it waits number and not string. How should I feed the data attribute in an accpetable way ? How can I create an array of array in the getData function if this is needed ? Thank you.