Skip to content

Wrong bar width with multiple x-Axis #12262

@hokolomopo

Description

@hokolomopo

Expected behavior

If we create a bar chart that has both a bar dataset and a line dataset (both on different axis), the bars should take the full width of the scale tick.

Current behavior

The bars only take half of the available space when we add a line dataset, even though the line has no impact on the available space for the bars.

Image

Reproducible sample

https://codepen.io/Adrien-Minne/pen/azBYbYw?editors=0010

Optional extra steps/info to reproduce

Issue is present since version 4.5, specifically with this commit: 8ea47ca. Previous versions didn't have this issue.

Possible solution

Commit 8ea47ca divide the available space by the number of axis, but it should only consider the axis that contains bar datasets.

Context

No response

chart.js version

4.5.1

Browser name and version

Chrome Version 148.0.7778.167 (Official Build) (64-bit)

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions