【发布时间】:2020-03-09 11:12:41
【问题描述】:
我在 Angluar 中使用 chart.js 库 (https://www.chartjs.org/docs/latest/charts/bar.html),我想为整个条形图设置 3 种颜色。
当显示超过 3 列时,有没有办法告诉图表应该从头开始应用颜色数组?到目前为止我的代码:
colors: ['red','green','yellow']
data: {
datasets: [{
barPercentage: 0.5,
barThickness: 6,
maxBarThickness: 8,
minBarLength: 2,
data: [10, 20, 30, 40, 50, 60, 70]
backgroundColor: colors,
}]
};
输出应该是:红、绿、黄、红、绿、黄、...
【问题讨论】: