question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help with removing padding on y-axis

See original GitHub issue

I have struggled a lot trying to remove some padding that is added within the canvas when hidden the y-axis ticks. padding

I have even tried to modify the padding of the x-axis ticks with negativa numbers but then they wont align correctly with the data on the chart.

Please is there someone that could help? I tried SO but got no luck finding help there.

My code:

const ChartObj = new Chart(element, {
        type: 'line',
        data: chartData,
        options: {
            responsive: true,
            maintainAspectRatio: false,
            onClick: this.handleClick.bind(this, chartData),
            legend: {
                display: false
            },
            scales: {
                yAxes: [{
                    gridLines: {
                        display: false,
                        drawBorder: false
                    },
                    scaleLabel: {
                        display: false
                    },
                    ticks: {
                        display: false
                    }
                }],
                xAxes: [{
                    gridLines: {
                        color: 'rgba(255, 255, 255, 0)',
                        zeroLineColor: 'rgba(255, 255, 255, 0)', // hide the zero line by making it white
                        zeroLineWidth: 0,
                    },
                    scaleLabel: {
                        display: false
                    },
                    ticks: {
                        // Only display time line with a 5 year span
                        callback: function(dataLabel, index) {
                            return (index+1) % 5 === 0 ? dataLabel : '';
                        },
                    }
                }],
            },
            tooltips: {
                mode: 'index',
                intersect: false,
                position: 'nearest',
                callbacks: {
                    label: function(tooltipItem, data) {
                        if (data.datasets[tooltipItem.datasetIndex].label.length) {
                            return data.datasets[tooltipItem.datasetIndex].label + ': ' + currencyFormatter.format(tooltipItem.yLabel, { code: 'SEK', thousand: ' ', precision: 0 });
                        }
                    },
                    title: function(tooltipItem, data) {
                        return data.labels[tooltipItem[0]['index']] + ' år';
                    }
                },
            }
        },
    });

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
mathdev112commented, Oct 22, 2017

Hi. I use 2.7.0 version and this problem still available for me. How can I remove this padding? Thanks in advance.

1reaction
mathdev112commented, Oct 22, 2017

default

Read more comments on GitHub >

github_iconTop Results From Across the Web

removing the y-axis margins - javascript - Stack Overflow
I've been trying to make a masonry type layout so I gave random height and colors to the divs but there seem to...
Read more >
How to remove the padding from the Y-Axis title - Highcharts
The problem I am having is that I need to make sure that the padding is 0 on different font sizes that I...
Read more >
Remove an extra padding in y-axis on Epic detail (!37886) · Merge ...
What does this MR do? Removes an extra padding in y-axis on Epic detail Web page. Ordering class name is just aligned with...
Read more >
Remove padding to on inside of a chart - Bokeh Discourse
In the example below I would like to remove the left and right space/padding so that x=0 is inline with the y axis...
Read more >
Set axis limits and aspect ratios - MATLAB axis - MathWorks
This syntax will be removed in a future release. ... Add Padding Around Stairstep Plot ... x = 0:12; y = sin(x); stairs(x,y)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found