javascript - Hiding a tooltip with transition in d3 - Stack Overflow

I'm new to d3 and coding in general, and I'm making a social network graph with some tooltips

I'm new to d3 and coding in general, and I'm making a social network graph with some tooltips. The tooltip is supposed to appear when someone hovers over a node and fade out and hide when the mouse is removed. I managed to get the tip to fade out with a transition, but the tip is actually still there, just invisible, so the box and text sometimes obscure other nodes, making it so that you can't successfully hover over parts of other nodes and trigger other tooltips. When the code is just node.on('mouseout', tip.hide);, it works fine, but it doesn't have the transitions.

Here's the fiddle. The effect I'm talking about doesn't happen there as much as in a normal browser though. /

      node.on('mouseover', tip.show); 
      node.on('mouseout', function() { 
          d3.select(".d3-tip")
          .transition()
          .delay(100)
          .duration(500)
          .style("opacity",0);
          tip.hide;
         }); 
      //node.on('mouseout', tip.hide); //This is the original line.

Edit:

I figured it out. I needed to add another style that I didn't know about. Here's the fixed code:

  node.on('mouseout', function() {
      d3.select(".d3-tip")
      .transition()
        .delay(100)
        .duration(600)
        .style("opacity",0)
        .style('pointer-events', 'none')
      });

I'm new to d3 and coding in general, and I'm making a social network graph with some tooltips. The tooltip is supposed to appear when someone hovers over a node and fade out and hide when the mouse is removed. I managed to get the tip to fade out with a transition, but the tip is actually still there, just invisible, so the box and text sometimes obscure other nodes, making it so that you can't successfully hover over parts of other nodes and trigger other tooltips. When the code is just node.on('mouseout', tip.hide);, it works fine, but it doesn't have the transitions.

Here's the fiddle. The effect I'm talking about doesn't happen there as much as in a normal browser though. http://jsfiddle/wPLB5/

      node.on('mouseover', tip.show); 
      node.on('mouseout', function() { 
          d3.select(".d3-tip")
          .transition()
          .delay(100)
          .duration(500)
          .style("opacity",0);
          tip.hide;
         }); 
      //node.on('mouseout', tip.hide); //This is the original line.

Edit:

I figured it out. I needed to add another style that I didn't know about. Here's the fixed code:

  node.on('mouseout', function() {
      d3.select(".d3-tip")
      .transition()
        .delay(100)
        .duration(600)
        .style("opacity",0)
        .style('pointer-events', 'none')
      });
Share Improve this question edited Jun 25, 2014 at 20:05 kellyh asked Jun 24, 2014 at 22:07 kellyhkellyh 1132 silver badges8 bronze badges 1
  • maybe set height and width to 0 instead of opacity to 0? i couldn't see the issue in the fiddle. – Union find Commented Jun 25, 2014 at 2:26
Add a ment  | 

2 Answers 2

Reset to default 6

I figured it out. I needed to add a pointer-events style. Here's the fixed code:

  node.on('mouseout', function() {
      d3.select(".d3-tip")
      .transition()
        .delay(100)
        .duration(600)
        .style("opacity",0)
        .style('pointer-events', 'none')
      });

You can try the two approaches using div tooltip or using svg title.

 node.append("svg:title")
   .text(function(d) { return "Location:" + " " + d.location + 
      "\nFloruit Date:" + " " + d.floruitDate; });

Also, maybe this answer will be useful for you D3: show data on mouseover of circle.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744211472a4563352.html

相关推荐

  • javascript - Hiding a tooltip with transition in d3 - Stack Overflow

    I'm new to d3 and coding in general, and I'm making a social network graph with some tooltips

    9天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信