I managed to get this visualization (small multiple diagrams by regions) to work in a slightly different form when I use dummy data for dates, i.e. when i use only years. However, when I use actual dates like this, this is problematic:
Record,Code,2008-1-1,2008-2-1,2008-3-1,2008-4-1,2008-5-1,2008-6-1,2008-7-1...
instead of this dummy data that works great
Record,Code,1895,1896,1897,1898,1899,1900,1901...
When I use full dates, the browser freezes; no error message. I used to correct parsing errors, but this seems to be beyond my capabilities.
Here's the broken Plunker: https://plnkr.co/edit/fOlpxo648OyCSM7Sq8ak?p=preview
Another Plunker that actually loads but uses dummy data is at the bottom of this question.
This piece of code seems especially problematic:
function createDatesArr(start, end) {
var arr = [];
for (var i = start; i <= end; i++ ) {
arr.push((i));
}
return arr;
}
In a slightly different form, I will get an error that the "dates" are not defined. I tried to solve this problem with the following code:
var dateFormat = d3.time.format("%Y-%m-%d");
var startDate = new Date('2008-1-1');
var endDate = new Date ('2017-12-1');
var dates = createDatesArr(startDate, endDate);
Or so:
var dateFormat = d3.time.format("%Y-%m-%d");
var startYear = "2008-1-1";
var endYear = "2017-12-1";
var dates = createYearsArr(startYear, endYear);
Or like this:
var dateFormat = d3.time.format("%Y-%m-%d");
var startDate = d3.min(dataset, function(d) { return d.Date; });
var endDate = d3.max(dataset, function(d) { return d.Date; });
var dates = createDatesArr(startDate, endDate);
Or, alternatively, defining "dates" as follows:
d3.csv(dataPath, function(data) {
var dates = d3.keys(data[0]).slice(1);
data = data.filter(function(d) {
return true;
});
var dates = d3.keys(data[0]).slice(1);
None of this worked, but I hope someone can help me fix it.
Here's another Plunker that really works, which demonstrates what I'm ultimately trying to achieve, albeit using dummy data (only years) for dates: http://plnkr.co/edit/jRC8iQg2kdtlZWtGE020?p=preview
Please, help.