mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-13 07:11:12 +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
1 changed files with 13 additions and 0 deletions
|
@ -31,6 +31,10 @@ class Morris.Bar extends Morris.Grid
|
||||||
xLabelMargin: 50
|
xLabelMargin: 50
|
||||||
horizontal: false
|
horizontal: false
|
||||||
shown: true
|
shown: true
|
||||||
|
inBarValue: false
|
||||||
|
inBarValueTextColor: 'white'
|
||||||
|
inBarValueMinTopMargin: 1
|
||||||
|
inBarValueRightMargin: 4
|
||||||
|
|
||||||
# Do any size-related calculations
|
# Do any size-related calculations
|
||||||
#
|
#
|
||||||
|
@ -177,6 +181,15 @@ class Morris.Bar extends Morris.Grid
|
||||||
@options.barOpacity, @options.barRadius)
|
@options.barOpacity, @options.barRadius)
|
||||||
lastTop -= size
|
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
|
else
|
||||||
null
|
null
|
||||||
|
|
Loading…
Reference in a new issue