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);