Using JSON object/string directly to create chart

Posted by user1180396 
Using JSON object/string directly to create chart
March 13, 2012 07:17PM
I am just getting my feet wet with JSCharts and things are going well except for one point. I can't find a way to pass a JSON object/string directly to create a chart.

The setDataJSON function can be used to have JSCharts contact the server itself which gets me the data I need but this is a blocking action, so the script stops dead while waiting for the server to respond. I want to do other things while the request is running. Additionally I want to use part of the returned JSON for other things besides the chart, but the way things are now I would need to make two separate requests to the server - I am working with mobile networks so this is something I really want to avoid.

Here is an example of what I would like to do:

function loadChart() {
    $.get("getChart.php",
        function(data) {
            var jso = $.parseJSON(data);
            drawChart(jso.chartData);
            processOtherStuff(jso.otherData)
        }
    );
    doSomethingWhileRequestInProgress();
}

function drawChart(jso) {
    var myChart = new JSChart('chartcontainer', 'line');
    myChart.setDataJSONObject(jso);
    myChart.draw();
}

I am kinda surprised this is not available because with no http necessary it's actually less work for the JSChart creators to make than the existing setJSONData function is smiling smiley



Edited 2 time(s). Last edit at 03/13/2012 07:21PM by user1180396.
Sorry, you do not have permission to post/reply in this forum.