【发布时间】:2020-06-19 04:01:33
【问题描述】:
我正在尝试实现 vue-chartjs Donut,但我无法正确设置颜色。
这是我使用组件 Doughnut 的地方
我的 App.vue
<template>
<div id="app">
<label for="Doughnut">Doughnut</label>
<div id="ChartDoughnut">
<ChartDoughnut :chartData="chartDataDoughnut" />
</div>
</div>
</template>
<script>
import ChartDoughnut from "./components/ChartDoughnut.vue";
export default {
name: "App",
components: {
ChartDoughnut
},
data() {
return {
chartDataDoughnut: {
datasets: [
{
data: [10, 20, 30]
}
],
// These labels appear in the legend and in the tooltips when hovering different arcs
labels: ["Red", "Yellow", "Blue"]
}
// optionsDoughnut: {}
};
}
};
</script>
这是 Doughnut 的组件
chartDoughnut.vue
<script>
import { Doughnut } from "vue-chartjs";
export default {
extends: Doughnut,
props: {
chartData: {
type: Object,
default: null
},
options: {
type: Object,
default: null
}
},
mounted() {
this.renderChart(this.chartData);
}
};
</script>
我在标签上添加了颜色,但它不起作用。
【问题讨论】:
标签: vue.js vuejs2 vue-chartjs