小编Nac*_*lin的帖子

React-Chartjs-2 如何创建虚线网格线

我使用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)

chart.js react-chartjs-2

4
推荐指数
1
解决办法
2511
查看次数

标签 统计

chart.js ×1

react-chartjs-2 ×1