Skip to content

Draw points beyond scale limits when clip is disabled - #12347

Open
abdull-ah-med wants to merge 1 commit into
chartjs:masterfrom
abdull-ah-med:fix/clip-false-trimmed-points
Open

abdull-ah-med wants to merge 1 commit into
chartjs:masterfrom
abdull-ah-med:fix/clip-false-trimmed-points

Conversation

@abdull-ah-med

Copy link
Copy Markdown

Fixes #11899

When a dataset sets clip: false, the line and scatter controllers still drop points that fall outside the index scale's user-defined min/max (_getStartAndCountOfVisiblePoints). Those points would be drawn outside the chart area, so with clipping disabled they — and the line segments leading to them — just disappear, which is what the codepen in the issue shows.

Changes

  • _getStartAndCountOfVisiblePoints takes the dataset's clip option and ignores the index scale's min (or max) bound when clipping is disabled on the corresponding side of the chart area. clip: false disables both bounds; the per-side form (e.g. clip: {left: false, top: 0, right: 0, bottom: 0}) only keeps points beyond the unclipped side, taking reverse and vertical index axes into account.
  • LineController and ScatterController pass this.options.clip.
  • Behaviour with the default clip (or numeric clip values) is unchanged, so the existing trimming optimization still applies in the common case.

Tests

  • New specs in controller.line.tests.js (clip: false, per-side clip, per-side clip with a reversed scale) and controller.scatter.tests.js (clip: false). They fail on master and pass with the change.
  • pnpm lint (eslint, markdown lint, type tests) passes.
  • Full karma suite in Chrome: 1699 passed, 7 failed. The same 7 image-fixture specs (filler above-below-vertical-linechart, drawTimeFillFalse/*, radialLinear ticks-below-zero, time ticks-round, timeseries data-timestamps) fail identically on unchanged master on my machine, so they're environment-related.

Note: the filler plugin still clips fill to the index scale bounds (#12283), so with clip: false the line now extends beyond min/max while any area fill stays within them. I left that alone to keep this focused; happy to extend it if you'd like the fill to follow.

This change was prepared with AI assistance; I reviewed the diff and test results.

Line and scatter controllers skip points outside the index scale's
user-defined min/max. When the dataset's `clip` is `false` (or false on
the matching side), those points are visible outside the chart area, so
they should not be trimmed.

Fixes chartjs#11899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant