我想使用选项字段更改线图的网格颜色,但我不知道从哪里开始。首先尝试使用渐变更改画布背景颜色,但结果不理想。
canvas{
background:linear-gradient(top, #ea1a07 0%, #f4b841 75%,#f2dd43 100%);
}
然而,我没有得到我想要的东西,因为如上图所示,不仅网格被着色,而且x值、y标签和图例也被着色了。
使用此CSS代码获得的结果图片如下: Picture of the result I'm getting with this css code 我想要的样子如下所示: Example of what I want to get 我的chart.js选项如下:
options = {
scales: {
xAxes: [{
gridLines: {
color: 'rgba(171,171,171,1)',
lineWidth: 1
}
}],
yAxes: [{
ticks: {
beginAtZero: true,
max: 100,
min: 0,
stepSize: 10
},
gridLines: {
color: 'rgba(171,171,171,1)',
lineWidth: 0.5
}
}]
},
responsive: true
};
那么,有没有一种方法可以将网格的背景设置为三种不同的颜色(带有渐变或不带渐变)?注意:我正在使用带有Angular 2(ng2-charts)的chart.js。