Permalink
Browse files

use instead of for clarity

  • Loading branch information...
1 parent 15ba34e commit eacacb2736cb684d3c0062e37716f4b70a0a5dee @paularmstrong paularmstrong committed Jun 28, 2013
Showing with 6 additions and 20 deletions.
  1. +3 −17 lib/chart.js
  2. +3 −3 test/chart.test.js
View
@@ -47,7 +47,7 @@ var emptyData = [[]],
interpolation: 'monotone',
// Data sorting
- sortingMethod: function (a, b) {
+ sortX: function (a, b) {
return (!a.x && !b.x) ? 0 : (a.x < b.x) ? -1 : 1;
}
};
@@ -253,7 +253,7 @@ _.defaults(xChart.prototype, {
np.y = o.dataFormatY(p.y);
}
return np;
- }).sort(o.sortingMethod);
+ }).sort(o.sortX);
return _.extend(_.clone(set), { data: d });
}
@@ -646,19 +646,5 @@ _.defaults(xChart.prototype, {
throw 'Required method "' + method + '" not found on vis type "' +
self._type + '".';
}
- }/*,
-
- _updateSorting:function(method) {
- self = this;
- if(typeof(method) == 'function') { self.sortingMethod = method }
- else if (method == 'auto') {
- self.sortingMethod = function (a, b) {
- if (!a.x && !b.x) {
- return 0;
- }
- return (a.x < b.x) ? -1 : 1;
- }
- }
- self.setData(_mainData);
- }*/
+ }
});
View
@@ -66,7 +66,7 @@
xMax: null,
yMin: null,
yMax: null,
- sortingMethod: c._options.sortingMethod
+ sortX: c._options.sortX
});
});
@@ -560,7 +560,7 @@
it('no sorting', function () {
var chart = new xChart('bar', data, container, {
- sortingMethod: function (a, b) {}
+ sortX: function (a, b) {}
});
expect(chart._mainData[0].data[0]).to.be.eql({x : 2, y : 3});
expect(chart._mainData[0].data[1]).to.be.eql({x : 3, y : 2});
@@ -570,7 +570,7 @@
it('custom sorting method (reverse)', function () {
var chart = new xChart('bar', data, container, {
- sortingMethod: function (a, b) {
+ sortX: function (a, b) {
return !a.x && b.x ? 0 : a.x < b.x ? 1 : -1;
}
});

0 comments on commit eacacb2

Please sign in to comment.