Skip to content

Instantly share code, notes, and snippets.

@nicohaemhouts
Created July 13, 2015 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicohaemhouts/e4b8cf76b51bde574f6f to your computer and use it in GitHub Desktop.
Save nicohaemhouts/e4b8cf76b51bde574f6f to your computer and use it in GitHub Desktop.
Progres Arc
{"description":"Progres Arc","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.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,"ajax-caching":true}
var height = 750,
width = 800,
svg = d3.select('svg')
.attr('width', width)
.attr('height', height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"),
t = 2 * Math.PI;
// An arc function with all values bound except the endAngle. So, to compute an
// SVG path string for a given angle, we pass an object with an endAngle
// property to the `arc` function, and it will return the corresponding string.
var arc = d3.svg.arc()
.innerRadius(180)
.outerRadius(240)
.startAngle(0);
// Add the background arc, from 0 to 100% (τ).
var background = svg.append("path")
.datum({endAngle: t})
.style("fill", "#ddd")
.attr("d", arc);
// Add the foreground arc in orange, currently showing 12.7%.
var foreground = svg.append("path")
.datum({endAngle: 0.83 * t})
.style("fill", "orange")
.attr("d", arc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment