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

fix: updated type for doughnut offset #11051

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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],
}
});