Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Adding tooltip with data from csv file to a choropleth map

I'm trying to add a tooltip with data on a choropleth map. It already appears on mouse over but I'm stuck trying to show the data that's in the csv file I used to create the map. I'd like to show the "name" + "pop" + "%".

Here's how I loaded the data:

d3.queue()
  .defer(d3.json, "https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson")
  .defer(d3.csv, "https://raw.githubusercontent.com/lcercos/geojson/main/eurostat_data-map.csv", function(d) { data.set(d.code, +d.pop); })
  .await(ready);

Here's the on mouse over function:

function ready(error, topo) {
  var div = d3.select("body").append("div") // calling tooltip
     .attr("class", "tooltip")
     .style("opacity", 0);

  let mouseOver = function(d) {
    d3.selectAll(".Country")
      .transition()
      .duration(100)
      .style("opacity", .5)

    d3.select(this)
      .transition()
      .duration(100)
      .style("opacity", 1)
      .style("stroke", "black");

      div.transition()
           .duration(50)
           .style("opacity", 1);
      div.html(d.name + d.value + "%") // html data <- Is here the problem?
           .style("left", (d3.event.pageX + 15) + "px")
           .style("top", (d3.event.pageY - 10) + "px");

  }

  let mouseLeave = function(d) {
    d3.selectAll(".Country")
      .transition()
      .duration(0)
      .style("opacity",)
    d3.select(this)
      .transition()
      .duration(0)
      .style("stroke", "transparent");
    div.transition()
           .duration("50")
           .style("opacity", 0);
  }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!