chartjs / chartjs/Chart.js

Toggle data visibility for bar charts should expand remaining bars to fill the space

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

Description

### Feature Proposal

Currently, toggling data (not dataset) visibility for bar charts causes a bar to animate away, leaving an empty column where it used to be. This feels not very useful, as the space isn't reclaimed. I think the real value of hiding some bars is to allow the remaining ones to be more legible, by using that space.

For example, a dataset containing 50 unique datapoints could show only 10 of them, and have a legend which allows toggling each category. As new ones are checked, the bars would shrink and include a new one. With the current setup, the initial 10 would only use 20% of the chart area. I don't see a way around this other than passing in a different dataset as categories are checked, which feels redundant with the visibility state within chartjs.

Related to https://github.com/chartjs/Chart.js/issues/6418

### Possible Implementation

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