Add tooltip to D3 Icicle visual (Observable)
NickName:Cybernetic Ask DateTime:2019-12-06T08:32:01

Add tooltip to D3 Icicle visual (Observable)

I am working with this icicle visual on D3 Observable. I need to add a tooltip, so that it works faster and looks better than native browser version.

I tried this:

  var tooltip = d3.select("body")
    .append("div")
    .style("opacity", 0)
    .attr("class", "tooltip")
    .style("background-color", "white")
    .style("border", "solid")
    .style("border-width", "1px")
    .style("border-radius", "5px")
    .style("padding", "10px");

    var mouseover = function(d) {
    tooltip
      .style("opacity", 1)
    };

  var mousemove = function(d) {
    tooltip
      .html("hello")
      .style("left", (d3.mouse(this)[0]+90) + "px")
      .style("top", (d3.mouse(this)[1]) + "px")
  };

  var mouseleave = function(d) {
    tooltip
      .transition()
      .duration(200)
      .style("opacity", 0)
  };

And adding the events onto the rect:

.on("mouseover", mouseover)
.on("mousemove", mousemove )
.on("mouseleave", mouseleave)

Nothing shows up at all when you hover over the rects of the visual. Can elements be appended to the body in D3 observable?

Copyright Notice:Content Author:「Cybernetic」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59205214/add-tooltip-to-d3-icicle-visual-observable

More about “Add tooltip to D3 Icicle visual (Observable)” related questions

Add tooltip to D3 Icicle visual (Observable)

I am working with this icicle visual on D3 Observable. I need to add a tooltip, so that it works faster and looks better than native browser version. I tried this: var tooltip = d3.select("bo...

Show Detail

Open d3 visual to specific location (icicle)

Using the D3 icicle visual on Observable. How can I navigate to a specific rect without having to click through. So if a user opens the visual, it would programmatically naivgate to/open the visual

Show Detail

Add size to icicle visualization

I'm working off this D3 visualization here: https://bl.ocks.org/mbostock/4347473 How could I add the size of each box next to the label as done here: https://observablehq.com/@d3/zoomable-icicle? ...

Show Detail

zoomable icicle d3 add label in chart

I have read the post about to insert a label into a d3 chart but I don't see the text This is the post: How to add to text to the Zoomable Icicle d3 graph? This is my page with code: http://

Show Detail

D3 Icicle Chart Static Node Height

I'm creating a horizontal D3 Icicle Chart that will be used to display a pedigree. This will only show the father/mother so each node will only ever have two children (its parents) and this will co...

Show Detail

How to add ToolTip to D3 Tree node?

I have D3 Tree like this: http://mbostock.github.io/d3/talk/20111018/tree.html How can I add description i.e. ToolTip to each node so that if use hover any node the tooltip will be visible (assum...

Show Detail

Vertical Icicle in D3

I need to rotate this Icicle to a vertical(up-down) way: https://observablehq.com/@d3/zoomable-icicle. The first screen option works but when I clicked the item, it fails. The following changes wor...

Show Detail

Extend D3 Chart to add tooltip from HTML page

I have a D3 graph showing tooltip on mouseover. The graph is currently created from a JS file. D3 graph code: var tooltip = d3.select('body') .append('div') .style('position', 'absolute

Show Detail

D3 Add Tooltip to Stacked Area Chart

I would like to add tooltip on mouseover event for the below stacked area chart: https://observablehq.com/@d3/stacked-area-chart?collection=@d3/d3-shape The tooltip should contain current mouse

Show Detail

Creating an Icicle Chart using Python Visual in Power BI

I am trying to create an icicle chart for a company hierarchy. Our company uses Power BI for it's reports and I can see that there isn't an icicle visual within Power BI but that one can be created...

Show Detail