Skip to content

Fix appending data while decimation is active - #12284

Open
tianrking wants to merge 1 commit into
chartjs:masterfrom
tianrking:codex/decimation-live-data-appends
Open

Fix appending data while decimation is active#12284
tianrking wants to merge 1 commit into
chartjs:masterfrom
tianrking:codex/decimation-live-data-appends

Conversation

@tianrking

Copy link
Copy Markdown

Fixes #11929

When decimation first runs, the plugin stores the original array in _data but makes the public dataset.data getter return _decimated. Appending through the documented dataset.data.push(...) path therefore updates only a temporary sampled array, while the next decimation pass still reads stale raw data.

This keeps dataset.data backed by the user-supplied raw array and makes dataset controllers consume _decimated internally. Scriptable contexts, segment contexts, and tooltip items now resolve raw from the controller data so their indices continue to match the rendered sample. Existing decimation assertions use the rendered metadata length, and a regression test appends through the public data array and verifies the raw length, parsed tail, controller context, and tooltip item.

Tests

  • Test-first regression: raw length remained 10 instead of 11; parsed tail remained {x: 9, y: 9} instead of {x: 10, y: 10}
  • Tooltip test-first check: old lookup returned {x: 4, y: 4} instead of the rendered tail point
  • Targeted Karma suites: decimation 6/6, tooltip 40/40, dataset controller 44/44, line 102/102, scatter 9/9
  • Full Karma suite: 1703/1703
  • pnpm lint-js — 0 errors
  • pnpm build with pnpm 8.13.0

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.

Chart with live data source + decimation + zoom plugins not drawing new points when samples exceed decimation threshold

1 participant