Skip to content

Commit 2d7fa90

Browse files
committed
The zoom() getter now correctly returns current domain
This fix is copied from c3js#2270 by @robhybrid. Closes c3js#1497
1 parent 3ca01bd commit 2d7fa90

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/api.zoom-spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ describe('c3 api zoom', function () {
2424
};
2525
});
2626

27+
it('should return the correct extent', function () {
28+
var zoomDomain = chart.zoom(),
29+
expectedDomain = chart.internal.x.domain();
30+
31+
expect(+zoomDomain[0]).toBe(+expectedDomain[0]);
32+
expect(+zoomDomain[1]).toBe(+expectedDomain[1]);
33+
});
34+
2735
it('should be zoomed properly', function () {
2836
var target = [3, 5], domain;
2937
chart.zoom(target);

src/api.zoom.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ c3_chart_fn.zoom = function (domain) {
1515
$$.redraw({withY: $$.config.zoom_rescale, withSubchart: false});
1616
}
1717
$$.config.zoom_onzoom.call(this, $$.x.orgDomain());
18+
return domain;
19+
} else {
20+
return $$.x.domain();
1821
}
19-
return domain;
2022
};
2123
c3_chart_fn.zoom.enable = function (enabled) {
2224
var $$ = this.internal;

0 commit comments

Comments
 (0)