Skip to content

Commit df4d831

Browse files
authored
Merge pull request #148 from sgratzl/release/v4.4.1
Release v4.4.1
2 parents c43fcd4 + cbdad86 commit df4d831

File tree

4 files changed

+157
-78
lines changed

4 files changed

+157
-78
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sgratzl/chartjs-chart-boxplot",
33
"description": "Chart.js module for charting boxplots and violin charts",
4-
"version": "4.4.0",
4+
"version": "4.4.1",
55
"publishConfig": {
66
"access": "public"
77
},
Loading

src/elements/Violin.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,36 @@ export class Violin extends StatsBase<IViolinElementProps, IViolinElementOptions
7070
} else {
7171
maxEstimate = props.maxEstimate;
7272
}
73+
74+
ctx.beginPath();
7375
if (this.isVertical()) {
7476
const { x, width } = props;
7577
const factor = width / 2 / maxEstimate;
76-
ctx.moveTo(x, props.min);
78+
7779
props.coords.forEach((c) => {
7880
ctx.lineTo(x - c.estimate * factor, c.v);
7981
});
80-
ctx.lineTo(x, props.max);
81-
ctx.moveTo(x, props.min);
82-
props.coords.forEach((c) => {
83-
ctx.lineTo(x + c.estimate * factor, c.v);
84-
});
85-
ctx.lineTo(x, props.max);
82+
83+
props.coords
84+
.slice()
85+
.reverse()
86+
.forEach((c) => {
87+
ctx.lineTo(x + c.estimate * factor, c.v);
88+
});
8689
} else {
8790
const { y, height } = props;
8891
const factor = height / 2 / maxEstimate;
89-
ctx.moveTo(props.min, y);
92+
9093
props.coords.forEach((c) => {
9194
ctx.lineTo(c.v, y - c.estimate * factor);
9295
});
93-
ctx.lineTo(props.max, y);
94-
ctx.moveTo(props.min, y);
95-
props.coords.forEach((c) => {
96-
ctx.lineTo(c.v, y + c.estimate * factor);
97-
});
98-
ctx.lineTo(props.max, y);
96+
97+
props.coords
98+
.slice()
99+
.reverse()
100+
.forEach((c) => {
101+
ctx.lineTo(c.v, y + c.estimate * factor);
102+
});
99103
}
100104
ctx.closePath();
101105
ctx.stroke();

0 commit comments

Comments
 (0)