[ Launch: Arc Test ] 89b2cfa3d63d9309c887 by dmann99
-
-
Save dmann99/89b2cfa3d63d9309c887 to your computer and use it in GitHub Desktop.
Arc Test
This file contains 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
{"description":"Arc Test","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"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":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/TnDHEzf.png"} |
This file contains 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
<svg id="svg_donut" width="600" height="400"></svg> |
This file contains 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
var cScale = d3.scale.linear().domain([0, 100]).range([0, 2 * Math.PI]); | |
// Start Pos (0..100) | End Pos (0..100) | Color | Level | |
data = [[ 0, 25,"#fe5656",0], | |
[25, 50,"#5bff5b",0], | |
[50,100,"#7a7ac6",0]] | |
var vis = d3.select("#svg_donut"); | |
var inRadius=0; | |
var barWidth=161; | |
var arc = d3.svg.arc() | |
.innerRadius(function(d){return inRadius+(d[3]*barWidth);}) | |
.outerRadius(function(d){return inRadius+barWidth+(d[3]*barWidth);}) | |
.startAngle(function(d){return cScale(d[0]);}) | |
.endAngle(function(d){return cScale(d[1]);}); | |
vis.selectAll("path") | |
.data(data) | |
.enter() | |
.append("path") | |
.attr("d", arc) | |
.style("fill", function(d){return d[2];}) | |
.attr("transform", "translate(260,200)"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment