What I want to create is a scalable and scalable timeline in D3. At the moment, I do not use D3, but only two zoom buttons. My problem is this: when I click the button, I update the scale and redraw the axis, as well as the brush. For some reason, the brush does not update the degree rectangle and the pen, but only the background. I know that I'm not really updating .extent()brushes. But shouldn't the brush update when zoomed out?
Here is the relevant piece of code. The rest can be found in this violin .
document.getElementById('in').addEventListener('click', zoom.bind(null, .1));
document.getElementById('out').addEventListener('click', zoom.bind(null, -.1));
function zoom(step) {
var offset;
zoomScale += step;
if(zoomScale < 1)
zoomScale -= step;
offset = (zoomScale * width - width) / 2;
xScale
.range([-offset, width + offset]);
brushGroup
.call(brush);
xAxisGroup
.transition()
.call(xAxis);
}
Thanks a lot!
source
share