Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yassilah committed Sep 10, 2023
1 parent 8a2f216 commit 589f66d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
13 changes: 6 additions & 7 deletions src/component/axis/AngleAxisView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,24 @@ const angelAxisElementsBuilders: Record<typeof elementList[number], AngleAxisEle

axisLine(group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
const lineStyleModel = angleAxisModel.getModel(['axisLine', 'lineStyle']);
const angleAxis = polar.getAngleAxis();
const RADIAN = Math.PI / 180;
const angleExtent = angleAxis.getExtent();

// extent id of the axis radius (r0 and r)
const rId = getRadiusIdx(polar);
const r0Id = rId ? 0 : 1;
let shape;

const startAngle = (angleAxisModel.get('startAngle') - 90) / zrUtil.RADIAN_TO_DEGREE;
const endAngle = (angleAxisModel.get('endAngle') - 90) / zrUtil.RADIAN_TO_DEGREE;


if (radiusExtent[r0Id] === 0) {
shape = new graphic.Arc({
shape: {
cx: polar.cx,
cy: polar.cy,
r: radiusExtent[rId],
startAngle,
endAngle
startAngle: -angleExtent[0] * RADIAN,
endAngle: -angleExtent[1] * RADIAN,
clockwise: angleAxis.inverse
},
style: lineStyleModel.getLineStyle(),
z2: 1,
Expand All @@ -169,7 +169,6 @@ const angelAxisElementsBuilders: Record<typeof elementList[number], AngleAxisEle
cy: polar.cy,
r: radiusExtent[rId],
r0: radiusExtent[r0Id]

},
style: lineStyleModel.getLineStyle(),
z2: 1,
Expand Down
12 changes: 7 additions & 5 deletions src/component/axis/RadiusAxisView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
const lineStyleModel = splitLineModel.getModel('lineStyle');
let lineColors = lineStyleModel.get('color');
let lineCount = 0;
const angleAxis = polar.getAngleAxis().model;
const startAngle = (angleAxis.get('startAngle') - 90) / zrUtil.RADIAN_TO_DEGREE;
const endAngle = (angleAxis.get('endAngle') - 90) / zrUtil.RADIAN_TO_DEGREE;

const angleAxis = polar.getAngleAxis();
const RADIAN = Math.PI / 180;
const angleExtent = angleAxis.getExtent();

lineColors = lineColors instanceof Array ? lineColors : [lineColors];

Expand All @@ -121,8 +122,9 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
cy: polar.cy,
// ensure circle radius >= 0
r: Math.max(ticksCoords[i].coord, 0),
startAngle,
endAngle
startAngle: -angleExtent[0] * RADIAN,
endAngle: -angleExtent[1] * RADIAN,
clockwise: angleAxis.inverse
}
}));
}
Expand Down
6 changes: 2 additions & 4 deletions src/coord/polar/polarCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ function setAxis(axis: RadiusAxis | AngleAxis, axisModel: PolarAxisModel) {
axis.inverse = axisModel.get('inverse');

if (isAngleAxisModel(axisModel)) {
console.log('coucou')
axis.inverse = axis.inverse !== axisModel.get('clockwise');
const startAngle = axisModel.get('startAngle');
const endAndle = axisModel.get('endAngle')
const actualEndAngle = typeof endAndle === 'number' ? endAndle :startAngle + (axis.inverse ? -360 : 360);
axis.setExtent(startAngle, actualEndAngle);
const endAngle = axisModel.get('endAngle') ?? (startAngle + (axis.inverse ? -360 : 360));
axis.setExtent(startAngle, endAngle);
}

// Inject axis instance
Expand Down
11 changes: 6 additions & 5 deletions test/polar-end-angle.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 589f66d

Please sign in to comment.