Skip to content

Commit b5e6ba7

Browse files
committed
feat(polar): supports radius array for polar
1 parent e50f049 commit b5e6ba7

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

src/component/axis/AngleAxisView.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,24 @@ export default AxisView.extend({
9696
_axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
9797
var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
9898

99-
var circle = new graphic.Circle({
100-
shape: {
101-
cx: polar.cx,
102-
cy: polar.cy,
103-
r: radiusExtent[getRadiusIdx(polar)]
104-
},
105-
style: lineStyleModel.getLineStyle(),
106-
z2: 1,
107-
silent: true
108-
});
109-
circle.style.fill = null;
110-
111-
this.group.add(circle);
99+
for (var rx = 0; rx < radiusExtent.length; ++rx) {
100+
// Draw a circle for radius like [0, 100], and two circles for [20, 100]
101+
if (radiusExtent[rx] > 0) {
102+
var circle = new graphic.Circle({
103+
shape: {
104+
cx: polar.cx,
105+
cy: polar.cy,
106+
r: radiusExtent[rx]
107+
},
108+
style: lineStyleModel.getLineStyle(),
109+
z2: 1,
110+
silent: true
111+
});
112+
circle.style.fill = null;
113+
114+
this.group.add(circle);
115+
}
116+
}
112117
},
113118

114119
/**

src/coord/polar/polarCreator.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,23 @@ function resizePolar(polar, polarModel, api) {
4747

4848
var radiusAxis = polar.getRadiusAxis();
4949
var size = Math.min(width, height) / 2;
50-
var radius = parsePercent(polarModel.get('radius'), size);
50+
51+
var radius = polarModel.get('radius');
52+
if (radius == null) {
53+
radius = [0, "100%"];
54+
}
55+
else if (typeof radius === 'number' || typeof radius === 'string') {
56+
// r0 = 0
57+
radius = [0, radius];
58+
}
59+
radius = [
60+
parsePercent(radius[0], size),
61+
parsePercent(radius[1], size)
62+
];
63+
5164
radiusAxis.inverse
52-
? radiusAxis.setExtent(radius, 0)
53-
: radiusAxis.setExtent(0, radius);
65+
? radiusAxis.setExtent(radius[1], radius[0])
66+
: radiusAxis.setExtent(radius[0], radius[1]);
5467
}
5568

5669
/**

0 commit comments

Comments
 (0)