Last active
March 29, 2016 05:13
-
-
Save robert8138/6dff75888860f814f0b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.keys(window.calendarMap).forEach(function(key){ | |
document.getElementById(key) | |
.addEventListener(‘click’, function(){ | |
makeCalendar(key); | |
}); | |
}); | |
// ... a bunch of D3 code to set up my calendar visualization ... // | |
function makeCalendar(eventType) { | |
var url = "http://127.0.0.1:5000/api/" + eventType | |
d3.json(url, function(error, data) { | |
var dataSet = data['json_list'] | |
var datasetMunged = d3.nest() | |
.key(function(d) { return format(new Date(d.date)); }) | |
.rollup(function(events) { | |
return d3.sum(events, function(d) { | |
return d.duration|| 0; }); }) | |
.map(dataSet); | |
var colors = ["#ffffd9","#edf8b1","#c7e9b4", | |
"#7fcdbb","#41b6c4","#1d91c0", | |
"#225ea8","#253494","#081d58"] | |
var colorScale = d3.scale.quantize() | |
.domain([0, 200]) | |
.range(colors); | |
rect.classed("day", true) | |
.style("fill", function(d) { | |
return colorScale(datasetMunged[d]); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment