我正在使用chart.js库(https://www.chartjs.org/docs/latest/charts/bar.html)在Angluar中工作,我想为整个条形图设置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,
}]
};输出应该是:红,绿,黄,红,绿,黄,...
发布于 2020-03-09 19:20:19
您可以使用简单的编程逻辑。colorIndex = columnNumber%3使用模运算符。休息吧,你可以想想。希望能有所帮助
https://stackoverflow.com/questions/60599368
复制相似问题