chartjs / chartjs/Chart.js

Array of tuples data structure not working when parsing is disabled

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

Description

When switching from an [array of objects](https://chartjs.org/docs/latest/general/data-structures.html#object) to an [array of tuples](https://chartjs.org/docs/latest/general/data-structures.html#array) on a line chart, I get the following TypeScript error:

> Type '[number, number]' is not assignable to type 'number | Point | null'.

Furthermore, with parsing set to false, provided I erase type information through casts to `any` to skip TypeScript's checks, the line stops being drawn on the chart, so I am unable to apply this [recommended performance optimization](https://chartjs.org/docs/latest/general/performance.html#automatic-data-decimation-during-draw):

> Provide prepared data in the internal format accepted by the dataset and scales, and set `parsing: false`. See [Data structures](https://chartjs.org/docs/latest/general/data-structures.html) for more information.

### Reproducible sample

- [TypeScript issue](https://typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYQBYENYBoUdgEXRnTgF84AzKCEOAcgGM8YA6AKwGc6BuAWACgBDCADsO8ACZF0ALlyYYhYgB46AG2AiApnQB8cALyIBcOFOIctMDnIDaCE6acB6Z2el2kADzkAGHACefmQ43nIAjP5wQXCRZAC6cK5wAOrQANaaAOaOTu7EdrZRvvE4tpE4kfGJyQByEPAA7hnZuQkCpHyC-NqN8rAAFBIQDACuIFoirACOo1pQAQDKWmpaDDDQA4zoIgBu6FwAlACEoY4wAWBacuqaOliO5ugdh11AA)
- [Runtime issue](https://codepen.io/inad9300/pen/QwKVvaY?editors=0010)

### chart.js version

v4.5.1

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.