Skip to content

Commit

Permalink
fix: updated type for doughnut offset (#11051)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlankamp committed Jan 13, 2023
1 parent be049a3 commit 0e189dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/charts/doughnut.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The doughnut/pie chart allows a number of properties to be specified for each da
| [`hoverBorderJoinStyle`](#interactions) | `'round'`\|`'bevel'`\|`'miter'` | Yes | Yes | `undefined`
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
| [`hoverOffset`](#interactions) | `number` | Yes | Yes | `0`
| [`offset`](#styling) | `number` | Yes | Yes | `0`
| [`offset`](#styling) | `number`\|`number[]` | Yes | Yes | `0`
| [`rotation`](#general) | `number` | - | - | `undefined`
| [`spacing`](#styling) | `number` | - | - | `0`
| [`weight`](#styling) | `number` | - | - | `1`
Expand Down
4 changes: 2 additions & 2 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export interface DoughnutControllerDatasetOptions
/**
* Arc offset (in pixels).
*/
offset: number;
offset: number | number[];

/**
* Starting angle to draw this dataset from.
Expand Down Expand Up @@ -313,7 +313,7 @@ export interface DoughnutControllerChartOptions {
/**
* Arc offset (in pixels).
*/
offset: number;
offset: number | number[];

/**
* The outer radius of the chart. String ending with '%' means percentage of maximum radius, number means pixels.
Expand Down
29 changes: 29 additions & 0 deletions test/types/controllers/doughnut_spacing_offset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Chart, ChartMeta, Element } from '../../../src/types.js';

const chart = new Chart('id', {
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],
}
});

0 comments on commit 0e189dd

Please sign in to comment.