Skip to content

Commit d4c7d2c

Browse files
committed
default *rotation* to 90 for clockwise *direction*
1 parent 4d5a1bd commit d4c7d2c

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

src/plots/polar/layout_attributes.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ var angularAxisAttrs = {
200200
direction: {
201201
valType: 'enumerated',
202202
values: ['counterclockwise', 'clockwise'],
203-
// we could make the default 'clockwise' for category and date angular axes
204203
dflt: 'counterclockwise',
205204
role: 'info',
206205
editType: 'calc',
@@ -211,16 +210,15 @@ var angularAxisAttrs = {
211210

212211
rotation: {
213212
valType: 'angle',
214-
// we could maybe make `rotation: 90` by default for category and date angular axes
215-
dflt: 0,
216213
editType: 'calc',
217214
role: 'info',
218215
description: [
219216
'Sets that start position (in degrees) of the angular axis',
220-
'Note that by default, polar subplots are orientation such that the theta=0',
221-
'corresponds to a line pointing right (like what mathematicians prefer).',
222-
'For example to make the angular axis start from the North (like on a compass),',
223-
'set `angularaxis.rotation` to *90*.'
217+
'By default, polar subplots will `direction` set to *counterclockwise*',
218+
'get a `rotation` of *0*',
219+
'which corresponds to due East (like what mathematicians prefer).',
220+
'In turn, polar with `direction` set to *clockwise* get a rotation of *90*',
221+
'which corresponds to due North (like on a compass),'
224222
].join(' ')
225223
},
226224

src/plots/polar/layout_defaults.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ function handleDefaults(contIn, contOut, coerce, opts) {
119119
coerceAxis('period');
120120
}
121121

122-
// TODO maybe by default: non-linear axis
123-
// should get direction: 'clockwise' + rotation: 90
124-
coerceAxis('direction');
125-
coerceAxis('rotation');
122+
var direction = coerceAxis('direction');
123+
coerceAxis('rotation', {counterclockwise: 0, clockwise: 90}[direction]);
126124

127125
setConvertAngular(axOut);
128126
break;
-466 Bytes
Loading

test/image/mocks/polar_categories.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
},
4949
"radialaxis": {
5050
"angle": 45
51+
},
52+
"angularaxis": {
53+
"direction": "clockwise"
5154
}
5255
},
5356
"polar2": {

test/jasmine/tests/polar_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ describe('Test polar plots defaults:', function() {
130130
expect(layoutOut.polar.radialaxis.linecolor).toBe('blue');
131131
expect(layoutOut.polar.radialaxis.gridcolor).toBe('rgb(153, 153, 255)', 'blend by 60% with bgcolor');
132132
});
133+
134+
it('should default *rotation* to 90 when clockwise *direction*', function() {
135+
_supply({
136+
polar: {}
137+
});
138+
139+
expect(layoutOut.polar.angularaxis.direction).toBe('counterclockwise');
140+
expect(layoutOut.polar.angularaxis.rotation).toBe(0);
141+
142+
_supply({
143+
polar: {
144+
angularaxis: {direction: 'clockwise'}
145+
}
146+
});
147+
148+
expect(layoutOut.polar.angularaxis.direction).toBe('clockwise');
149+
expect(layoutOut.polar.angularaxis.rotation).toBe(90);
150+
});
133151
});
134152

135153
describe('Test relayout on polar subplots:', function() {

0 commit comments

Comments
 (0)