我正在使用vue-google-charts
软件包显示Google图表,但无法在其中使用Calendar chart
。
html模板:
<GChart
type="CalendarChart"
:data="chartData"
:options="chartOptions"
/>
脚本:
<script>
import { GChart } from "vue-google-charts";
export default {
name: "App",
components: {
GChart
},
data() {
return {
chartData: [
['a','b'],
[ new Date(2012, 3, 13), 37032 ],
[ new Date(2012, 3, 14), 38024 ],
[ new Date(2012, 3, 15), 38024 ],
[ new Date(2012, 3, 16), 38108 ],
[ new Date(2012, 3, 17), 38229 ]
],
chartOptions: {
chart: {
title: "Red Sox Attendance",
height: 350,
}
}
};
}
};
它显示此错误
Uncaught (in promise) TypeError: chartsLib.visualization[this.type] is not a constructor
at VueComponent.createChartObject (vue-google-charts.common.js:1)
at eval (vue-google-charts.common.js:1)
如何解决此问题?谢谢。
似乎有:settings
属性要图表。它与之合作。
<GChart
:settings="{packages: ['calendar']}"
type="Calendar"
:data="chartData"
:options="chartOptions"
/>