mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-11 05:46:37 +01:00
Merge branch 'issue-138' of github.com:tiraeth/morris.js
Conflicts: lib/morris.grid.coffee morris.js morris.min.js
This commit is contained in:
commit
ecabc8976b
@ -66,6 +66,7 @@ class Morris.Grid extends Morris.EventEmitter
|
||||
gridTextColor: '#888'
|
||||
gridTextSize: 12
|
||||
hideHover: false
|
||||
yLabelFormat: (label, prefix, suffix) -> "#{prefix}#{Morris.commas(label)}#{suffix}"
|
||||
numLines: 5
|
||||
padding: 25
|
||||
parseTime: true
|
||||
@ -282,7 +283,7 @@ class Morris.Grid extends Morris.EventEmitter
|
||||
# @private
|
||||
#
|
||||
yLabelFormat: (label) ->
|
||||
"#{@options.preUnits}#{Morris.commas(label)}#{@options.postUnits}"
|
||||
@options.yLabelFormat(label, @options.preUnits, @options.postUnits)
|
||||
|
||||
updateHover: (x, y) ->
|
||||
hit = @hitTest(x, y)
|
||||
|
@ -124,6 +124,9 @@
|
||||
gridTextColor: '#888',
|
||||
gridTextSize: 12,
|
||||
hideHover: false,
|
||||
yLabelFormat: function(label, prefix, suffix) {
|
||||
return "" + prefix + (Morris.commas(label)) + suffix;
|
||||
},
|
||||
numLines: 5,
|
||||
padding: 25,
|
||||
parseTime: true,
|
||||
@ -394,7 +397,7 @@
|
||||
};
|
||||
|
||||
Grid.prototype.yLabelFormat = function(label) {
|
||||
return "" + this.options.preUnits + (Morris.commas(label)) + this.options.postUnits;
|
||||
return this.options.yLabelFormat(label, this.options.preUnits, this.options.postUnits);
|
||||
};
|
||||
|
||||
Grid.prototype.updateHover = function(x, y) {
|
||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
15
spec/lib/grid/y_label_format_spec.coffee
Normal file
15
spec/lib/grid/y_label_format_spec.coffee
Normal file
@ -0,0 +1,15 @@
|
||||
describe 'Morris.Grid#yLabelFormat', ->
|
||||
|
||||
it 'should use custom formatter for y labels', ->
|
||||
formatter = (label, prefix, suffix) ->
|
||||
flabel = parseFloat(label) / 1000
|
||||
"#{prefix}#{flabel.toFixed(1)}k#{suffix}"
|
||||
line = Morris.Line
|
||||
element: 'graph'
|
||||
data: [{x: 1, y: 1500}, {x: 2, y: 2500}]
|
||||
xkey: 'x'
|
||||
ykeys: ['y']
|
||||
labels: ['dontcare']
|
||||
preUnits: "$"
|
||||
yLabelFormat: formatter
|
||||
line.yLabelFormat(1500).should.equal "$1.5k"
|
Loading…
Reference in New Issue
Block a user