Merge pull request #459 from JelteF/better-ylabel-callback

Pass series index to yLabelFormat
This commit is contained in:
Jelte Fennema 2014-08-14 14:32:08 +02:00
commit bb86c78613
3 changed files with 5 additions and 5 deletions

View file

@ -241,7 +241,7 @@ class Morris.Bar extends Morris.Grid
content += """
<div class='morris-hover-point' style='color: #{@colorFor(row, j, 'label')}'>
#{@options.labels[j]}:
#{@yLabelFormat(y)}
#{@yLabelFormat(y, j)}
</div>
"""
if typeof @options.hoverCallback is 'function'

View file

@ -381,13 +381,13 @@ class Morris.Grid extends Morris.EventEmitter
# @private
#
yAxisFormat: (label) -> @yLabelFormat(label)
yAxisFormat: (label) -> @yLabelFormat(label, 0)
# @private
#
yLabelFormat: (label) ->
yLabelFormat: (label, i) ->
if typeof @options.yLabelFormat is 'function'
@options.yLabelFormat(label)
@options.yLabelFormat(label, i)
else
"#{@options.preUnits}#{Morris.commas(label)}#{@options.postUnits}"

View file

@ -115,7 +115,7 @@ class Morris.Line extends Morris.Grid
content += """
<div class='morris-hover-point' style='color: #{@colorFor(row, j, 'label')}'>
#{@options.labels[j]}:
#{@yLabelFormat(y)}
#{@yLabelFormat(y, j)}
</div>
"""
if typeof @options.hoverCallback is 'function'