[英]Chart.js color change of the data points
You can set the color value for each data point an array.您可以为数组中的每个数据点设置颜色值。
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)',
],
borderWidth: 1
}]
codepen - https://codepen.io/non_tech_guy/pen/VwzwRrL codepen - https://codepen.io/non_tech_guy/pen/VwzwRrL
The only catch I can see is the first borderColor value controls the color of the line but it is a step closer.我能看到的唯一问题是第一个 borderColor 值控制线条的颜色,但它更近了一步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.