Skip to content

Keep hidden bars collapsed when minBarLength is set - #12372

Open
hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix-hidden-bar-minimum-length
Open

hakarrr wants to merge 2 commits into
chartjs:masterfrom
hakarrr:fix-hidden-bar-minimum-length

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 26, 2026

Copy link
Copy Markdown

Problem

toggleDataVisibility(index) should hide a bar, but _calculateBarValuePixels() applies minBarLength after collapsing its head to its base. The minimum length makes the hidden bar visible again. For example, hiding a 0.01 value with minBarLength: 45 leaves a roughly 45px bar on the canvas.

Change

Read the item's visibility once and only apply the minimum-length adjustment to visible items. Hidden bars retain their collapsed geometry; visible zero, small, negative and floating bars keep their minimum lengths. This does not change dataset visibility, stacking order, per-bar base resolution or border selection.

Tests

Added 40 cases covering both index axes, reversed value scales, stacked and unstacked charts, zero/small positive/small negative/floating values, repeated updates and hide/show restoration. Cross-dataset controls check that other bars stay in place, including charts without a minimum length. Hidden canvas pixels are checked too.

On unmodified master, 36 new cases fail and 4 controls pass. With this change, a fresh frozen-lockfile install passes all 1743 native Karma/Chromium cases, the production build, declaration generation and tsc --noEmit. Scoped ESLint has no errors and five existing warning locations; the already-warned value-pixel method gains one statement and one complexity point. Firefox and downstream integration tests were not run locally.

The original bar visibility support is #7870. Minimum-length behavior from #9400, #10157 and #10766 is retained for visible bars.

hakarrr and others added 2 commits October 26, 2026 22:06
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant