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

241
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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