以前这个折线图有一个字符串,因为它是第一列,我试图将其转换为使用DateTime,因此X轴连续而不是离散,但是图表不再呈现,我收到一条错误消息,无法调用方法'Yc'为null。
任何想法为什么?
<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>
答案 0 :(得分:1)
3小时后,答案当然是
cols: [{label: 'Date', type: 'Date'},
实际应该是
cols: [{label: 'Date', type: 'date'},
糟糕...