d3.js - d3 call zoom on graph with mouseover on items -


i have call zoom attached graph , works fine.

when attach mouseover event item ( rectangle) in chart mouseover fires zoom isn't called.

i'm trying have mouse-rollover make tooltip appear , 'mouse-click , drag' make chart pan on y-axis only.

is there easy way these work or should customize events in example?

http://bl.ocks.org/stepheneb/1182434

bar = g.selectall(".bar")             .data(currentdata)             .enter().append('rect')             .attr("class", "horizontal bar")             .attr("x", 0)          .attr("height", ordinalscale.rangeband())             .attr("y", function(d) {             return ordinalscale(d.key);         })             .attr("width", 0)             .on("mouseover", function(d) {              tooltip = d3.select("body").append("div")                 .attr("class", "tooltip")                 .style("opacity", 0);               tooltip.style("left", (d3.event.pagex - 80) + "px")                 .style("top", (d3.event.pagey) + "px")                 .append('p')                 .text(d.key)                 .attr('class', 'tootip-key')                 .append('p')                 .text(d.value)                 .attr('class', 'tooltip-value');              tooltip.transition()                 .duration(200)                 .style("opacity", 0.9);          })              .on("mouseout", function(d) {              tooltip.remove();           }); 

and zoom behavior attached so.

g.append("g")         .attr("class", "y axis")         .call(yaxis)         .attr("pointer-events", "all")         .call(d3.behavior.zoom().on("zoom", zoom)); 

thanks!

the easiest way tooltip append svg:title element elements want have tooltip. rest taken care of browser. if need fancier, have @ tipsy.

to limit panning y axis, ignore translation x value in handler function (zoom in case).


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -