javascript - d3 limit zoom level for time axis -
my code below zooming on time x-axis. want set limit in between time should zoom in or out i.e. upper limit , lower limit of time. i've tried put boundaries value in zoomed function suggested in d3 graph limited zoom thread. isn't working.
var x = d3.time.scale() .domain([(start_date), (end_date)]) .range([0, width]); var zoom = d3.behavior.zoom() .x(x) .on("zoom", zoomed); svg = d3.select('#chart'+k) .append("svg:svg") .attr('width', width + margin.left + margin.right) .attr('height', height + margin.top + margin.bottom) .append("svg:g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")") .call(zoom); function zoomed() { svg.selectall(".line") .remove(); makebackground(); svg.select(".x.axis").call(xaxis); d3.select(".x.axis.top").call(xaxistop); svg.select(".x.grid") .call(make_x_axis() .ticksize(-height, 0, 0) .tickformat("")); svg.selectall(".circle-path") .remove(); d3.selectall(".traintag") .remove(); drawpaths(); drawcircle(x,y,chartbody,traindata[0]); }
Comments
Post a Comment