From: Jukka Kurkela Date: Sat, 16 Jan 2021 21:04:48 +0000 (+0200) Subject: Doughnut: complete radians to degrees conversion (#8321) X-Git-Tag: v3.0.0-beta.10~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c64bc88e8b71f0a0b588e0177c39a8ca90f06bb;p=thirdparty%2FChart.js.git Doughnut: complete radians to degrees conversion (#8321) --- diff --git a/docs/docs/charts/doughnut.mdx b/docs/docs/charts/doughnut.mdx index e5758478f..a9b929eb4 100644 --- a/docs/docs/charts/doughnut.mdx +++ b/docs/docs/charts/doughnut.mdx @@ -164,8 +164,8 @@ These are the customisation options specific to Pie & Doughnut charts. These opt | Name | Type | Default | Description | ---- | ---- | ------- | ----------- | `cutoutPercentage` | `number` | `50` - for doughnut, `0` - for pie | The percentage of the chart that is cut out of the middle. -| `rotation` | `number` | `-0.5 * Math.PI` | Starting angle to draw arcs from. -| `circumference` | `number` | `2 * Math.PI` | Sweep to allow arcs to cover. +| `rotation` | `number` | 0 | Starting angle to draw arcs from. +| `circumference` | `number` | 360 | Sweep to allow arcs to cover. | `animation.animateRotate` | `boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object. | `animation.animateScale` | `boolean` | `false` | If true, will animate scaling the chart from the center outwards. diff --git a/docs/docs/getting-started/v3-migration.md b/docs/docs/getting-started/v3-migration.md index 1877fd60f..0e2e86e7e 100644 --- a/docs/docs/getting-started/v3-migration.md +++ b/docs/docs/getting-started/v3-migration.md @@ -72,7 +72,7 @@ A number of changes were made to the configuration options passed to the `Chart` * Polar area `elements.arc.angle` is now configured in degrees instead of radians. * Polar area `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`. * Doughnut `rotation` option is now in degrees and 0 is at top. Default is changed from `-½π` to `0`. -* Doughnut `circumference` option is now in degrees. Default is changed from `2π` to `0`. +* Doughnut `circumference` option is now in degrees. Default is changed from `2π` to `360`. * `scales.[x/y]Axes` arrays were removed. Scales are now configured directly to `options.scales` object with the object key being the scale Id. * `scales.[x/y]Axes.barPercentage` was moved to dataset option `barPercentage` * `scales.[x/y]Axes.barThickness` was moved to dataset option `barThickness` diff --git a/samples/charts/doughnut.html b/samples/charts/doughnut.html index 4373c99c5..358213bc4 100644 --- a/samples/charts/doughnut.html +++ b/samples/charts/doughnut.html @@ -143,12 +143,12 @@ }); document.getElementById('changeCircleSize').addEventListener('click', function() { - if (window.myDoughnut.options.circumference === Math.PI) { - window.myDoughnut.options.circumference = 2 * Math.PI; - window.myDoughnut.options.rotation = -Math.PI / 2; + if (window.myDoughnut.options.circumference === 180) { + window.myDoughnut.options.circumference = 360; + window.myDoughnut.options.rotation = -45; } else { - window.myDoughnut.options.circumference = Math.PI; - window.myDoughnut.options.rotation = -Math.PI; + window.myDoughnut.options.circumference = 180; + window.myDoughnut.options.rotation = -90; } window.myDoughnut.update(); diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index 28f48da17..a018fa5ef 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -233,13 +233,13 @@ export interface DoughnutControllerDatasetOptions /** * Sweep to allow arcs to cover. - * @default 2 * Math.PI + * @default 360 */ circumference: number; /** * Starting angle to draw this dataset from. - * @default -0.5 * Math.PI + * @default 0 */ rotation: number; @@ -273,13 +273,13 @@ export interface DoughnutControllerChartOptions { /** * Starting angle to draw arcs from. - * @default -0.5 * Math.PI + * @default 0 */ rotation: number; /** * Sweep to allow arcs to cover. - * @default 2 * Math.PI + * @default 360 */ circumference: number;