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

171
Vistas
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
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