我有这个简单的折线图,我试图将网格线从默认的灰色更改,但是选项对象似乎有选择地工作。也许我错过了一些基本的东西,但我已经摆弄了几个小时并且无法让它工作,感谢任何帮助!我正在使用“react-chartjs-2”。
下面是我传递数据和选项的 render() 方法。
render() {
const data = {
labels: this.state.realTimes,
datasets: [
{
label: "Price",
data: this.state.Prices,
fill: false,
backgroundColor: "rgb(255, 255, 255)",
borderColor: "rgba(255, 255, 255)"
}
]
};
const options = {
scales: {
yAxis: {
beginAtZero: true, //this works
gridLines: {
color: "rgba(171,171,171,1)", //this doesn't
lineWidth: 0.5
}
}
}
};
return (
<div>
{this.state.loading ? (
this.loading()
) : (
<Line data={data} options={options} width={600} height={160} />
)}
</div>
);
}