How to remove the Chart.js x Axis bottom line?
Asked Answered
A

5

6

I am using Chart.js 2.8.0 trying to get rid of the X/Y axis border. With gridLines { showBorder: false }} I am still seeing the X axis border. I also have the color set to 0 alpha, all the other lines on X and Y are gone except for the bottom one on the X axis that just wont go away. Tries some other options like drawBorder: false and scaleLineColor: "rgba(0,0,0,0)", none affected the bottom line on the X axis. image

This is my chart configurations

    type: 'line',
    data: {
        datasets: [{
            label: '',
            data: [],
            backgroundColor: [],
            borderWidth: 1
        }]
    },
    options: {
        scaleLineColor: "rgba(0,0,0,0)",
        layout: {
            padding: {
            top: 20
            }
        },
        legend: {
            display: false
        },
        scales: {
            gridLines: {
                showBorder: false
            },
            xAxes: [{
                gridLines: {
                    color: "rgba(0, 0, 0, 0)",
                }
            }],
            yAxes: [{
                gridLines: {
                    color: "rgba(0, 0, 0, 0)",
                },
                ticks: {
                    beginAtZero: true,
                    display: false,
                }
            }]
        }
    }
};
Aliaalias answered 11/4, 2019 at 3:38 Comment(2)
Possible duplicate of How to remove the line/rule of an axis in Chart.js?Ronironica
No. As stated above, I have used the solution in that question unsuccessfully.Aliaalias
A
10

After some time fiddling with it I have found the solution zeroLineColor: 'transparent' did the trick. Found it here https://github.com/chartjs/Chart.js/issues/3950

scales: {
            xAxes: [{
                gridLines: {
                    zeroLineColor: 'transparent'
                },
            }],
Aliaalias answered 11/4, 2019 at 3:49 Comment(0)
C
10

For anyone looking for the answer in v5, it's: options.scales.x.border.display: false;

Correna answered 7/12, 2022 at 0:27 Comment(1)
I am someone who was looking for the answer in v5! Thank you! This works perfectly.Kobold
C
8

If anyone is on v3 and is looking for the answer, its options.scales.x.grid.drawBorder: false

This is on v3.7.1 Found it by complete accident by looking through the typescript file and trying anything that looked relevant.

Chrome answered 15/3, 2022 at 7:42 Comment(0)
P
1

this answer for who are using recharts module :

<XAxis strokeOpacity={0} dataKey="name" />
Premature answered 16/12, 2021 at 3:18 Comment(0)
F
1

if anyone looking for answer with ChartJS v4 then try this

scales: {
y: {
 border: {
  display: false
  }
 }
}
Fogged answered 23/11, 2023 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.