Skip to content

floating bars incorrectly offset by stacked base value #12197

@unreal639

Description

@unreal639

Expected behavior

Floating bars should be rendered at their absolute y coordinates regardless of the stacked configuration. Since a floating bar already encodes both its start and end position explicitly, it should not be offset by the cumulative stack value of other datasets.

Current behavior

When using floating bars (y: [start, end]) with stacked: true on a linear axis, some datasets are not rendered at all when multiple datasets share the same x value. This happens because the stacked base offset calculated by applyStack is incorrectly added to the absolute coordinates of the floating bar, pushing affected bars outside the visible scale range.

Reproducible sample

https://jsfiddle.net/g9kLhmbe/2/

Optional extra steps/info to reproduce

No response

Possible solution

Add a floatingBarMode option at the dataset level to distinguish between absolute and relative positioning of floating bars.

'absolute': the floating bar is rendered at its exact [start, end] coordinates, ignoring any stacked offset.
'relative': the floating bar is offset by the cumulative stack value of preceding datasets, preserving the current behavior.

To avoid a breaking change, floatingBarMode could default to 'relative' to preserve existing behavior.

Context

No response

chart.js version

v4.5.1

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