我使用react-chartjs-2并尝试在y轴上创建虚线网格线
我尝试查看图表配置网站:https://www.chartjs.org/docs/latest/axes/styling.html#grid-line-configuration
但找不到窍门
这是我的代码:
import { Chart } from 'react-chartjs-2';
import {Chart as ChartJS, registerables} from 'chart.js';
ChartJS.register(...registerables);
const data = {
labels: ["Label1", "Label2", "Label3"],
datasets: [{
label: 'legend1',
data: [12, 19, 3],
},{
label: 'legend2',
data: [22, 9, 13],
}]
};
const options = {
scales: {
y: {
grid: {
tickBorderDash: [4, 4],
tickColor: '#000',
tickWidth: 2,
offset: true,
drawTicks: true,
drawOnChartArea: true
},
beginAtZero: true,
},
x: {
display: false
}
},
};
const BarChart …Run Code Online (Sandbox Code Playgroud)