[英]Vue Chart.js component does not render
儀表板獲取具有10個元素的數據數組作為chdata
屬性。 每0.5秒陣列更新一次新項目。 我可以看到,數據在數據集中正在變化,但圖表沒有顯示。
Uncaught TypeError: Cannot read property 'skip' of undefined
到此錯誤Uncaught TypeError: Cannot read property 'skip' of undefined
懸停時Uncaught TypeError: Cannot read property 'skip' of undefined
。
//LineChart.vue
<script>
import {
Line,
mixins
} from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveData],
props: ["options"],
data() {
return {
chartData: {
labels: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
datasets: [{
label: 'Data One',
borderColor: '#e67e22',
pointBackgroundColor: '#e67e22',
borderWidth: 1,
pointBorderColor: '#e67e22',
backgroundColor: 'transparent',
data: this.$root.$data.chdata
}]
},
}
},
mounted() {
this.renderChart(this.chartData, {
responsive: true,
maintainAspectRatio: false,
animation: false,
//Boolean - If we want to override with a hard coded scale
scaleOverride: true,
//** Required if scaleOverride is true **
//Number - The number of steps in a hard coded scale
scaleSteps: 20,
//Number - The value jump in the hard coded scale
scaleStepWidth: 10,
//Number - The scale starting value
scaleStartValue: 0
});
},
watch: {
chartData: function() {
this._chart.destroy()
this.renderChart(this.data, this.options)
// this._chart.update()
}
}
});
</script>
我在mounted()
做了這個:
var self = this;
self.set = setInterval(function() {
self._chart.update()
}, 200);
而且我對此並不滿意。
問題是,您沒有更新標簽。 您可以在標簽數組中定義10個項目。 這適用於10個數據條目。
如果將新條目推送到數據陣列,則還需要添加新標簽。 否則chart.js將拋出此錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.