Created
November 25, 2013 08:41
-
-
Save nasum/7638309 to your computer and use it in GitHub Desktop.
D3.jsで円グラフ
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
D3.jsで円グラフを複数並べてみた |
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
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
} | |
body { | |
background: #dfd; | |
font: 30px sans-serif; | |
} |
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
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<div class="watch"> | |
</div> |
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 dataset = [15,20,30,40]; | |
var width = 200; | |
var height = 200; | |
var rect = 100; | |
var svg = d3.select('.watch') | |
.append('svg') | |
.attr('width',width) | |
.attr('height',height); | |
var arc = d3.svg.arc() | |
.innerRadius(0) | |
.outerRadius(rect) | |
.startAngle(0.5*Math.PI) | |
.endAngle(1.5*Math.PI); | |
var arc2 = d3.svg.arc() | |
.innerRadius(0) | |
.outerRadius(rect) | |
.startAngle(0*Math.PI) | |
.endAngle(0.2*Math.PI); | |
svg.append("path") | |
.attr("d", arc) | |
.attr("transform", "translate(" + rect +"," + rect +")"); | |
svg.append("path") | |
.attr("d", arc2) | |
.attr("transform", "translate(" + rect +"," + rect +")"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment