简体   繁体   English

如何更改chartjs中的x轴线条样式?

[英]how to change x-axis line style in chartjs?

zeroLineWidth:0 is not working with it. zeroLineWidth:0不适用于它。

my chart options.我的图表选项。

xAxes: [
    {
        gridLines: {
            display: false
        }
    }
],
yAxes: [
    {
        gridLines: {
            drawBorder: false,
            drawTicks: false,
            borderDash: [4, 4],
            color: "#eee",
            zeroLineWidth: 0
        }
    }
];

how to remove or change the x-axis line style?如何删除或更改 x 轴的线条样式? example image示例图像

zeroLineWidth apparently only works if the yAxis starts at zero. zeroLineWidth显然仅在yAxis从零开始时才有效。 This can be guaranteed by adding ticks.beginAtZero to your yAxis .这可以通过将ticks.beginAtZero添加到您的yAxis来保证。

ticks: {
  beginAtZero: true
}

 new Chart(document.getElementById('myChart'), { type: 'line', data: { labels: ['A', 'B', 'C', 'D'], datasets: [{ label: 'OK', data: [1, 2, 1, 2], fill: false, borderColor: 'blue' }] }, options: { responsive: true, legend: { display: false }, scales: { xAxes: [{ gridLines: { display: false } }], yAxes: [{ gridLines: { drawBorder: false, drawTicks: false, borderDash: [4, 4], color: "#eee", zeroLineWidth: 0 }, ticks: { beginAtZero: true } }] } } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script> <canvas id="myChart" height="90"></canvas>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM