Skip to content

Line chart stacking (via dataset stack) doesn't work on initial render #11856

@NAndreasson

Description

@NAndreasson

Expected behavior

I expect the datasets/lines to be stacked on initial render.

Current behavior

The dataset/lines will be stacked after an update (i.e. two renders are needed before they become stacked).

Reproducible sample

https://codepen.io/NAndreasson/pen/gONREBm

Optional extra steps/info to reproduce

Click the button in the Codepen to trigger an update

Possible solution

I think the bug is related to the following:

https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js#L404-L414

In the first render, isStacked will return false which will affect _resyncElements. After updating isStacked will return true and the expected result will render.

Context

No response

chart.js version

v4.4.3

Browser name and version

No response

Link to your project

No response

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