Skip to content

Top of negative bar renders over zero line #6000

@winterlimelight

Description

@winterlimelight

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions