开发者

Index Was Outside The Bound of Array In Java script C# Web Application Creating Google Chart?

hi i got this error in java script i am trying to run from server side in this script i use for loop in which i get value for loop runs more then 3000 times and get value from array having mare then 3000 values my script is,

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Year');
        data.addColumn('number', 'Sales');
      开发者_JAVA技巧  data.addRows(count);
        for (var i=0;i<count;i++)
        {
        data.setValue(i, 0, '"+Dvar[i]+"');
        data.setValue(i, 1, "+Pvar[i]+");
        }
        var chart = new    
                google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, {width: 400, height: 240, title: 'Company Performance'});
      }
    </script>

i am using this script server side so this script is in the string and count is mentioned oudside this script as array (Dvar) and (Pvar) and count value would be more then 3000 or is there any error in this script regarding loop hopes for your suggestions..


You said count is defined as an array, then you problem is this line:

 for (var i=0;i<count;i++)

you cant use count directly for count's length, it should have been

 for (var i=0;i<count.length ;i++)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜