Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 Gaps in stacked bar chart when datasets removed #8519

Closed
sdehm opened this issue Feb 24, 2021 · 2 comments · Fixed by #8520
Closed

v3 Gaps in stacked bar chart when datasets removed #8519

sdehm opened this issue Feb 24, 2021 · 2 comments · Fixed by #8520
Milestone

Comments

@sdehm
Copy link

sdehm commented Feb 24, 2021

Expected Behavior

When a dataset is spliced or shifted out of the array the stacked bars should drop to fill the space left by the missing data.

Current Behavior

When the data is specified in the Objects[] format, such as data: [{x: 10, y: 20}, {x: 15, y: 10}], gaps appear when datasets are spliced or shifted out.

Possible Solution

Looks like this might be similar to issues fixed in #6576. Here are some workarounds I've tested:

  • Don't use Object[] format for data
  • Set y-value for missing data to 0
  • When removing a dataset set the data to [] and keep the dataset rather than splicing it out

Steps to Reproduce

Create a stacked bar chart with data in Objects[] format and missing some values. Remove datasets by shifting or splicing.
Example codepen derived from sample stacked bar chart:
https://codepen.io/scdehmlow/pen/WNodogK

Context

Using Objects[] format for my data helps keep my interface to Chart.js clean and my datasets will not always have values for every x value. I will be clearing the data rather than removing datasets for now.

Environment

  • Chart.js version: 3.0.0-beta.11
  • Browser name and version: Chrome 88.0.4324.190
  • Link to your project:
@etimberg
Copy link
Member

I noticed the tooltip hover goes wrong too, so perhaps this is a general problem with the associated metadata.

@kurkle
Copy link
Member

kurkle commented Feb 24, 2021

I noticed the tooltip hover goes wrong too, so perhaps this is a general problem with the associated metadata.

Oh, did not notice that. Will have to re-check the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants