mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
ArcElement: Skip draw when radius is negative (#8170)
This commit is contained in:
parent
8ab62f57be
commit
e78310c0fd
@ -184,7 +184,7 @@ export default class ArcElement extends Element {
|
||||
me.pixelMargin = (options.borderAlign === 'inner') ? 0.33 : 0;
|
||||
me.fullCircles = Math.floor(me.circumference / TAU);
|
||||
|
||||
if (me.circumference === 0) {
|
||||
if (me.circumference === 0 || me.innerRadius < 0 || me.outerRadius < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,4 +65,36 @@ describe('Arc element tests', function() {
|
||||
expect(center.x).toBeCloseTo(0.5, 6);
|
||||
expect(center.y).toBeCloseTo(0.5, 6);
|
||||
});
|
||||
|
||||
it('should not draw when radius < 0', function() {
|
||||
var ctx = window.createMockContext();
|
||||
|
||||
var arc = new Chart.elements.ArcElement({
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI / 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
innerRadius: -0.1,
|
||||
outerRadius: Math.sqrt(2),
|
||||
options: {}
|
||||
});
|
||||
|
||||
arc.draw(ctx);
|
||||
|
||||
expect(ctx.getCalls().length).toBe(0);
|
||||
|
||||
arc = new Chart.elements.ArcElement({
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI / 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
innerRadius: 0,
|
||||
outerRadius: -1,
|
||||
options: {}
|
||||
});
|
||||
|
||||
arc.draw(ctx);
|
||||
|
||||
expect(ctx.getCalls().length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user