Browse Source

Merge pull request #2345 from cogniteev/fix/zoom-api-getter

The zoom() getter now correctly returns current domain
pull/1533/merge
Anthony Pessy 7 years ago committed by GitHub
parent
commit
06cc1f0a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      spec/api.zoom-spec.js
  2. 4
      src/api.zoom.js

8
spec/api.zoom-spec.js

@ -24,6 +24,14 @@ describe('c3 api zoom', function () {
}; };
}); });
it('should return the correct extent', function () {
var zoomDomain = chart.zoom(),
expectedDomain = chart.internal.x.domain();
expect(+zoomDomain[0]).toBe(+expectedDomain[0]);
expect(+zoomDomain[1]).toBe(+expectedDomain[1]);
});
it('should be zoomed properly', function () { it('should be zoomed properly', function () {
var target = [3, 5], domain; var target = [3, 5], domain;
chart.zoom(target); chart.zoom(target);

4
src/api.zoom.js

@ -15,8 +15,10 @@ c3_chart_fn.zoom = function (domain) {
$$.redraw({withY: $$.config.zoom_rescale, withSubchart: false}); $$.redraw({withY: $$.config.zoom_rescale, withSubchart: false});
} }
$$.config.zoom_onzoom.call(this, $$.x.orgDomain()); $$.config.zoom_onzoom.call(this, $$.x.orgDomain());
return domain;
} else {
return $$.x.domain();
} }
return domain;
}; };
c3_chart_fn.zoom.enable = function (enabled) { c3_chart_fn.zoom.enable = function (enabled) {
var $$ = this.internal; var $$ = this.internal;

Loading…
Cancel
Save