Skip to content

Commit

Permalink
Add borderJoinStyle option for arc elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Nov 19, 2021
1 parent 51762ae commit a16e9f9
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/elements/element.arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,19 @@ function drawFullCircleBorders(ctx, element, inner) {

function drawBorder(ctx, element, offset, spacing, endAngle) {
const {options} = element;
const {borderWidth, borderJoinStyle} = options;
const inner = options.borderAlign === 'inner';

if (!options.borderWidth) {
if (!borderWidth) {
return;
}

if (inner) {
ctx.lineWidth = options.borderWidth * 2;
ctx.lineJoin = 'round';
ctx.lineWidth = borderWidth * 2;
ctx.lineJoin = borderJoinStyle || 'round';
} else {
ctx.lineWidth = options.borderWidth;
ctx.lineJoin = 'bevel';
ctx.lineWidth = borderWidth;
ctx.lineJoin = borderJoinStyle || 'bevel';
}

if (element.fullCircles) {
Expand Down Expand Up @@ -359,6 +360,7 @@ ArcElement.id = 'arc';
ArcElement.defaults = {
borderAlign: 'center',
borderColor: '#fff',
borderJoinStyle: undefined,
borderRadius: 0,
borderWidth: 2,
offset: 0,
Expand Down
25 changes: 25 additions & 0 deletions test/fixtures/controller.doughnut/borderJoinStyle/bevel-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
data: [0, 2, 4, null, 6, 8],
backgroundColor: 'transparent',
borderColor: '#000',
borderWidth: 10,
spacing: 50,
},
]
},
options: {
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions test/fixtures/controller.doughnut/borderJoinStyle/miter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
data: [0, 2, 4, null, 6, 8],
backgroundColor: 'transparent',
borderColor: '#000',
borderJoinStyle: 'miter',
borderWidth: 10,
spacing: 50,
},
]
},
options: {
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions test/fixtures/controller.doughnut/borderJoinStyle/round.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
config: {
type: 'doughnut',
data: {
labels: [0, 1, 2, 3, 4, 5],
datasets: [
{
data: [0, 2, 4, null, 6, 8],
backgroundColor: 'transparent',
borderColor: '#000',
borderJoinStyle: 'round',
borderWidth: 10,
spacing: 50,
},
]
},
options: {
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
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 a16e9f9

Please sign in to comment.