vue-chart.js :数据作为计算属性可用,但未显示在图表中
vue-chart.js : Data available as computed properties, but not showing in chart
数据在计算属性中可用(见屏幕截图),但不会呈现到 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 调试)
尝试计算 属性 来计算图表数据:
查看 chart.js
在 https://www.webpackbin.com/bins/-KpNBtUKQ67-jSFRHtNe
datasets: [
{
label: 'Ticketstatus',
backgroundColor: '#f87979',
data: this.orderStatusChartData
}
.
computed: {
orderStatusChartData () {
let chartData = []
this.statOrderstatus.forEach(function(orderStatus) {
chartData.push(orderStatus.doc_count)
})
return chartData
}
数据在计算属性中可用(见屏幕截图),但不会呈现到 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 调试)
尝试计算 属性 来计算图表数据:
查看 chart.js
在 https://www.webpackbin.com/bins/-KpNBtUKQ67-jSFRHtNe
datasets: [
{
label: 'Ticketstatus',
backgroundColor: '#f87979',
data: this.orderStatusChartData
}
.
computed: {
orderStatusChartData () {
let chartData = []
this.statOrderstatus.forEach(function(orderStatus) {
chartData.push(orderStatus.doc_count)
})
return chartData
}