Skip to content

[BUG] Tick text extents not calculated correctly #4502

@mMerlin

Description

@mMerlin

Expected Behaviour

No space should be included in the chart layout for scaleLabel axis content, when no scaleLabel is being displayed.

Current Behaviour

Since PR #4268 (Time axis ticks formatting for base and senior unit) from @hurskiy-andriy, the chart body is being positioned on the canvas as if axis scaleLabels where being displayed. Untested, but this may only occur when using a time type axis.

Possible solution

I have looked at the code changes introduced by the PR, but so far have not seen anything obvious that introduced the new result.

Steps to reproduce

var graphPoints = [
  {x: 1496998541000, y: 0},
  {x: 1496998541000, y: 7.5},
  {x: 1497007069000, y: 15},
  {x: 1497009140000, y: 22.5},
  {x: 1497009255000, y: 30},
  {x: 1497009300001, y: 37.5}
];

var sensorGraph = new Chart(document.getElementById("myCanvas").getContext("2d"), {
    type: "scatter",
    data: {
        datasets: [{
            data: graphPoints
        }]
    },
    options: {
        scales: {
            xAxes: [{
                type: "time",
            }]
        }
    }
});

Context

2d7c1f0 #4268 introduced a problem with layout for scale labels on Jun 15 14:20:16 2017 . The space needed to place them is being reserved, even when they are not displayed. This is true if no Axis scaleLabel option information is included, or if that is explicitly set to display: false. It looks correct if a scaleLabel is displayed, and seems to use exactly the same amount of space that is being left blank without the scaleLabel.

Environment

  • Chart.js after v2.6.0
  • Firefox 54.0 (64-bit) on Fedora 24

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions