maybe you could help me.
My jquery ajax call result is splitted with "||" and it creates an array of values. One of these values is a string like this:
[['2012-11-18', 33, 2], ['2012-11-19', 162, 11], ['2012-11-20', 140, 13]]
I need to make this as a viable javascript array to pass it to google chart drawchart(myarray) function to use it with data.addRows(myarray);
Can anyone help me to achieve it?
I can make this ajax returned array to look like whatever, what is important is that i could use this array to update google chart.
OKay, heres my ajax success code:
success: function(response)
{
response_d = response.split("||");
response_message = response_d[0];
if(response_message == 'ok') {
$("#contr_count").html(response_d[1]);
$("#contr_average").html(contr_time(response_d[2]));
$("#contr_space_average").html(contr_time(response_d[3]));
var chartdata = $.parseJSON(response_d[4]);
drawChart(chartdata);
$("#contr_list").html(response_d[5]);
}
else {
}
}
And here is the drawchart function
function drawChart(chartdata) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Minutit tagasi');
data.addColumn('number', 'T pikkus');
data.addColumn('number', 'T vahe pikkus');
data.addRows(chartdata);
data.addRows(dateArray);
var options = {
title: 'T pikkuse ja vahe graafik (viimane 60 min)',
backgroundColor: '#fdf3e9',
colors: ['#FF7F00','#437C17'],
curveType: 'function',
enableInteractivity: true,
legend: {position: 'bottom'},
vAxis: {direction: -1},
hAxis: {direction: -1},
chartArea: {width: '85%'}
};
var chart = new google.visualization.LineChart(document.getElementById('contr_graph'));
chart.draw(data, options);
}
The code gives json error "SyntaxError: JSON.parse: unexpected character" ar firebug.