Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top of negative bar renders over zero line #6000

Closed
winterlimelight opened this issue Jan 21, 2019 · 3 comments · Fixed by #8648
Closed

Top of negative bar renders over zero line #6000

winterlimelight opened this issue Jan 21, 2019 · 3 comments · Fixed by #8648

Comments

@winterlimelight
Copy link

Expected Behavior

A bar is expected to have the zero-line as one of the borders

Current Behavior

Bars with negative values start from the zero-line, rather than below it, meaning they lack the top border.

Steps to Reproduce (for bugs)

https://jsfiddle.net/winter_limelight/zxd0b81c/9/

Note that the red line is absent from the Mar 18 bar.

var ctx = document.getElementById("chart").getContext('2d');
var chart = new Chart(ctx, {
  type: 'bar',
  data: {
    labels: ['Feb 18', 'Mar 18'],
    datasets: [{
      backgroundColor: '#AAFFCC',
      borderColor: '#0000FF',
      borderWidth: 1,
      data: [1, -1]
    }]
  },
  options: {
    scales: {
      yAxes: [{
        gridLines: {
          zeroLineColor: '#FF0000'
        },
      }]
    },
    maintainAspectRatio: false
  }
});

Setting maintainAspectRatio: true changes the border behaviour, but doesn't fix the issue.

Context

Presently trying to create chart showing historical +ve/-ve percentage changes for a client.

Environment

Chart.js version: 2.7.3
Browser name and version: Noted in Chrome 71, Firefox 64.

@kurkle
Copy link
Member

kurkle commented Jan 21, 2019

This is a bit different in master: https://jsfiddle.net/wkec8d9u/ (still a bug though IMO)

@etimberg
Copy link
Member

etimberg commented Jan 5, 2020

Tested master and now the red line is missing on the positive bar https://jsfiddle.net/pqfdrvz3/

@kurkle
Copy link
Member

kurkle commented Mar 16, 2021

dpr: 1
image

dpr: 1.25
image

dpr: 2.5
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants