0

以前,此折线图的第一列有一个字符串,我正在尝试将其转换为使用 DateTime,因此 X 轴是连续的而不是离散的,但是图表不再呈现,并且我收到无法调用方法“Yc”的错误消息' 为空。

任何想法为什么?

  <head>
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  <script async="" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
  <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {

      var data = new google.visualization.DataTable(
        {
          cols: [{label: 'Date', type: 'Date'},
                 {label: 'Firefox', type: 'number'},
                 {label: 'Chrome', type: 'number'},
                 {label: 'IE10', type: 'number'},
                 {label: 'IE8', type: 'number'},
                 {label: 'IE9', type: 'number'}],
          rows:[
                {c:[{v:'Date(2013,06,14,03,16)'},{v:4994},{v:5930},{v:5667},{v:4836},{v:7620}]},
                {c:[{v:'Date(2013,06,14,05,58)'},{v:4884},{v:6151},{v:6097},{v:4880},{v:7468}]},
                {c:[{v:'Date(2013,06,14,08,50)'},{v:5020},{v:6593},{v:5824},{v:4876},{v:7312}]},
                {c:[{v:'Date(2013,06,14,11,56)'},{v:5076},{v:6227},{v:5488},{v:5371},{v:7310}]},
                {c:[{v:'Date(2013,06,14,14,59)'},{v:5044},{v:6221},{v:6141},{v:4824},{v:6874}]},
                {c:[{v:'Date(2013,06,14,17,58)'},{v:5265},{v:6235},{v:5736},{v:4865},{v:7235}]},
                {c:[{v:'Date(2013,06,14,20,56)'},{v:4959},{v:6161},{v:5506},{v:5022},{v:7140}]},
                {c:[{v:'Date(2013,06,14,23,53)'},{v:5010},{v:6539},{v:5549},{v:5060},{v:7036}]}
                ]
            }
          );

      var options = {
        title: 'Chart Title',
        interpolateNulls: true,
        seriesType: "line"
      }

      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>
4

1 回答 1

1

3 hours later and of course the answer is

cols: [{label: 'Date', type: 'Date'},

should actually be

cols: [{label: 'Date', type: 'date'},

Argh...

于 2013-07-09T16:16:49.290 回答