Skip to content

[Bug]: Wrong typings for Bar component #1058

@Oleksii14

Description

@Oleksii14

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

Bar component has these typings in vue-chartjs/dist/typedCharts.d.ts:

export declare const Bar: TypedChartComponent<"bar", (number | [number, number] | null)[], unknown>;

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:

Type '{ datasets: { label: string; data: { x: Date; y: number; }[]; backgroundColor: string; grouped: boolean; maxBarThickness: number; }[]; }' is not assignable to type 'ChartData<"bar", (number | [number, number] | null)[], unknown>'.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions