@@ -74,13 +74,18 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
7474
7575 } ,
7676 _drawBoxPlot ( vm , boxplot , ctx , vert ) {
77- ctx . beginPath ( ) ;
7877 if ( vert ) {
7978 const x = vm . x ;
8079 const width = vm . width ;
8180 const x0 = x - width / 2 ;
82- ctx . fillRect ( x0 , boxplot . q1 , width , boxplot . q3 - boxplot . q1 ) ;
83- ctx . strokeRect ( x0 , boxplot . q1 , width , boxplot . q3 - boxplot . q1 ) ;
81+ if ( boxplot . q3 > boxplot . q1 ) {
82+ ctx . fillRect ( x0 , boxplot . q1 , width , boxplot . q3 - boxplot . q1 ) ;
83+ ctx . strokeRect ( x0 , boxplot . q1 , width , boxplot . q3 - boxplot . q1 ) ;
84+ } else {
85+ ctx . fillRect ( x0 , boxplot . q3 , width , boxplot . q1 - boxplot . q3 ) ;
86+ ctx . strokeRect ( x0 , boxplot . q3 , width , boxplot . q1 - boxplot . q3 ) ;
87+ }
88+ ctx . beginPath ( ) ;
8489 ctx . moveTo ( x0 , boxplot . whiskerMin ) ;
8590 ctx . lineTo ( x0 + width , boxplot . whiskerMin ) ;
8691 ctx . moveTo ( x , boxplot . whiskerMin ) ;
@@ -91,13 +96,20 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
9196 ctx . lineTo ( x , boxplot . q3 ) ;
9297 ctx . moveTo ( x0 , boxplot . median ) ;
9398 ctx . lineTo ( x0 + width , boxplot . median ) ;
99+ ctx . closePath ( ) ;
100+ ctx . stroke ( ) ;
94101 } else {
95102 const y = vm . y ;
96103 const height = vm . height ;
97104 const y0 = y - height / 2 ;
98- ctx . fillRect ( boxplot . q1 , y0 , boxplot . q3 - boxplot . q1 , height ) ;
99- ctx . strokeRect ( boxplot . q1 , y0 , boxplot . q3 - boxplot . q1 , height ) ;
100-
105+ if ( boxplot . q3 > boxplot . q1 ) {
106+ ctx . fillRect ( boxplot . q1 , y0 , boxplot . q3 - boxplot . q1 , height ) ;
107+ ctx . strokeRect ( boxplot . q1 , y0 , boxplot . q3 - boxplot . q1 , height ) ;
108+ } else {
109+ ctx . fillRect ( boxplot . q3 , y0 , boxplot . q1 - boxplot . q3 , height ) ;
110+ ctx . strokeRect ( boxplot . q3 , y0 , boxplot . q1 - boxplot . q3 , height ) ;
111+ }
112+ ctx . beginPath ( ) ;
101113 ctx . moveTo ( boxplot . whiskerMin , y0 ) ;
102114 ctx . lineTo ( boxplot . whiskerMin , y0 + height ) ;
103115 ctx . moveTo ( boxplot . whiskerMin , y ) ;
@@ -108,9 +120,10 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
108120 ctx . lineTo ( boxplot . q3 , y ) ;
109121 ctx . moveTo ( boxplot . median , y0 ) ;
110122 ctx . lineTo ( boxplot . median , y0 + height ) ;
123+ ctx . closePath ( ) ;
124+ ctx . stroke ( ) ;
111125 }
112- ctx . stroke ( ) ;
113- ctx . closePath ( ) ;
126+
114127 } ,
115128 _getBounds ( ) {
116129 const vm = this . _view ;
0 commit comments