mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
No need to bail any more when initialising with no data.
This commit is contained in:
parent
6e0e5f0468
commit
481401c3b7
@ -17,10 +17,6 @@ class Morris.Grid extends Morris.EventEmitter
|
|||||||
|
|
||||||
@options = $.extend {}, @gridDefaults, (@defaults || {}), options
|
@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
|
# backwards compatibility for units -> postUnits
|
||||||
if typeof @options.units is 'string'
|
if typeof @options.units is 'string'
|
||||||
@options.postUnits = options.units
|
@options.postUnits = options.units
|
||||||
|
@ -81,9 +81,6 @@
|
|||||||
this.el.css('position', 'relative');
|
this.el.css('position', 'relative');
|
||||||
}
|
}
|
||||||
this.options = $.extend({}, this.gridDefaults, this.defaults || {}, options);
|
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') {
|
if (typeof this.options.units === 'string') {
|
||||||
this.options.postUnits = options.units;
|
this.options.postUnits = options.units;
|
||||||
}
|
}
|
||||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
@ -186,3 +186,14 @@ describe 'Morris.Grid#setData', ->
|
|||||||
line.data.length.should.equal 0
|
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.setData([{x: 2, y: '12'}, {x: 1, y: '13.5'}, {x: 4, y: '14'}, {x: 3, y: '16'}])
|
||||||
line.data.length.should.equal 4
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user