Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d464ba2

Browse files
committed
startAngle in degrees, 0 at top.
1 parent 2388eea commit d464ba2

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

docs/charts/polar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ These are the customisation options specific to Polar Area charts. These options
5959

6060
| Name | Type | Default | Description
6161
| ---- | ---- | ------- | -----------
62-
| `startAngle` | `Number` | `-0.5 * Math.PI` | Starting angle to draw arcs for the first item in a dataset.
62+
| `startAngle` | `Number` | `0` | Starting angle to draw arcs for the first item in a dataset. In degrees, 0 is top.
6363
| `animation.animateRotate` | `Boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object.
6464
| `animation.animateScale` | `Boolean` | `true` | If true, will animate scaling the chart from the center outwards.
6565

src/controllers/controller.polarArea.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defaults._set('polarArea', {
2828
animateScale: true
2929
},
3030

31-
startAngle: -0.5 * Math.PI,
31+
startAngle: 0,
3232
legendCallback: function(chart) {
3333
var text = [];
3434
text.push('<ul class="' + chart.id + '-legend">');
@@ -119,14 +119,15 @@ module.exports = DatasetController.extend({
119119
var me = this;
120120
var dataset = me.getDataset();
121121
var meta = me.getMeta();
122-
var start = me.chart.options.startAngle || 0;
122+
var start = helpers.toRadians(me.chart.options.startAngle || 0);
123123
var starts = me._starts = [];
124124
var angles = me._angles = [];
125125
var i, ilen, angle;
126126

127127
me._updateRadius();
128128

129129
meta.count = me.countVisibleElements();
130+
start -= Math.PI / 2.0; // radialLinear scale excepts 0 to be at top
130131

131132
for (i = 0, ilen = dataset.data.length; i < ilen; i++) {
132133
starts[i] = start;
@@ -171,8 +172,8 @@ module.exports = DatasetController.extend({
171172
var centerX = scale.xCenter;
172173
var centerY = scale.yCenter;
173174

174-
// var negHalfPI = -0.5 * Math.PI;
175-
var datasetStartAngle = opts.startAngle;
175+
var negHalfPI = -0.5 * Math.PI;
176+
var datasetStartAngle = helpers.toRadians(opts.startAngle) + negHalfPI;
176177
var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
177178
var startAngle = me._starts[index];
178179
var endAngle = startAngle + (arc.hidden ? 0 : me._angles[index]);

src/scales/scale.radialLinear.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,7 @@ module.exports = function(Chart) {
454454
this.chart.options.startAngle :
455455
0;
456456

457-
var startAngleRadians = startAngle * Math.PI * 2 / 360;
458-
459-
// Start from the top instead of right, so remove a quarter of the circle
460-
return index * angleMultiplier + startAngleRadians;
457+
return index * angleMultiplier + helpers.toRadians(startAngle);
461458
},
462459
getDistanceFromCenterForValue: function(value) {
463460
var me = this;

test/specs/controller.polarArea.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe('Chart.controllers.polarArea', function() {
172172
showLines: true,
173173
legend: false,
174174
title: false,
175-
startAngle: 0, // default is -0.5 * Math.PI
175+
startAngle: 90, // default is 0
176176
elements: {
177177
arc: {
178178
backgroundColor: 'rgb(255, 0, 0)',

0 commit comments

Comments
 (0)