Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

101
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda