Skip to content

Instantly share code, notes, and snippets.

@su-docker
Created October 17, 2013 18:49
Show Gist options
  • Save su-docker/7030175 to your computer and use it in GitHub Desktop.
Save su-docker/7030175 to your computer and use it in GitHub Desktop.
Promo Calendar
{"description":"Promo Calendar","endpoint":"","display":"svg","public":true,"require":[{"name":"underscore","url":"http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"utils.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/hR42SF6.png"}
//Dates
function getDates(year) {
var date = new Date(year,0,1);
var allDates = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [], 11: []};
while(date.getFullYear() == year) {
allDates[date.getMonth()].push(date);
var aDate = new Date(date);
aDate.setDate(date.getDate()+1);
date = aDate;
}
return allDates;
}
var dates = getDates(2013);
var svg = d3.select("svg");
var months = svg.selectAll('.month').data(dates);
months
.enter()
.append("g");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment