Browse Source

Fix zoom transition

pull/2246/head
Masayuki Tanaka 7 years ago
parent
commit
5831b4eb83
  1. 12
      c3.js
  2. 2
      c3.min.js
  3. 2
      src/api.zoom.js
  4. 8
      src/subchart.js

12
c3.js

@ -4266,7 +4266,7 @@ c3_chart_fn.zoom = function (domain) {
}); });
} }
if ($$.config.subchart_show) { if ($$.config.subchart_show) {
$$.brush.selectionAsValue(domain); $$.brush.selectionAsValue(domain, true);
} else { } else {
$$.updateXDomain(null, true, false, false, domain); $$.updateXDomain(null, true, false, false, domain);
$$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false });
@ -8307,12 +8307,16 @@ c3_chart_internal_fn.initBrush = function (scale) {
$$.brush.selection = function () { $$.brush.selection = function () {
return d3.brushSelection($$.context.select('.' + CLASS.brush).node()); return d3.brushSelection($$.context.select('.' + CLASS.brush).node());
}; };
$$.brush.selectionAsValue = function (selectionAsValue) { $$.brush.selectionAsValue = function (selectionAsValue, withTransition) {
var selection; var selection, brush;
if (selectionAsValue) { if (selectionAsValue) {
if ($$.context) { if ($$.context) {
selection = [this.scale(selectionAsValue[0]), this.scale(selectionAsValue[1])]; selection = [this.scale(selectionAsValue[0]), this.scale(selectionAsValue[1])];
$$.brush.move($$.context.select('.' + CLASS.brush).transition(), selection); brush = $$.context.select('.' + CLASS.brush);
if (withTransition) {
brush = brush.transition();
}
$$.brush.move(brush, selection);
} }
return []; return [];
} }

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

2
src/api.zoom.js

@ -8,7 +8,7 @@ c3_chart_fn.zoom = function (domain) {
domain = domain.map(function (x) { return $$.parseDate(x); }); domain = domain.map(function (x) { return $$.parseDate(x); });
} }
if ($$.config.subchart_show) { if ($$.config.subchart_show) {
$$.brush.selectionAsValue(domain); $$.brush.selectionAsValue(domain, true);
} }
else { else {
$$.updateXDomain(null, true, false, false, domain); $$.updateXDomain(null, true, false, false, domain);

8
src/subchart.js

@ -39,12 +39,14 @@ c3_chart_internal_fn.initBrush = function (scale) {
$$.brush.selection = function () { $$.brush.selection = function () {
return d3.brushSelection($$.context.select('.' + CLASS.brush).node()); return d3.brushSelection($$.context.select('.' + CLASS.brush).node());
}; };
$$.brush.selectionAsValue = function (selectionAsValue) { $$.brush.selectionAsValue = function (selectionAsValue, withTransition) {
var selection; var selection, brush;
if (selectionAsValue) { if (selectionAsValue) {
if ($$.context) { if ($$.context) {
selection = [this.scale(selectionAsValue[0]), this.scale(selectionAsValue[1])]; selection = [this.scale(selectionAsValue[0]), this.scale(selectionAsValue[1])];
$$.brush.move($$.context.select('.' + CLASS.brush).transition(), selection); brush = $$.context.select('.' + CLASS.brush);
if (withTransition) { brush = brush.transition(); }
$$.brush.move(brush, selection);
} }
return []; return [];
} }

Loading…
Cancel
Save