Sort input data (closes #10, #20).

This commit is contained in:
Olly Smith 2012-02-29 20:53:53 +00:00
parent b3b8377c53
commit eca4b3aba1
3 changed files with 6 additions and 1 deletions

View File

@ -58,6 +58,8 @@ class Morris.Line
# Do any necessary pre-processing for a new dataset
#
precalc: ->
# sort data
@options.data.sort (a, b) => (a[@options.xkey] < b[@options.xkey]) - (b[@options.xkey] < a[@options.xkey])
# extract labels
@columnLabels = $.map @options.data, (d) => d[@options.xkey]
@seriesLabels = @options.labels

View File

@ -48,6 +48,9 @@
Line.prototype.precalc = function() {
var ykey, ymax, _i, _len, _ref,
_this = this;
this.options.data.sort(function(a, b) {
return (a[_this.options.xkey] < b[_this.options.xkey]) - (b[_this.options.xkey] < a[_this.options.xkey]);
});
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