Permalink
Browse files

setData allows setting x/y Min/Max onto options

  • Loading branch information...
1 parent 178a147 commit c5e6164da780f847435ec7694d4ea87982bb31b8 @paularmstrong paularmstrong committed Dec 14, 2012
Showing with 17 additions and 0 deletions.
  1. +5 −0 lib/chart.js
  2. +12 −0 test/chart.test.js
View
@@ -227,6 +227,11 @@ _.defaults(xChart.prototype, {
break;
}
+ o.xMin = data.xMin || o.xMin;
+ o.xMax = data.xMax || o.xMax;
+ o.yMin = data.yMin || o.yMin;
+ o.yMax = data.yMax || o.yMax;
+
if (self._vis) {
self._destroy(self._vis, self._mainStorage);
}
View
@@ -256,6 +256,18 @@
expect(c._mainData[0].data[0]).to.be.eql({ x: '1taco', y: 10 });
expect(c._mainData[0].data[1]).to.be.eql({ x: '2taco', y: 20 });
});
+
+ it('allows setting x/y Min/Max onto options', function () {
+ var c = new xChart('bar', mData, container),
+ newData = _.extend({}, mData, {
+ xMin: 1,
+ xMax: 10,
+ yMin: 2,
+ yMax: 8
+ });
+ c.setData(newData);
+ expect(c._options.xMin).to.equal(newData.xMin);
+ });
});
describe('setType(type)', function () {

0 comments on commit c5e6164

Please sign in to comment.