Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 9a3ee5c

Browse files
authored
Merge pull request #63 from datavisyn/release-2.2.1
Release 2.2.1
2 parents a731da2 + 8a19ea1 commit 9a3ee5c

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chartjs-chart-box-and-violin-plot",
33
"description": "Chart.js module for charting boxplots",
4-
"version": "2.2.0",
4+
"version": "2.2.1",
55
"author": {
66
"name": "datavisyn",
77
"email": "contact@datavisyn.io",

src/elements/boxandwhiskers.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
'use strict';
22

33
import * as Chart from 'chart.js';
4-
import ArrayElementBase, {defaults} from './base';
4+
import ArrayElementBase, {
5+
defaults
6+
} from './base';
57

68

7-
Chart.defaults.global.elements.boxandwhiskers = {...defaults};
9+
Chart.defaults.global.elements.boxandwhiskers = {
10+
...defaults
11+
};
812

913
function transitionBoxPlot(start, view, model, ease) {
1014
const keys = Object.keys(model);
@@ -58,9 +62,6 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
5862
const boxplot = vm.boxplot;
5963
const vert = this.isVertical();
6064

61-
62-
this._drawItems(vm, boxplot, ctx, vert);
63-
6465
ctx.save();
6566

6667
ctx.fillStyle = vm.backgroundColor;
@@ -72,6 +73,8 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
7273

7374
ctx.restore();
7475

76+
this._drawItems(vm, boxplot, ctx, vert);
77+
7578
},
7679
_drawBoxPlot(vm, boxplot, ctx, vert) {
7780
if (vert) {
@@ -185,7 +188,10 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
185188
}
186189

187190
if (vert) {
188-
const {x, width} = vm;
191+
const {
192+
x,
193+
width
194+
} = vm;
189195
const x0 = x - width / 2;
190196
return {
191197
left: x0,
@@ -194,7 +200,10 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
194200
bottom: boxplot.whiskerMin
195201
};
196202
}
197-
const {y, height} = vm;
203+
const {
204+
y,
205+
height
206+
} = vm;
198207
const y0 = y - height / 2;
199208
return {
200209
left: boxplot.whiskerMin,

src/elements/violin.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

33
import * as Chart from 'chart.js';
4-
import ArrayElementBase, {defaults} from './base';
4+
import ArrayElementBase, {
5+
defaults
6+
} from './base';
57

68

79
Chart.defaults.global.elements.violin = {
@@ -62,9 +64,6 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
6264
const violin = vm.violin;
6365
const vert = this.isVertical();
6466

65-
66-
this._drawItems(vm, violin, ctx, vert);
67-
6867
ctx.save();
6968

7069
ctx.fillStyle = vm.backgroundColor;
@@ -82,12 +81,18 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
8281
const width = vm.width;
8382
const factor = (width / 2) / violin.maxEstimate;
8483
ctx.moveTo(x, violin.min);
85-
coords.forEach(({v, estimate}) => {
84+
coords.forEach(({
85+
v,
86+
estimate
87+
}) => {
8688
ctx.lineTo(x - estimate * factor, v);
8789
});
8890
ctx.lineTo(x, violin.max);
8991
ctx.moveTo(x, violin.min);
90-
coords.forEach(({v, estimate}) => {
92+
coords.forEach(({
93+
v,
94+
estimate
95+
}) => {
9196
ctx.lineTo(x + estimate * factor, v);
9297
});
9398
ctx.lineTo(x, violin.max);
@@ -96,12 +101,18 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
96101
const height = vm.height;
97102
const factor = (height / 2) / violin.maxEstimate;
98103
ctx.moveTo(violin.min, y);
99-
coords.forEach(({v, estimate}) => {
104+
coords.forEach(({
105+
v,
106+
estimate
107+
}) => {
100108
ctx.lineTo(v, y - estimate * factor);
101109
});
102110
ctx.lineTo(violin.max, y);
103111
ctx.moveTo(violin.min, y);
104-
coords.forEach(({v, estimate}) => {
112+
coords.forEach(({
113+
v,
114+
estimate
115+
}) => {
105116
ctx.lineTo(v, y + estimate * factor);
106117
});
107118
ctx.lineTo(violin.max, y);
@@ -114,6 +125,8 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
114125

115126
ctx.restore();
116127

128+
this._drawItems(vm, violin, ctx, vert);
129+
117130
},
118131
_getBounds() {
119132
const vm = this._view;
@@ -122,7 +135,10 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
122135
const violin = vm.violin;
123136

124137
if (vert) {
125-
const {x, width} = vm;
138+
const {
139+
x,
140+
width
141+
} = vm;
126142
const x0 = x - width / 2;
127143
return {
128144
left: x0,
@@ -131,7 +147,10 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
131147
bottom: violin.min
132148
};
133149
}
134-
const {y, height} = vm;
150+
const {
151+
y,
152+
height
153+
} = vm;
135154
const y0 = y - height / 2;
136155
return {
137156
left: violin.min,

0 commit comments

Comments
 (0)