Skip to content

Axis labels removed by the auto skip functionality are still considered for sizing purposes #3694

@ste2425

Description

@ste2425

Expected Behavior

When padding the bottom of a chart to make space for xAxis labels it should only pad for rendered labels, not all labels.

Current Behavior

If a dataset has a long xAxis label, but the chart is small and that label not rendered the chart has extra padding on the bottom to accommodate that label. Results in potentially a large amount of white space under the chart.

Possible Solution

Not entirely sure how the amount of padding needed is calculated but it appears it is performed before the list of labels to render is filtered down. Potentially move this process to after?

Steps to Reproduce (for bugs)

Fiddle

The top chart does not occupy the full height of its container. The bottom chart shows it's the label 'Autoenrolment' that it is accounting for, even though it is not rendered in the top chart.

Context

Chartjs is being used within Angular-Gridster, so the charts resize to their container, those containers are not always square so we turn off maintainAspectRatio.

The issue is the grid has to fit within a relatively small space (No matter how much we try this requirement cannot change) Which means you could potentially make rather small charts. (As big as the small example in the fiddle). Chartjs does a great job of managing this, except for the padding used to accommodate the Axislabels.

Environment

  • Chart.js version: 2.3.0 & 2.0.0 (Used in fiddle)
  • Browser name and version: Chrome latest, IE 11, FF latest

EDIT: Also present in the latest master

Workaround

As a workaround i have had to truncate my labels so that they are at a more uniformed length, using the ticks callback. Then use the tooltip callbacks to present the user with the full length tooltip.

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