Skip to content

Stacked Floating Bars not rendered correctly #10774

Description

@nmakhari

Expected behavior

When I create a stacked bar chart, and provide [start,end] values as data (for floating bars) I should see the bars rendered between the specified values.

Current behavior

Depending on the size of the floating bars, and the order that they are rendered, floating bars in the same stack are rendered in the wrong spots.

Reproducible sample

https://codepen.io/nmakhari/pen/MWGzKeV

Optional extra steps/info to reproduce

If you change the bottom bar in the example to be [-5, 4] instead of [-4, 4] (although it seems that if the bottom bar is the same size or larger than the top one, the issue does not occur, this is not true. In my testing I was able to trigger the bug when this condition wasn't true).

The order property on the datasets also plays into this somehow, when the order is defined such that the top bar is rendered first, the issue does not occur. Unfortunately, in my testing, when the order was defined as such (greater value bars rendered first) the issue would still happen if you reverse the orientation of the bars across the y axis.

SO Question: https://stackoverflow.com/questions/74009641/stacked-bar-chart-with-floating-bars-does-not-render-correctly

Possible solution

No response

Context

I want to shift the bars in a stacked bar chart away from the origin by a fixed amount. I want the bars to have a certain magnitude, but I want them to start for example, at y = -30 and be rendered as if they were on the y axis.

More specifically, I'm using a horizontal chart, with stacked and grouped bars.

I was attempting to follow the solution here: https://stackoverflow.com/questions/63827750/how-can-i-change-the-starting-point-of-horizontal-bars-in-charts-js when I noticed errors using stacked bars in my project.

chart.js version

3.9.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