Skip to content

Commit a8838da

Browse files
committed
draw sectors that span more than 2pi as 'full' circle
1 parent 8589d99 commit a8838da

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/lib/angles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ function rad2deg(rad) { return rad / PI * 180; }
2323
* is sector a full circle?
2424
* ... this comes up a lot in SVG path-drawing routines
2525
*
26+
* N.B. we consider all sectors that span more that 2pi 'full' circles
27+
*
2628
* @param {2-item array} aBnds : angular bounds in *radians*
2729
* @return {boolean}
2830
*/
2931
function isFullCircle(aBnds) {
30-
return Math.abs(Math.abs(aBnds[1] - aBnds[0]) - twoPI) < 1e-15;
32+
return Math.abs(aBnds[1] - aBnds[0]) > twoPI - 1e-15;
3133
}
3234

3335
/**

src/plots/polar/set_convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function setConvertAngular(ax, polarLayout) {
166166
// Set the angular range in degrees to make auto-tick computation cleaner,
167167
// changing rotation/direction should not affect the angular tick value.
168168
ax.range = Lib.isFullCircle(sectorInRad) ?
169-
sector.slice() :
169+
[sector[0], sector[0] + 360] :
170170
sectorInRad.map(g2rad).map(rad2deg);
171171
break;
172172

test/image/mocks/polar_sector.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@
11431143
"polar20": {
11441144
"sector": [
11451145
-180,
1146-
180
1146+
200
11471147
],
11481148
"bgcolor": "#d3d3d3",
11491149
"domain": {

0 commit comments

Comments
 (0)