Skip to content

Commit

Permalink
Do not draw box border when width is 0 (chartjs#342)
Browse files Browse the repository at this point in the history
* Do not draw box border when width is 0

* Fix lint issues
  • Loading branch information
etimberg authored Mar 8, 2021
1 parent 67da887 commit e4fde33
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/types/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export default class BoxAnnotation extends Element {

roundedRect(ctx, x, y, width, height, options.cornerRadius);
ctx.fill();
ctx.stroke();

// If no border, don't draw it
if (options.borderWidth) {
ctx.stroke();
}

ctx.restore();
}
Expand Down
38 changes: 38 additions & 0 deletions test/fixtures/box/borderWidth0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
config: {
type: 'bar',
options: {
scales: {
x: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
},
y: {
display: false,
min: 0,
max: 25
}
},
plugins: {
annotation: {
annotations: {
box1: {
type: 'box',
xScaleID: 'x',
yScaleID: 'y',
xMin: 1.5,
xMax: 3.5,
yMin: 5,
yMax: 10,
backgroundColor: 'rgba(33, 101, 171, 0.5)',
borderColor: 'red',
borderWidth: 0,
},
}
}
}
}
},
options: {
spriteText: true
}
};
Binary file added test/fixtures/box/borderWidth0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e4fde33

Please sign in to comment.