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 = {
@@ -63,7 +65,7 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
6365 const vert = this . isVertical ( ) ;
6466
6567
66- this . _drawItems ( vm , violin , ctx , vert ) ;
68+
6769
6870 ctx . save ( ) ;
6971
@@ -82,12 +84,18 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
8284 const width = vm . width ;
8385 const factor = ( width / 2 ) / violin . maxEstimate ;
8486 ctx . moveTo ( x , violin . min ) ;
85- coords . forEach ( ( { v, estimate} ) => {
87+ coords . forEach ( ( {
88+ v,
89+ estimate
90+ } ) => {
8691 ctx . lineTo ( x - estimate * factor , v ) ;
8792 } ) ;
8893 ctx . lineTo ( x , violin . max ) ;
8994 ctx . moveTo ( x , violin . min ) ;
90- coords . forEach ( ( { v, estimate} ) => {
95+ coords . forEach ( ( {
96+ v,
97+ estimate
98+ } ) => {
9199 ctx . lineTo ( x + estimate * factor , v ) ;
92100 } ) ;
93101 ctx . lineTo ( x , violin . max ) ;
@@ -96,12 +104,18 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
96104 const height = vm . height ;
97105 const factor = ( height / 2 ) / violin . maxEstimate ;
98106 ctx . moveTo ( violin . min , y ) ;
99- coords . forEach ( ( { v, estimate} ) => {
107+ coords . forEach ( ( {
108+ v,
109+ estimate
110+ } ) => {
100111 ctx . lineTo ( v , y - estimate * factor ) ;
101112 } ) ;
102113 ctx . lineTo ( violin . max , y ) ;
103114 ctx . moveTo ( violin . min , y ) ;
104- coords . forEach ( ( { v, estimate} ) => {
115+ coords . forEach ( ( {
116+ v,
117+ estimate
118+ } ) => {
105119 ctx . lineTo ( v , y + estimate * factor ) ;
106120 } ) ;
107121 ctx . lineTo ( violin . max , y ) ;
@@ -114,6 +128,8 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
114128
115129 ctx . restore ( ) ;
116130
131+ this . _drawItems ( vm , violin , ctx , vert ) ;
132+
117133 } ,
118134 _getBounds ( ) {
119135 const vm = this . _view ;
@@ -122,7 +138,10 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
122138 const violin = vm . violin ;
123139
124140 if ( vert ) {
125- const { x, width} = vm ;
141+ const {
142+ x,
143+ width
144+ } = vm ;
126145 const x0 = x - width / 2 ;
127146 return {
128147 left : x0 ,
@@ -131,7 +150,10 @@ const Violin = Chart.elements.Violin = ArrayElementBase.extend({
131150 bottom : violin . min
132151 } ;
133152 }
134- const { y, height} = vm ;
153+ const {
154+ y,
155+ height
156+ } = vm ;
135157 const y0 = y - height / 2 ;
136158 return {
137159 left : violin . min ,
0 commit comments