Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

94
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda