@@ -25,7 +25,9 @@ class Morris.Bar extends Morris.Grid
25
25
' #edc240'
26
26
' #cb4b4b'
27
27
' #9440ed'
28
- ]
28
+ ],
29
+ barOpacity : 1.0
30
+ barRadius : [0 , 0 , 0 , 0 ]
29
31
xLabelMargin : 50
30
32
31
33
# Do any size-related calculations
@@ -108,7 +110,8 @@ class Morris.Bar extends Morris.Grid
108
110
size = bottom - top
109
111
110
112
top -= lastTop if @options .stacked
111
- @ drawBar (left, top, barWidth, size, @ colorFor (row, sidx, ' bar' ), @options .barStyle ? .opacity , @options .barStyle ? .radius )
113
+ @ drawBar (left, top, barWidth, size, @ colorFor (row, sidx, ' bar' ),
114
+ @options .barOpacity , @options .barRadius )
112
115
113
116
lastTop += size
114
117
else
@@ -181,23 +184,20 @@ class Morris.Bar extends Morris.Grid
181
184
.attr (' font-weight' , @options .gridTextWeight )
182
185
.attr (' fill' , @options .gridTextColor )
183
186
184
-
185
- drawBar : ( xPos , yPos , width , height , barColor , opacity = ' 1 ' , radius = [ 0 , 0 , 0 , 0 ]) ->
186
- if Math . max (radius ... ) > height or (r for r in radius when r is 0 ). length is 4
187
+ drawBar : ( xPos , yPos , width , height , barColor , opacity , radiusArray ) ->
188
+ maxRadius = Math . max (radiusArray ... )
189
+ if maxRadius == 0 or maxRadius > height
187
190
path = @raphael .rect (xPos, yPos, width, height)
188
191
else
189
- path = @raphael .path @ roundedRect (xPos, yPos, width, height, radius)
190
-
191
-
192
+ path = @raphael .path @ roundedRect (xPos, yPos, width, height, radiusArray)
192
193
path
193
194
.attr (' fill' , barColor)
194
195
.attr (' stroke-width' , 0 )
195
196
.attr (' fill-opacity' , opacity)
196
197
197
198
roundedRect : (x , y , w , h , r = [0 ,0 ,0 ,0 ]) ->
198
- [].
199
- concat ([" M" , x, r[0 ] + y, " Q" , x, y, x + r[0 ], y]).
200
- concat ([" L" , x + w - r[1 ], y, " Q" , x + w, y, x + w, y + r[1 ]]).
201
- concat ([" L" , x + w, y + h - r[2 ], " Q" , x + w, y + h, x + w - r[2 ], y + h]).
202
- concat ([" L" , x + r[3 ], y + h, " Q" , x, y + h, x, y + h - r[3 ], " Z" ])
199
+ [ " M" , x, r[0 ] + y, " Q" , x, y, x + r[0 ], y,
200
+ " L" , x + w - r[1 ], y, " Q" , x + w, y, x + w, y + r[1 ],
201
+ " L" , x + w, y + h - r[2 ], " Q" , x + w, y + h, x + w - r[2 ], y + h,
202
+ " L" , x + r[3 ], y + h, " Q" , x, y + h, x, y + h - r[3 ], " Z" ]
203
203
0 commit comments