Browse Source

Fix to zoom out based on zoom.x.min/max - #603

pull/1207/head
Masayuki Tanaka 10 years ago
parent
commit
aeff370a6f
  1. 13
      c3.js
  2. 8
      c3.min.js
  3. 5
      src/domain.js
  4. 8
      src/zoom.js

13
c3.js

@ -1581,9 +1581,8 @@
return $$.x.domain();
};
c3_chart_internal_fn.trimXDomain = function (domain) {
var $$ = this, config = $$.config, d3 = $$.d3;
var min = d3.min([$$.orgXDomain[0], config.zoom_x_min]);
var max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
var zoomDomain = this.getZoomDomain(),
min = zoomDomain[0], max = zoomDomain[1];
if (domain[0] <= min) {
domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min;
@ -5522,12 +5521,18 @@
return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
};
$$.zoom.updateScaleExtent = function () {
var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.orgXDomain),
var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.getZoomDomain()),
extent = this.orgScaleExtent();
this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
return this;
};
};
c3_chart_internal_fn.getZoomDomain = function () {
var $$ = this, config = $$.config, d3 = $$.d3,
min = d3.min([$$.orgXDomain[0], config.zoom_x_min]),
max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
return [min, max];
};
c3_chart_internal_fn.updateZoom = function () {
var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {};
$$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null);

8
c3.min.js vendored

File diff suppressed because one or more lines are too long

5
src/domain.js

@ -221,9 +221,8 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU
return $$.x.domain();
};
c3_chart_internal_fn.trimXDomain = function (domain) {
var $$ = this, config = $$.config, d3 = $$.d3;
var min = d3.min([$$.orgXDomain[0], config.zoom_x_min]);
var max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
var zoomDomain = this.getZoomDomain(),
min = zoomDomain[0], max = zoomDomain[1];
if (domain[0] <= min) {
domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min;

8
src/zoom.js

@ -28,12 +28,18 @@ c3_chart_internal_fn.initZoom = function () {
return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
};
$$.zoom.updateScaleExtent = function () {
var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.orgXDomain),
var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.getZoomDomain()),
extent = this.orgScaleExtent();
this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
return this;
};
};
c3_chart_internal_fn.getZoomDomain = function () {
var $$ = this, config = $$.config, d3 = $$.d3,
min = d3.min([$$.orgXDomain[0], config.zoom_x_min]),
max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
return [min, max];
};
c3_chart_internal_fn.updateZoom = function () {
var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {};
$$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null);

Loading…
Cancel
Save