-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
[Bug]: Wrong typings for Bar component #1058
Comments
I am having the same problem, this must be fixed. But for now, do you have a workaround? Because right now typescript check fails and we are not able to build the project. |
Because of this issue, I switch to Google Charts and it solve my problem. |
then use it to type your data variable:
|
same problem. according to chart.js docs, internal format for bar chart is
which is kind of extended |
I use casting to const dataset: any = apiData.map(d => ({x: ..., y: ...}));
...
{
datasets: [ dataset as ChartData<'bar'> ]
} |
The issue should be resolved in the latest version of vue-chartjs. As soon as the main lib's related PR is merged, I will restore the previous algorithm of type generation, since the original issue is related to the Chart.js |
UPD: Chart.js supports generic types so you can easily provide own type of the data while initializing a chart, so there's no issue with Chart.js itself (see comment here). The interface fix for this issue is already in the main vue-chartjs branch, but I will try to rethink this solution via Vue generic components |
Would you like to work on a fix?
Current and expected behavior
Bar component has these typings in
vue-chartjs/dist/typedCharts.d.ts
:The chart data can be also an array of objects like
[{ x: Date; y: number }]
or similar. When I provide such data type to the Bar component, I receive related type errors from vue-tsc:In the reproduction section, don't forget to run project in the TypeScript workspace (the sandbox has JS workspace so you will not see any errors)
Reproduction
https://stackblitz.com/edit/github-ucglyx?file=src%2FApp.vue
chart.js version
v4.4.0
vue-chartjs version
v5.2.0
Possible solution
Adjust the typings
The text was updated successfully, but these errors were encountered: