HI I am very new to both json and js charts.
In the example of bar chart, they are giving a hard coded array like this,
var myData = new Array(['U.S.A.', 69.5], ['Canada', 2.8], ['Japan & SE.Asia', 5.6] );
var myChart = new JSChart('graph', 'bar');
myChart.setDataArray(myData);
Instead of that I want to use the response of $.post() method which is in json. Here is the piece of code.
var myData=[];
$.post("JSONServlet", function(data) {
$.each(data.Userdetails, function(i, data) {
myData[i] = [];
myData[i]['text'] = data['firstname'];
myData[i]['id'] = data['ssn'];
alert("first name " +myData[i]['text']+ " salary " +myData[i]['id']);
// I am getting correct data here, but how to assign this myData to barchart
});
}, "json");
is this the logic to use or how else can i get username and salary from the response and pass it to the barchart. Please help. I am stuck with this.
thanks in advance.