This is the way to do it:
function zoom() { bars.attr("transform", "translate(" + d3.event.translate[0]+",0)scale(" + d3.event.scale + ",1)"); chart.select(".x.axis") .attr("transform", "translate(" + d3.event.translate[0]+","+(height)+")") .call(xAxis.scale(x.rangeRoundBands([0, width * d3.event.scale],.1 * d3.event.scale))); chart.select(".y.axis") .call(yAxis); }
http://jsfiddle.net/0917vvqt/
Just translate and scale the stripes to X not x and y, also translate xAxis from d3.event.translate [0] (x axis).
EDIT 1: Here is an updated example with a clip: http://jsfiddle.net/9rypxf10/
kevinkl3
source share