开发者

Google visualization AreaChart giving "Invalid Argument" in IE7

开发者 https://www.devze.com 2023-03-14 19:16 出处:网络
I am getting a json string back from an ajax call which I am sticking in a Google visualization AreaChart. I have found that whenever there is only 1 row in the data, GV returns \"Invalid Argument\" i

I am getting a json string back from an ajax call which I am sticking in a Google visualization AreaChart. I have found that whenever there is only 1 row in the data, GV returns "Invalid Argument" in IE7, but it works in all other browsers.

Here is the array I am getting back from the ajax call,

Array
(
    [0] => Array
        (
            [cols] => Array
                (
                    [0] => Array
                        (
                            [label] => Time Dispersion
                            [type] => string
                        )

开发者_StackOverflow                    [1] => Array
                        (
                            [label] => Score
                            [type] => number
                        )

                )

            [rows] => Array
                (
                    [0] => Array
                        (
                            [c] => Array
                                (
                                    [0] => Array
                                        (
                                            [v] => SA-00:00
                                        )

                                    [1] => Array
                                        (
                                            [v] => 50
                                        )
                                )
                        )
                )
        )
)

And here is the ajax call, along with the table setup,

$.getJSON(url, function(fpdata) {
    //load summary of footprint chart
    var prepdata = fpdata.timesum[0];
    var data = new google.visualization.DataTable(prepdata, 0.5);
    var chcontainer = 'eleid';
    var chart = new google.visualization.AreaChart(document.getElementById(chcontainer)); 
    var options = {width: fpwidth, height: fpheight, titleFontSize: 14, is3D: true, legend: 'none', title: 'Title',
        pointSize: 0,  vAxis: {maxValue: 100, title: 'Percentage Correct'}  , hAxis: {title: 'Title'}
    };

    chart.draw(data, options ); 
    $("#"+chcontainer).append('<br /><span class="printthis">[Print]</span>');
});


An area chart requires at least 2 rows in order to have a line from one point to another. To fix this I put a check in that would set the first row to zero if there was only 1 data result.

It would be nice if GV put this somewhere in their API documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消