I am new to D3 and I am actually trying horizontal panning options for a bar chart. I have tried the following example where horizantal panning works perfectly but there are certain problems that i could see. As I want to limit the panning with respect to the data that are present in the graph (how to restrict the chart only with the valid data) and I could see the bar chart showing up in the negative horizontal side of the graph (How to hide the bars when it reaches negative horizontal side) Please help me through this. Are there any working examples available online. Thank you.
--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
var zoom = d3.behavior.zoom().scaleExtent([1, 1]); zoom.x(x); zoom.on('zoom', function() { svg.select('.data').enter().append("rect").attr("class", "bar") .attr("x", function(d) { return x(d.day)+14; }) .attr("width", x.rangeBand()/3) .attr("y", function(d) { return y(d.steps); }) .attr("height", function(d) { return height - y(d.steps); }); });
svg.call(zoom);
svg.selectAll(".bar") .data(data) .enter().append("rect") .attr("class", "bar") .attr("x", function(d) { return x(d.day)+14; }) .attr("width", x.rangeBand()/3) .attr("y", function(d) { return y(d.steps); }) .attr("height", function(d) { return height - y(d.steps); });