@@ -108,7 +108,7 @@ class Morris.Bar extends Morris.Grid
108
108
size = bottom - top
109
109
110
110
top -= lastTop if @options .stacked
111
- @ drawBar (left, top, barWidth, size, @ colorFor (row, sidx, ' bar' ))
111
+ @ drawBar (left, top, barWidth, size, @ colorFor (row, sidx, ' bar' ), @options . barStyle ? . opacity , @options . barStyle ? . radius )
112
112
113
113
lastTop += size
114
114
else
@@ -181,7 +181,23 @@ class Morris.Bar extends Morris.Grid
181
181
.attr (' font-weight' , @options .gridTextWeight )
182
182
.attr (' fill' , @options .gridTextColor )
183
183
184
- drawBar : (xPos , yPos , width , height , barColor ) ->
185
- @raphael .rect (xPos, yPos, width, height)
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
+ path = @raphael .rect (xPos, yPos, width, height)
188
+ else
189
+ path = @raphael .path @ roundedRect (xPos, yPos, width, height, radius)
190
+
191
+
192
+ path
186
193
.attr (' fill' , barColor)
187
194
.attr (' stroke-width' , 0 )
195
+ .attr (' fill-opacity' , opacity)
196
+
197
+ 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" ])
203
+
0 commit comments