mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-11 05:46:37 +01:00
Couple of quick fixes.
This commit is contained in:
parent
0dc74db428
commit
8faced7668
@ -73,11 +73,13 @@ class Morris.Grid extends Morris.EventEmitter
|
|||||||
setData: (data, redraw = true) ->
|
setData: (data, redraw = true) ->
|
||||||
ymax = if @cumulative then 0 else null
|
ymax = if @cumulative then 0 else null
|
||||||
ymin = if @cumulative then 0 else null
|
ymin = if @cumulative then 0 else null
|
||||||
|
|
||||||
if @options.goals.length > 0
|
if @options.goals.length > 0
|
||||||
ymax = Math.max(ymax, Math.max.apply(null,@options.goals))
|
minGoal = Math.min.apply(null, @options.goals)
|
||||||
ymin = Math.min(ymin, Math.min.apply(null,@options.goals))
|
maxGoal = Math.max.apply(null, @options.goals)
|
||||||
|
ymin = if ymin is null then minGoal else Math.min(ymin, minGoal)
|
||||||
|
ymax = if ymax is null then maxGoal else Math.max(ymax, maxGoal)
|
||||||
|
|
||||||
@data = $.map data, (row, index) =>
|
@data = $.map data, (row, index) =>
|
||||||
ret = {}
|
ret = {}
|
||||||
ret.label = row[@options.xkey]
|
ret.label = row[@options.xkey]
|
||||||
@ -118,9 +120,9 @@ class Morris.Grid extends Morris.EventEmitter
|
|||||||
|
|
||||||
@events = []
|
@events = []
|
||||||
if @options.parseTime and @options.events.length > 0
|
if @options.parseTime and @options.events.length > 0
|
||||||
@events = $.map @options.events, (event, index) => Morris.parseDate(event)
|
@events = (Morris.parseDate(e) for e in @options.events)
|
||||||
@xmax = Math.max(@xmax, Math.max.apply(null,@events))
|
@xmax = Math.max(@xmax, Math.max.apply(null, @events))
|
||||||
@xmin = Math.min(@xmin, Math.min.apply(null,@events))
|
@xmin = Math.min(@xmin, Math.min.apply(null, @events))
|
||||||
|
|
||||||
if @xmin is @xmax
|
if @xmin is @xmax
|
||||||
@xmin -= 1
|
@xmin -= 1
|
||||||
|
21
morris.js
21
morris.js
@ -115,7 +115,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Grid.prototype.setData = function(data, redraw) {
|
Grid.prototype.setData = function(data, redraw) {
|
||||||
var ymax, ymin,
|
var e, maxGoal, minGoal, ymax, ymin,
|
||||||
_this = this;
|
_this = this;
|
||||||
if (redraw == null) {
|
if (redraw == null) {
|
||||||
redraw = true;
|
redraw = true;
|
||||||
@ -123,8 +123,10 @@
|
|||||||
ymax = this.cumulative ? 0 : null;
|
ymax = this.cumulative ? 0 : null;
|
||||||
ymin = this.cumulative ? 0 : null;
|
ymin = this.cumulative ? 0 : null;
|
||||||
if (this.options.goals.length > 0) {
|
if (this.options.goals.length > 0) {
|
||||||
ymax = Math.max(ymax, Math.max.apply(null, this.options.goals));
|
minGoal = Math.min.apply(null, this.options.goals);
|
||||||
ymin = Math.min(ymin, Math.min.apply(null, this.options.goals));
|
maxGoal = Math.max.apply(null, this.options.goals);
|
||||||
|
ymin = ymin === null ? minGoal : Math.min(ymin, minGoal);
|
||||||
|
ymax = ymax === null ? maxGoal : Math.max(ymax, maxGoal);
|
||||||
}
|
}
|
||||||
this.data = $.map(data, function(row, index) {
|
this.data = $.map(data, function(row, index) {
|
||||||
var idx, ret, total, ykey, yval;
|
var idx, ret, total, ykey, yval;
|
||||||
@ -185,9 +187,16 @@
|
|||||||
this.xmax = this.data[this.data.length - 1].x;
|
this.xmax = this.data[this.data.length - 1].x;
|
||||||
this.events = [];
|
this.events = [];
|
||||||
if (this.options.parseTime && this.options.events.length > 0) {
|
if (this.options.parseTime && this.options.events.length > 0) {
|
||||||
this.events = $.map(this.options.events, function(event, index) {
|
this.events = (function() {
|
||||||
return Morris.parseDate(event);
|
var _i, _len, _ref, _results;
|
||||||
});
|
_ref = this.options.events;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
e = _ref[_i];
|
||||||
|
_results.push(Morris.parseDate(e));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}).call(this);
|
||||||
this.xmax = Math.max(this.xmax, Math.max.apply(null, this.events));
|
this.xmax = Math.max(this.xmax, Math.max.apply(null, this.events));
|
||||||
this.xmin = Math.min(this.xmin, Math.min.apply(null, this.events));
|
this.xmin = Math.min(this.xmin, Math.min.apply(null, this.events));
|
||||||
}
|
}
|
||||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user