Skip to content

Commit

Permalink
feat(polar): supports radius array for polar
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Oct 15, 2019
1 parent e50f049 commit b5e6ba7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
31 changes: 18 additions & 13 deletions src/component/axis/AngleAxisView.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,24 @@ export default AxisView.extend({
_axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');

var circle = new graphic.Circle({
shape: {
cx: polar.cx,
cy: polar.cy,
r: radiusExtent[getRadiusIdx(polar)]
},
style: lineStyleModel.getLineStyle(),
z2: 1,
silent: true
});
circle.style.fill = null;

this.group.add(circle);
for (var rx = 0; rx < radiusExtent.length; ++rx) {
// Draw a circle for radius like [0, 100], and two circles for [20, 100]
if (radiusExtent[rx] > 0) {
var circle = new graphic.Circle({
shape: {
cx: polar.cx,
cy: polar.cy,
r: radiusExtent[rx]
},
style: lineStyleModel.getLineStyle(),
z2: 1,
silent: true
});
circle.style.fill = null;

this.group.add(circle);
}
}
},

/**
Expand Down
19 changes: 16 additions & 3 deletions src/coord/polar/polarCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,23 @@ function resizePolar(polar, polarModel, api) {

var radiusAxis = polar.getRadiusAxis();
var size = Math.min(width, height) / 2;
var radius = parsePercent(polarModel.get('radius'), size);

var radius = polarModel.get('radius');
if (radius == null) {
radius = [0, "100%"];
}
else if (typeof radius === 'number' || typeof radius === 'string') {
// r0 = 0
radius = [0, radius];
}
radius = [
parsePercent(radius[0], size),
parsePercent(radius[1], size)
];

radiusAxis.inverse
? radiusAxis.setExtent(radius, 0)
: radiusAxis.setExtent(0, radius);
? radiusAxis.setExtent(radius[1], radius[0])
: radiusAxis.setExtent(radius[0], radius[1]);
}

/**
Expand Down

0 comments on commit b5e6ba7

Please sign in to comment.