0

我正在使用钛 SDK。我想在我的应用程序中添加折线图工具。我的应用程序与设备兼容(android 和 iphone)。对于折线图,我使用的是 google graph api。(https://developers.google.com/chart/interactive/docs/gallery/linechart)。但仅适用于 iphone,而不适用于 android。与 iphone 工作得很好。但是,不适用于android。错误消息是:[表达式'c[0]'[null] 的结果不是对象。] 我如何消除这个问题我正在使用这个代码。

<html>
  <head>
    <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', 'Month'); // Implicit domain label col.
            data.addColumn('number', 'Sales'); // Implicit series 1 data col.
            data.addColumn({type:'string', role:'annotation'}); // annotation role col.
            data.addRows([
                ['April',1000,    'A'],
                ['May',  1170,   'B'],
                ['June',  660,   'C'],
                ['July', 1030,  'c']
            ]);
            var options = {
              title: 'Company Performance'
            };

            var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
            chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

请帮助我,提前谢谢

4

1 回答 1

1

这段代码对我有用。

<html>
  <head>
    <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 = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);

        var options = {
                width: 400, height: 400, annotationColumns:[{column:2, size:15, type:'flag', priority:'high'},], title: ''
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

谢谢大家。

于 2013-04-18T07:29:12.797 回答