数据在计算属性中可用(见屏幕截图),但不会呈现到 PieChart 控件中。
有人知道为什么吗?
代码 :
<script>
import { Pie } from 'vue-chartjs'
import * as types from '../store/mutationtypes'
import { mapGetters, mapActions } from 'vuex'
export default Pie.extend({
mounted () {
statOrderStatus : this.$store.dispatch('getStatisticsForOrderStatus'),
this.renderChart({
labels: this.orderStatusChartKeys,
datasets: [
{
label: 'Ticketstatus',
backgroundColor: '#f87979',
data: this.orderStatusChartData
}
]
})
},
computed: {
...mapGetters(["statOrderStatus"]),
orderStatusChartData () {
let chartData = []
this.statOrderStatus.forEach(function(orderStatus) {
chartData.push(orderStatus.doc_count)
})
return chartData
},
orderStatusChartKeys () {
let chartKeys = []
this.statOrderStatus.forEach(function(orderStatus) {
chartKeys.push(orderStatus.key)
})
return chartKeys
}
}
})
</script>
VUE 信息:(Chrome 调试)