Don't sort data when parseTime is false. Fixes #83.

This commit is contained in:
Olly Smith 2012-10-03 08:24:38 +01:00
parent 2903d086c6
commit 7775332aeb
3 changed files with 13 additions and 5 deletions

View File

@ -96,7 +96,11 @@ class Morris.Line
setData: (data, redraw = true) ->
# shallow copy & sort data
@options.data = data.slice(0)
@options.data.sort (a, b) => (a[@options.xkey] < b[@options.xkey]) - (b[@options.xkey] < a[@options.xkey])
if @options.parseTime
@options.data.sort (a, b) =>
(a[@options.xkey] < b[@options.xkey]) - (b[@options.xkey] < a[@options.xkey])
else
@options.data.reverse()
# extract labels
@columnLabels = $.map @options.data, (d) => d[@options.xkey]

View File

@ -392,9 +392,13 @@
redraw = true;
}
this.options.data = data.slice(0);
this.options.data.sort(function(a, b) {
return (a[_this.options.xkey] < b[_this.options.xkey]) - (b[_this.options.xkey] < a[_this.options.xkey]);
});
if (this.options.parseTime) {
this.options.data.sort(function(a, b) {
return (a[_this.options.xkey] < b[_this.options.xkey]) - (b[_this.options.xkey] < a[_this.options.xkey]);
});
} else {
this.options.data.reverse();
}
this.columnLabels = $.map(this.options.data, function(d) {
return d[_this.options.xkey];
});

2
morris.min.js vendored

File diff suppressed because one or more lines are too long