简体   繁体   中英

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. 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.

What version are you using? My bar chart in v 2.5.0 doesn't extend above

条形图样本

It does have the optional 'padding' argument:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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