11'use strict' ;
22
33import * as Chart from 'chart.js' ;
4- import ArrayElementBase , { defaults } from './base' ;
4+ import ArrayElementBase , {
5+ defaults
6+ } from './base' ;
57
68
79Chart . 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