Skip to content

Instantly share code, notes, and snippets.

@trinary
Last active December 20, 2015 03:29
Show Gist options
  • Save trinary/6064292 to your computer and use it in GitHub Desktop.
Save trinary/6064292 to your computer and use it in GitHub Desktop.
Not quite a clock face
{"description":"Not quite a clock face","endpoint":"","display":"svg","public":true,"require":[],"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}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/gIfByg6.png"}
var data = d3.range(12);
var rScale = d3.scale.linear().domain(d3.extent(data)).range([0,360]);
console.log(rScale(0), rScale(10));
var g = d3.select("svg").append("g")
.attr("transform","translate(100,100)");
var ticks = g.selectAll("g").data(data)
.enter()
.append("g")
.attr("transform", function(d,i) { return "rotate(" + rScale(d) + ")translate (50,0)";})
ticks.append("line")
.attr("x1", 1)
.attr("y1", 0)
.attr("x2", 5)
.attr("y2", 0)
.style("stroke", "#000");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment