Commit 6fb6b0f1 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add unzoom api

parent 651a26a5
...@@ -795,6 +795,12 @@ ...@@ -795,6 +795,12 @@
var brush = d3.svg.brush().on("brush", redrawForBrush); var brush = d3.svg.brush().on("brush", redrawForBrush);
var zoom = d3.behavior.zoom().on("zoom", __zoom_enabled ? redrawForZoom : null); var zoom = d3.behavior.zoom().on("zoom", __zoom_enabled ? redrawForZoom : null);
// define functions for c3
brush.update = function () {
if (context) context.select('.x.brush').call(this);
return this;
}
/*-- Draw Chart --*/ /*-- Draw Chart --*/
// for svg elements // for svg elements
...@@ -1376,8 +1382,7 @@ ...@@ -1376,8 +1382,7 @@
if (__subchart_show) { if (__subchart_show) {
// reflect main chart to extent on subchart if zoomed // reflect main chart to extent on subchart if zoomed
if (d3.event !== null && d3.event.type === 'zoom') { if (d3.event !== null && d3.event.type === 'zoom') {
brush.extent(x.orgDomain()); brush.extent(x.orgDomain()).update();
context.select('.x.brush').call(brush);
} }
// update subchart elements if needed // update subchart elements if needed
if (withSubchart) { if (withSubchart) {
...@@ -1386,8 +1391,7 @@ ...@@ -1386,8 +1391,7 @@
context.select('.x.axis').transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : subXAxis); context.select('.x.axis').transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : subXAxis);
// extent rect // extent rect
if ( ! brush.empty()) { if ( ! brush.empty()) {
brush.extent(x.orgDomain()); brush.extent(x.orgDomain()).update();
context.select('.x.brush').call(brush);
} }
// bars // bars
barW = getBarW(subXAxis, barTargetsNum, true); barW = getBarW(subXAxis, barTargetsNum, true);
...@@ -1720,6 +1724,11 @@ ...@@ -1720,6 +1724,11 @@
.style('opacity', 0); .style('opacity', 0);
}; };
c3.unzoom = function () {
brush.clear().update();
redraw({withUpdateXDomain:true});
}
c3.load = function (args) { c3.load = function (args) {
// check args // check args
if (isUndefined(args.done)) { if (isUndefined(args.done)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment