问题
I'm getting this error:
google.visualization.Dashboard is not a constructor
This is my code:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.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 = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};
var control = new google.visualization.ControlWrapper({
containerId: 'control_div',
controlType: 'CategoryFilter',
options: {
filterColumnIndex: 0,
ui: {
}
}
});
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard'));
dashboard.bind([control], [chart]);
dashboard.draw(data);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
<div id="dashboard" style="width: 900px; height: 500px"></div>
</body>
</html>
How can I fix this?
来源:https://stackoverflow.com/questions/46592396/google-visualization-dashboard-is-not-a-constructor