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

170
Views
Adding Dummy Zero Records to Nested Data in D3.js

My goal is to produce a frequency line chart where each line represents a year, the values represent counts of distinct names and the x-axis represents the average_score (rounded down to the nearest integer). The problem is that there are some pairs of year and rating for which the count of names returned is null. I would like to add zero records where this is the case.

Given all of this, I am new to JavaScript and cannot find an example of this being done programmatically with for loops. I am hoping that someone can point me to an example of how this could be done given the existing code below:

    d3.dsv(",", "average-score.csv", function (d) {
        return {
            name: d["name"],
            year: d["year"],
            average_score: d["average_score"],
            users_rated: d["users_rated"]
        }
    }).then(function (data) {

        var nested_data = d3.nest()
            .key(function (d) {
                return d.year;
            })
            .key(function (d) {
                return Math.floor(d.average_score);
            })
            .rollup(function (names) {
                return names.length;
            })
            .entries(data);
about 4 years ago · Juan Pablo Isaza
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!