Commit a2137e8a authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix page scroll when mouse on chart - #42

parent f73bebc1
...@@ -1435,10 +1435,9 @@ ...@@ -1435,10 +1435,9 @@
//-- Define brush/zoom -// //-- Define brush/zoom -//
var brush = d3.svg.brush().on("brush", redrawForBrush); var brush, zoom = function () {};
var zoom = d3.behavior.zoom().on("zoomstart", function () { zoom.altDomain = d3.event.sourceEvent.altKey ? x.orgDomain() : null; }).on("zoom", __zoom_enabled ? redrawForZoom : null);
// define functions for c3 brush = d3.svg.brush().on("brush", redrawForBrush);
brush.update = function () { brush.update = function () {
if (context) { context.select('.x.brush').call(this); } if (context) { context.select('.x.brush').call(this); }
return this; return this;
...@@ -1446,6 +1445,11 @@ ...@@ -1446,6 +1445,11 @@
brush.scale = function (scale) { brush.scale = function (scale) {
return __axis_rotated ? this.y(scale) : this.x(scale); return __axis_rotated ? this.y(scale) : this.x(scale);
}; };
if (__zoom_enabled) {
zoom = d3.behavior.zoom()
.on("zoomstart", function () { zoom.altDomain = d3.event.sourceEvent.altKey ? x.orgDomain() : null; })
.on("zoom", __zoom_enabled ? redrawForZoom : null);
zoom.scale = function (scale) { zoom.scale = function (scale) {
return __axis_rotated ? this.y(scale) : this.x(scale); return __axis_rotated ? this.y(scale) : this.x(scale);
}; };
...@@ -1458,6 +1462,7 @@ ...@@ -1458,6 +1462,7 @@
this.scaleExtent([extent[0] * ratio, extent[1] * ratio]); this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
return this; return this;
}; };
}
/*-- Draw Chart --*/ /*-- Draw Chart --*/
...@@ -2044,7 +2049,7 @@ ...@@ -2044,7 +2049,7 @@
if (withUpdateOrgXDomain) { if (withUpdateOrgXDomain) {
x.domain(d3.extent(getXDomain(c3.data.targets))); x.domain(d3.extent(getXDomain(c3.data.targets)));
orgXDomain = x.domain(); orgXDomain = x.domain();
zoom.scale(x).updateScaleExtent(); if (__zoom_enabled) { zoom.scale(x).updateScaleExtent(); }
subX.domain(x.domain()); subX.domain(x.domain());
brush.scale(subX); brush.scale(subX);
} }
......
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