问题
I use a vertical bar chart and I want to specify different colors for each bar:
main.js
import Chartkick from 'vue-chartkick';
import Chart from 'chart.js';
Vue.use(Chartkick.use(Chart));
File.vue
<column-chart :data="chartData" width="800px" :colors="['#0b6e00', '#006ca2', '#ff3333', '#d60001']"></column-chart>
But only the first color is used and all bars have the same colour.
I tried to pass a :library
attribute with backGround colour parameter as well without luck. Line chart accepts different colours.
回答1:
It will work if you define :colors
as a nested array as follows:
<column-chart
:data="chartData"
width="800px"
:colors="[['#0b6e00', '#006ca2', '#ff3333', '#d60001']]">
</column-chart>
Please have a look at the following StackBlitz
来源:https://stackoverflow.com/questions/61127225/vue-chartkick-different-colours-for-bar-chart