0
过去几天我一直试图执行我的谷歌图表网页(jsfiddle),但它似乎像错误不断变化,即使我没有做任何不同的事情,除了刷新网页。我曾尝试使用Chrome的“清空缓存和硬重新载入”功能,但这并没有改变任何内容。我收到的错误包括诸如Uncaught typeError: hi is not a function
之类的内容。我知道这个代码的作品,因为我昨天使用它,它工作得很好。我的代码在它的工作时间和现在之间没有改变。我是否导入了错误的东西,或者Google Charts API有什么问题。我得到了同样的问题,每当我试图打开Google's APIGoogle Charts:嗨不是函数
的javascript:
google.charts.load('current',{'packages':['controls','corechart']});
google.charts.setOnLoadCallback(drawDashboard);
function drawDashboard(){
var dataSet = google.visualization.arrayToDataTable([
[{label:'date',type:'datetime'},{label:'Bytes from network:Bytes to network',type:'number'}],
[new Date(2016,01,23,00,00),1.0],
[new Date(2016,01,23,01,00),1.0075187969924813],
[new Date(2016,01,23,03,00),1.126865671641791],
[new Date(2016,01,24,22,00),0.987012987012987],
[new Date(2016,01,25,01,00),1.0],
[new Date(2016,01,25,02,00),0.9166666666666666],
[new Date(2016,01,25,10,00),1.0],
[new Date(2016,01,26,12,00),1.0],
[new Date(2016,01,27,17,00),0.9864864864864865],
[new Date(2016,01,28,22,00),0.03125],
[new Date(2016,02,01,22,00),0.97],
]);
var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard_div'));
var dateRangeFilter = new google.visualization.ControlWrapper({'controlType':'ChartRangeFilter',
'containerId':'filter_div',
'options':{
'filterColumnLabel':'date',
'ui':{
'chartOptions':{
'chartArea':{
'width':'90%'
}
}
}
}
});
var lineChart = new google.visualization.ChartWrapper({'chartType':'LineChart',
'containerId':'curve_chart',
'options':{
'title': 'Total Bytes from the Source Network to Total Bytes To the Source Network per Day',
'curveType': 'function',
'chartArea': {'height': '80%', 'width': '90%'},
'legend': 'none'
}
});
dashboard.bind(dateRangeFilter,lineChart);
dashboard.draw(dataSet);
}
HTML:
<html>
<head>
<link rel="stylesheet" href="styles.css">
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
//javascript code from above
</script>
</head>
<body>
<h1>Data for this IP network</h1>
<hr />
<a href="../index.html"><<BACK TO INDEX</a>
<div id="dashboard_div">
<div id="curve_chart"></div>
<div id="filter_div"></div>
</div>
</body>
</html>
CSS:
h1{
text-align:center;
}
#dashboard_div{
border:1px solid #ccc;
margin:10px;
}
#curve_chart{
width:915px;
height:300px;
}
#filter_div{
width:915px;
height:50px;
}
我只是改变'google.charts.load( '当前',{ '包':[ '控制', 'corechart']});''到google.charts.load(” 44',{'packages':['controls','corechart']});'现在它可以工作。谢谢您的帮助! –