Adds the ability to mark events on a non-time-based line graph

This commit is contained in:
Alex Brinkman 2013-11-03 20:58:17 -07:00
parent a738317adb
commit b162e18cce
3 changed files with 21 additions and 14 deletions

View File

@ -186,8 +186,11 @@ class Morris.Grid extends Morris.EventEmitter
@xmax = @data[@data.length - 1].x
@events = []
if @options.parseTime and @options.events.length > 0
@events = (Morris.parseDate(e) for e in @options.events)
if @options.events.length > 0
if @options.parseTime
@events = (Morris.parseDate(e) for e in @options.events)
else
@events = @options.events
@xmax = Math.max(@xmax, Math.max.apply(null, @events))
@xmin = Math.min(@xmin, Math.min.apply(null, @events))

View File

@ -267,17 +267,21 @@
this.xmin = this.data[0].x;
this.xmax = this.data[this.data.length - 1].x;
this.events = [];
if (this.options.parseTime && this.options.events.length > 0) {
this.events = (function() {
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);
if (this.options.events.length > 0) {
if (this.options.parseTime) {
this.events = (function() {
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);
} else {
this.events = this.options.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));
}

2
morris.min.js vendored

File diff suppressed because one or more lines are too long