Skip to content

Commit 73f62a9

Browse files
nagixsimonbrunel
authored andcommitted
Apply lineJoin style at the first point in radar charts (chartjs#6269)
1 parent 9585024 commit 73f62a9

File tree

2 files changed

+19
-592
lines changed

2 files changed

+19
-592
lines changed

src/elements/element.line.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,24 @@ module.exports = Element.extend({
3737
var globalDefaults = defaults.global;
3838
var globalOptionLineElements = globalDefaults.elements.line;
3939
var lastDrawnIndex = -1;
40+
var closePath = me._loop;
4041
var index, current, previous, currentVM;
4142

42-
// If we are looping, adding the first point again
4343
if (me._loop && points.length) {
44-
points.push(points[0]);
44+
if (!spanGaps) {
45+
for (index = points.length - 1; index >= 0; --index) {
46+
// If the line has an open path, shift the point array
47+
if (points[index]._view.skip) {
48+
points = points.slice(index).concat(points.slice(0, index));
49+
closePath = false;
50+
break;
51+
}
52+
}
53+
}
54+
// If the line has a close path, add the first point again
55+
if (closePath) {
56+
points.push(points[0]);
57+
}
4558
}
4659

4760
ctx.save();
@@ -90,6 +103,10 @@ module.exports = Element.extend({
90103
}
91104
}
92105

106+
if (closePath) {
107+
ctx.closePath();
108+
}
109+
93110
ctx.stroke();
94111
ctx.restore();
95112
}

0 commit comments

Comments
 (0)