简体   繁体   English

可以隐藏超出Chart的Chart.js网格线吗?

[英]Possible to hide Chart.js grid lines that extend beyond chart?

I'm trying to find a way of hiding the grid lines that extend beyond the max value of the axis (see image below for reference). 我试图找到一种方法来隐藏超出轴线最大值的网格线(请参见下图以供参考)。

在此处输入图片说明

And the same for the X-Axis of course. 当然,X轴也一样。 I essentially just want the lines to stop at the max tick value. 我基本上只希望行停止在最大刻度值处。 I've scoured the documentation but no avail so hoping the good people of SE will be able to suggest a solution. 我搜索了文档但无济于事,所以希望SE的好人能够提出解决方案。

What version are you using? 您使用什么版本? My bar chart in v 2.5.0 doesn't extend above 我在2.5.0版中的条形图没有超出

条形图样本

It does have the optional 'padding' argument: 它确实具有可选的“ padding”参数:

   window.myBarChart = new Chart(ctx, {
      type: 'bar',
      data: barChartData,
      options: {
        elements: {
          rectangle: {
              borderWidth: 2,
          }
        },
        layout: {
          padding: {
            top: 12
          }
        },
        responsive: true,
        legend: {
          position: 'right',
        }
      }
    });

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

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