Browse Source

Update c3.min.js

pull/1207/head
Masayuki Tanaka 10 years ago
parent
commit
4f0bf9e572
  1. 50
      c3.js
  2. 8
      c3.min.js
  3. 32
      src/api.zoom.js
  4. 2
      src/config.js
  5. 18
      src/domain.js

50
c3.js

@ -1042,6 +1042,8 @@
zoom_onzoom: function () {}, zoom_onzoom: function () {},
zoom_onzoomstart: function () {}, zoom_onzoomstart: function () {},
zoom_onzoomend: function () {}, zoom_onzoomend: function () {},
zoom_x_min: undefined,
zoom_x_max: undefined,
interaction_enabled: true, interaction_enabled: true,
onmouseover: function () {}, onmouseover: function () {},
onmouseout: function () {}, onmouseout: function () {},
@ -1579,14 +1581,16 @@
return $$.x.domain(); return $$.x.domain();
}; };
c3_chart_internal_fn.trimXDomain = function (domain) { c3_chart_internal_fn.trimXDomain = function (domain) {
var $$ = this; var $$ = this, config = $$.config, d3 = $$.d3;
if (domain[0] <= $$.orgXDomain[0]) { var min = d3.min([$$.orgXDomain[0], config.zoom_x_min]);
domain[1] = +domain[1] + ($$.orgXDomain[0] - domain[0]); var max = d3.max([$$.orgXDomain[1], config.zoom_x_max]);
domain[0] = $$.orgXDomain[0]; if (domain[0] <= min) {
domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min;
} }
if ($$.orgXDomain[1] <= domain[1]) { if (max <= domain[1]) {
domain[0] = +domain[0] - (domain[1] - $$.orgXDomain[1]); domain[0] = +domain[0] - (domain[1] - max);
domain[1] = $$.orgXDomain[1]; domain[1] = max;
} }
return domain; return domain;
}; };
@ -6023,6 +6027,38 @@
$$.redraw({withUpdateXDomain: true}); $$.redraw({withUpdateXDomain: true});
}; };
c3_chart_fn.zoom.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.zoom_x_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.zoom_x_max;
}
};
c3_chart_fn.zoom.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.zoom_x_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.zoom_x_min;
}
};
c3_chart_fn.zoom.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};
c3_chart_fn.load = function (args) { c3_chart_fn.load = function (args) {
var $$ = this.internal, config = $$.config; var $$ = this.internal, config = $$.config;
// update xs if specified // update xs if specified

8
c3.min.js vendored

File diff suppressed because one or more lines are too long

32
src/api.zoom.js

@ -20,3 +20,35 @@ c3_chart_fn.unzoom = function () {
$$.brush.clear().update(); $$.brush.clear().update();
$$.redraw({withUpdateXDomain: true}); $$.redraw({withUpdateXDomain: true});
}; };
c3_chart_fn.zoom.max = function (max) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (max === 0 || max) {
config.zoom_x_max = d3.max([$$.orgXDomain[1], max]);
}
else {
return config.zoom_x_max;
}
};
c3_chart_fn.zoom.min = function (min) {
var $$ = this.internal, config = $$.config, d3 = $$.d3;
if (min === 0 || min) {
config.zoom_x_min = d3.min([$$.orgXDomain[0], min]);
}
else {
return config.zoom_x_min;
}
};
c3_chart_fn.zoom.range = function (range) {
if (arguments.length) {
if (isDefined(range.max)) { this.domain.max(range.max); }
if (isDefined(range.min)) { this.domain.min(range.min); }
} else {
return {
max: this.domain.max(),
min: this.domain.min()
};
}
};

2
src/config.js

@ -15,6 +15,8 @@ c3_chart_internal_fn.getDefaultConfig = function () {
zoom_onzoom: function () {}, zoom_onzoom: function () {},
zoom_onzoomstart: function () {}, zoom_onzoomstart: function () {},
zoom_onzoomend: function () {}, zoom_onzoomend: function () {},
zoom_x_min: undefined,
zoom_x_max: undefined,
interaction_enabled: true, interaction_enabled: true,
onmouseover: function () {}, onmouseover: function () {},
onmouseout: function () {}, onmouseout: function () {},

18
src/domain.js

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

Loading…
Cancel
Save