使用chartjs删除y轴上多余的线

cla*_*ios 2 chart.js vue-chartjs

我想知道如何删除折线图上多余的线条。我尝试设置drawborder为 false,但当然它只是删除轴上的所有行。我只是想摆脱不需要的指向 y 轴标签的垂直线,如下图带有红色标记的图像。

在此输入图像描述

模板:

<d-chartrecord 
     :chart-data="datacollection" 
     v-bind:options="options"
     :height="200"
></d-chartrecord>
Run Code Online (Sandbox Code Playgroud)

脚本:

export default {
    data () {
        return {
            datacollection: {},
            options: {
                responsive: true,
                legend: {
                  display: false,
                },
                scales: {
                    xAxes: [{
                        gridLines: {
                            display: true,
                            color: '#D7D7D7'
                        },
                        ticks: {
                            fontSize: 8,
                            beginAtZero: true
                        },
                        gridLines: {
                            display: true,
                        }
                    }],
                    yAxes: [{
                        display: true,
                        ticks: {
                            fontSize: 8,
                            beginAtZero: true,
                            stepSize: 50,
                            maxTicksLimit: 3
                        }
                    }],
                }
            },

        }
    },
    mounted () {
        this.putData()
    },
    methods: {
        putData () {
            this.datacollection = {
                labels: ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'],
                datasets: [{
                    lineTension: 0,
                    radius: 4,
                    borderWidth: 1,
                    borderColor: '#F2A727',
                    pointBackgroundColor:[ '#fff', '#fff', '#fff', '#fff', '#fff', '#F2A727'],
                    backgroundColor: 'transparent',
                    data: [this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt()]
                }]
            }
        },
        getRandomInt  () {
            return Math.floor(Math.random() * (95)) + 5
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 6

在chart.js中,gridLines提供了一个选项tickMarkLength来禁用超出轴的长度,例如:

 yAxes: [{
          gridLines: {
            tickMarkLength: 0,
          },
        }] 
xAxes: [{
          gridLines: {
            tickMarkLength: 0,
          },
        }]
Run Code Online (Sandbox Code Playgroud)