chartjs / chartjs/Chart.js

fill:'stack' consider dataset out of the stack

Open
#11,012 3 comments 2 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

When a dataset in a stack with fill `stack`, only dataset of this stack should be consider as fill source.

In the example bellow the datasets are on the same y axis. The y axis is stacked `true`.
The dataset A is in this own stack rather the dataset B and C are in the same stack.

![image](https://user-images.githubusercontent.com/116173421/208923895-758a8e48-2fc7-4d0e-85a1-7f90607e1b60.png)

To achieve this visual the dataset B is in fill `origin` instead of stack. This is problematic since when it's hidden the problem will appear again.

### Current behavior

The dataset in a stack with fill `stack` will consider as source dataset in different stack from same axis.

In the example bellow the dataset A is used as source to fill the area of dataset B, even if A and B are in different stack.

![image](https://user-images.githubusercontent.com/116173421/208926868-80820fd6-d24b-4dd3-b394-a5b92df5f3dd.png)

### Reproducible sample

https://jsfiddle.net/kfqu3zts/4/

### Optional extra steps/info to reproduce

_No response_

### Possible solution

When [building](https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.stack.js) the stack line consider only the visible dataset in the same stack if defined.

### Context

_No response_

### chart.js version

4.1.1

### Browser name and version

_No response_

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.