mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Merge pull request #518 from JelteF/in-bar-value
Add an option to display the value of a bar in the bar itself
This commit is contained in:
commit
d008d9317f
@ -31,6 +31,10 @@ class Morris.Bar extends Morris.Grid
|
||||
xLabelMargin: 50
|
||||
horizontal: false
|
||||
shown: true
|
||||
inBarValue: false
|
||||
inBarValueTextColor: 'white'
|
||||
inBarValueMinTopMargin: 1
|
||||
inBarValueRightMargin: 4
|
||||
|
||||
# Do any size-related calculations
|
||||
#
|
||||
@ -177,6 +181,15 @@ class Morris.Bar extends Morris.Grid
|
||||
@options.barOpacity, @options.barRadius)
|
||||
lastTop -= size
|
||||
|
||||
if @options.inBarValue and
|
||||
barWidth > @options.gridTextSize + 2*@options.inBarValueMinTopMargin
|
||||
barMiddle = left + 0.5 * barWidth
|
||||
@raphael.text(bottom - @options.inBarValueRightMargin, barMiddle, @yLabelFormat(row.y[sidx], sidx))
|
||||
.attr('font-size', @options.gridTextSize)
|
||||
.attr('font-family', @options.gridTextFamily)
|
||||
.attr('font-weight', @options.gridTextWeight)
|
||||
.attr('fill', @options.inBarValueTextColor)
|
||||
.attr('text-anchor', 'end')
|
||||
|
||||
else
|
||||
null
|
||||
|
Loading…
Reference in New Issue
Block a user