Skip to content

Commit

Permalink
Remove #9152
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed May 25, 2021
1 parent 67623c4 commit efb9482
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/elements/element.arc.js
Expand Up @@ -277,7 +277,7 @@ export default class ArcElement extends Element {
* @param {boolean} [useFinalPosition]
*/
getCenterPoint(useFinalPosition) {
const {x, y, startAngle, endAngle, innerRadius, outerRadius, circumference} = this.getProps([
const {x, y, startAngle, endAngle, innerRadius, outerRadius} = this.getProps([
'x',
'y',
'startAngle',
Expand All @@ -286,7 +286,7 @@ export default class ArcElement extends Element {
'outerRadius',
'circumference'
], useFinalPosition);
const halfAngle = isNaN(circumference) ? (startAngle + endAngle) / 2 : startAngle + circumference / 2;
const halfAngle = (startAngle + endAngle) / 2;
const halfRadius = (innerRadius + outerRadius) / 2;
return {
x: x + Math.cos(halfAngle) * halfRadius,
Expand Down
21 changes: 6 additions & 15 deletions test/specs/element.arc.tests.js
Expand Up @@ -66,35 +66,26 @@ describe('Arc element tests', function() {
expect(center.y).toBeCloseTo(0.5, 6);
});

it ('should get the center of full circle using endAngle', function() {
it ('should get the center of full circle before and after draw', function() {
// Mock out the arc as if the controller put it there
var arc = new Chart.elements.ArcElement({
startAngle: 0,
endAngle: Math.PI * 2,
x: 2,
y: 2,
innerRadius: 0,
outerRadius: 2
outerRadius: 2,
options: {}
});

var center = arc.getCenterPoint();
expect(center.x).toBeCloseTo(1, 6);
expect(center.y).toBeCloseTo(2, 6);
});

it ('should get the center of full circle using circumference', function() {
// Mock out the arc as if the controller put it there
var arc = new Chart.elements.ArcElement({
startAngle: 0,
endAngle: 0,
x: 2,
y: 2,
innerRadius: 0,
outerRadius: 2,
circumference: Math.PI * 2
});
var ctx = window.createMockContext();
arc.draw(ctx);

var center = arc.getCenterPoint();
center = arc.getCenterPoint();
expect(center.x).toBeCloseTo(1, 6);
expect(center.y).toBeCloseTo(2, 6);
});
Expand Down

0 comments on commit efb9482

Please sign in to comment.