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

236
Views
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 answers
Answer question

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 Report
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!