No need to bail any more when initialising with no data.

This commit is contained in:
Olly Smith 2013-02-06 07:40:25 +00:00
parent 6e0e5f0468
commit 481401c3b7
4 changed files with 12 additions and 8 deletions

View File

@ -17,10 +17,6 @@ class Morris.Grid extends Morris.EventEmitter
@options = $.extend {}, @gridDefaults, (@defaults || {}), options
# bail if there's no data
if @options.data is undefined or @options.data.length is 0
return
# backwards compatibility for units -> postUnits
if typeof @options.units is 'string'
@options.postUnits = options.units

View File

@ -81,9 +81,6 @@
this.el.css('position', 'relative');
}
this.options = $.extend({}, this.gridDefaults, this.defaults || {}, options);
if (this.options.data === void 0 || this.options.data.length === 0) {
return;
}
if (typeof this.options.units === 'string') {
this.options.postUnits = options.units;
}

2
morris.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -186,3 +186,14 @@ describe 'Morris.Grid#setData', ->
line.data.length.should.equal 0
line.setData([{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}])
line.data.length.should.equal 4
it 'should be able to add data if the chart is initialised with empty data', ->
line = Morris.Line
element: 'graph',
data: []
xkey: 'x'
ykeys: ['y']
labels: ['y']
line.data.length.should.equal 0
line.setData([{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}])
line.data.length.should.equal 4