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

243
Visualizações
D3js text not reading from database data

I am working on this project and momentally I need to display only one number which is return from database from my backend.

This is my code:

var data2 = d3.json("/Events/CountEmployees/").then(function (data) {
    d3.select("#data")
        .selectAll("p")
        .data(data)
        .enter()
        .append('p')
        .style("color", "red")
        .text(data => data.Count1);
   // console.log( data);
})

When I execute the console.log(data) command it actually reads my wanted data but I don't get the problem is with the text attribute in D3js.

This is the result I get from it: enter image description here

Now what I want is to display that data from count1 which is "6" as a text on my page but I am stuck and I can't find any solution. Can you please help me with this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found a solution to this.

Added <h4 id="rData"> </h4> on my html side, and this script on my .js file.

var data2 = d3.json("/Index/MyData/").then(function (data) {
    const test = data.map(d => d.Number);
    $('#rData').text(test);
})

Since I am retrieving data from database, I had to use a d3 function to get those data from my controller function (MyData) which return these data. Leaving this here in case someone else needs this some time in the future.

about 4 years ago · Juan Pablo Isaza Relatório
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