Skip to content

fix(types): add [number, number] tuple support for line and scatter chart defaultDataPoint#12250

Open
subodhbhyri wants to merge 1 commit intochartjs:masterfrom
subodhbhyri:fix/tuple-data-types-12232
Open

fix(types): add [number, number] tuple support for line and scatter chart defaultDataPoint#12250
subodhbhyri wants to merge 1 commit intochartjs:masterfrom
subodhbhyri:fix/tuple-data-types-12232

Conversation

@subodhbhyri
Copy link
Copy Markdown

Problem

When using an array of tuples ([number, number][]) as dataset data on a line
or scatter chart, TypeScript raises:

Type '[number, number]' is not assignable to type 'ScatterDataPoint | number | null'

This is despite tuples being a documented data structure
and already being supported for bar charts via [number, number] in its defaultDataPoint.

Fixes #12232

Changes

  • Added [number, number] to defaultDataPoint for line and scatter in src/types/index.d.ts, matching the existing bar chart behavior
  • Added type test cases in test/types/dataset_null_data.ts and test/types/data_types.ts to cover both ChartDataset and full new Chart(...) instantiation with tuple data

Scope

This PR fixes the TypeScript type error only. The runtime issue (line not
rendering when parsing: false is set with tuple data) is a separate problem
in the data parsing pipeline and is not addressed here.

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.

Array of tuples data structure not working when parsing is disabled

1 participant