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

[Bug]: mixed type with bar and line can not assign to data property #1010

Open
1 task
jchalex opened this issue Mar 14, 2023 · 0 comments
Open
1 task

[Bug]: mixed type with bar and line can not assign to data property #1010

jchalex opened this issue Mar 14, 2023 · 0 comments

Comments

@jchalex
Copy link

jchalex commented Mar 14, 2023

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

show the chart, but compile error

error TS2322: Type '{ labels: string[]; datasets: { label: string; data: number[]; type: string; }[]; }' is not assignable to type 'ChartData<"bar", (number | [number, number] | null)[], unknown>'.
  Types of property 'datasets' are incompatible.
    Type '{ label: string; data: number[]; type: string; }[]' is not assignable to type 'ChartDataset<"bar", (number | [number, number] | null)[]>[]'.
      Type '{ label: string; data: number[]; type: string; }' is not assignable to type 'ChartDataset<"bar", (number | [number, number] | null)[]>'.
        Type '{ label: string; data: number[]; type: string; }' is not assignable to type '_DeepPartialObject<{ type: "bar"; } & BarControllerDatasetOptions>'.
          Types of property 'type' are incompatible.
            Type 'string' is not assignable to type '"bar"'.

9           :data="data"

code

<Bar
  :data="data"
  :options="options"
/>
const data = {
  labels: TEST_MONTHS,
  datasets: [
    {
      label: 'num',
      data: [40, 20, 12, 11, 15, 22, 29, 35, 41, 22, 33, 30],
      type: 'bar',
    },
    {
      label: 'score',
      data: [40, 20, 12, 11, 15, 22, 29, 35, 41, 22, 33, 30],
      type: 'line',
    },
  ],
};
const options = {
  responsive: true,
  plugins: {
    title: {
      display: false,
      text: 'score',
    },
  },
};
const data: ChartData<'bar'|'line'> 

not work either

Reproduction

no

chart.js version

v4.2.1

vue-chartjs version

v5.2.0

Possible solution

No response

@palsingh palsingh mentioned this issue May 2, 2023
1 task
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

No branches or pull requests

1 participant