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

172
Visualizações
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 à 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