Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tarang19's avatar

D3 On hover Show id

Wanted to show id on hover of node but i am getting undefine any one tell me where i done wrong i am using d3 + vue

my code in d3

let tooltip = d3.select("body")
      .append("div")
      .style("position", "absolute")
      .style("z-index", "10")
      .style("visibility", "hidden");
      //.text("a simple tooltip");

    // external tree
    let externalTree = enter
      .filter( descendant => {
        // filter children with extrernal tree
        return _.has( descendant, 'data.data.externalTreeId' ) && !_.isNull(descendant.data.data.externalTreeId);
      })
      .append('a')
      //.attr('id', 'check')
      .attr('href', 'javascript:;')
      .classed('external-tree', true)
      .attr('data-id', descendant => {
        //let url = 'http://localhost:3000/user/';
        return `${descendant.data.id}`;
      })
      .on("mouseover", function (event,d){
        tooltip.transition()
          .duration(200)
          .style("opacity", .9);
        tooltip.text(descendant => {
          console.log('descendant',descendant);
          return `${descendant.data.id}`;
        })
          .style("left", (event.pageX) + 'px')
          .style("top", (event.pageY -28) + 'px');
      })
      .on("mouseout", function (d){
        tooltip.transition()
          .duration(500)
          .style("opacity", 0);
  });
0 likes
0 replies

Please or to participate in this conversation.