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

Wrong typing for offset for Doughnut #11050

Closed
mlankamp opened this issue Jan 12, 2023 · 0 comments · Fixed by #11051
Closed

Wrong typing for offset for Doughnut #11050

mlankamp opened this issue Jan 12, 2023 · 0 comments · Fixed by #11051

Comments

@mlankamp
Copy link
Contributor

Expected behavior

The offset should be defined as an number of number array.

export interface DoughnutControllerDatasetOptions{
  /**
   * Arc offset (in pixels).
   */
-  offset: number;
+  offset: number | number[];
}

export interface DoughnutControllerChartOptions {
  /**
   * Arc offset (in pixels).
   */
-  offset: number;
+  offset: number | number[];
}

Current behavior

According to the test https://github.com/chartjs/Chart.js/blob/master/test/fixtures/controller.doughnut/doughnut-spacing-and-offset.js the offset can be an array of numbers, but the typing in DoughnutControllerDatasetOptions and DoughnutControllerChartOptions describe it as a number

Reproducible sample

https://www.typescriptlang.org/play?ssl=32&ssc=1&pln=1&pc=1#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGwG6ZxkwAecALxwAJhDIBXEAFMAdjCoBzaTACiAG2kz5AIQCeASREAKAEQg9aTDFMBKOOjpwAEgBUAsgBlk6WVzoaWnIwLKxcUHAWVljCstIA7iiUMMa8fAA0iGxwOXAwemDSAFykYhKKqLISMCTp2bki6DDoJQj1uaJNjip0JQDabawdHY3N-QCMAAyZAEzTcAAs8wCsKwC6dUPDOeroAEbS6iUkACJddCpw47Xtw3voZADWioQSsiLIEOrQ-bfbJFBpCIblttjkSNBfMoQWDciQ9IdvvEYbDSC9pHIUbCSHt1BJpCQ-rk1kTsBsibsDupenA+kTwQYYForljhiRGcyZqyOuymcQAMzcuEc4gLIUMvlwZaE0HEzYdbDy3IQMAwYAQWQ0wbbOhgB7AWSKEqrJUdCB4PAXGD9FbzO2ZSbk2XYeou1jYWyhIA

Optional extra steps/info to reproduce

This typescipt example is the code from https://github.com/chartjs/Chart.js/blob/master/test/fixtures/controller.doughnut/doughnut-spacing-and-offset.js

import { Chart } from 'chart.js';

var ctx = document.getElementById("myChart") as HTMLCanvasElement;
var myChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
      datasets: [{
        data: [10, 20, 40, 50, 5],
        label: 'Dataset 1',
        backgroundColor: [
          'red',
          'orange',
          'yellow',
          'green',
          'blue'
        ]
      }],
      labels: [
        'Item 1',
        'Item 2',
        'Item 3',
        'Item 4',
        'Item 5'
      ],
    },
    options: {
      spacing: 50,
      offset: [0, 50, 0, 0, 0], /* typings error */
    }
  }
});

Possible solution

No response

Context

No response

chart.js version

v3.7.0 and v4.1.2

Browser name and version

No response

Link to your project

No response

@mlankamp mlankamp changed the title Missing typing for offset for Doughnut Wrong typing for offset for Doughnut Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant