Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart data type is incorrect in 4.1.2 #11064

Open
tleunen opened this issue Jan 16, 2023 · 8 comments
Open

Chart data type is incorrect in 4.1.2 #11064

tleunen opened this issue Jan 16, 2023 · 8 comments
Labels
type: bug type: types Typescript type changes

Comments

@tleunen
Copy link

tleunen commented Jan 16, 2023

Expected behavior

The types for the Chart object has data: ChartData, but it should be data: ChartData<TType, TData, TLabel>; instead to have the dataset typed properly within the data. Otherwise it's the default types from DefaultDataPoint<TType>

export declare class Chart<
  TType extends ChartType = ChartType,
  TData = DefaultDataPoint<TType>,
  TLabel = unknown
> {
 // ...
  data: ChartData<TType, TData, TLabel>;
 // ...

Current behavior

export declare class Chart<
  TType extends ChartType = ChartType,
  TData = DefaultDataPoint<TType>,
  TLabel = unknown
> {
 // ...
  data: ChartData;
 // ...

Reproducible sample

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGzAJ5gCmK6MHgHNonAGroANgFc+AXkRs4cMgOGiAXHDowowAHZCWrZQDcpsrfukgARjyjHlZCJOgB+LTr2Hj2NhzcfGiYMAAqQXAKIbAAPABEkgY88QA0-IIiUOIWPADaALoAfAGsAPRlcAByEDDAZHxhqHwAIgLoEbxwACYQPHT6JPAYpnwwzXBcvHRwYISmwN083fiExDHhQYFdbTAdkdGUm7x5JN3tJAWMQA

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.1.2

Browser name and version

No response

Link to your project

No response

@LeeLenaleee
Copy link
Collaborator

Happend in #10963

@LeeLenaleee LeeLenaleee added the type: types Typescript type changes label Jan 17, 2023
@dangreen
Copy link
Collaborator

@tleunen Hi. It's not a bug, it is expected behavior. You should be able to change data in runtime. Please see the PR description that @LeeLenaleee mentioned.

@LeeLenaleee
Copy link
Collaborator

To be honest I think that this behaviour is more unwanted as the binding of the chart instance 🤔

@LeeLenaleee
Copy link
Collaborator

Also another issue got posted about this (see above linked issue), in my oppinion it would be better to revert the changes and see if we can solve it another way because this way of working seems way more likely to me as having a runtime change and the downside of dealing with that

@elPandaFriki
Copy link

I've returned to version 4.0.1 until a solution has been decided.

@LeeLenaleee
Copy link
Collaborator

@etimberg @kurkle what are your oppinions about this?

@etimberg
Copy link
Member

A revert probably makes sense unless we can find a way to fix it. @dangreen thoughts?

@dangreen
Copy link
Collaborator

@etimberg I've made the PR

@dangreen dangreen reopened this Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: types Typescript type changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants