D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mapearlson
Full window
Github gist
2014-11-19-Michael-Pearlson-HW4(Part1)
<!DOCTYPE html> <meta charset="utf-8"> <style> body { font: 10px sans-serif; } .arc path { stroke: #fff; } </style> <body> <script src="https://d3js.org/d3.v3.min.js"></script> <script> var width = 1000, height = 700, radius = Math.min(width, height) / 2; var color = d3.scale.ordinal() .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); var arc = d3.svg.arc() .outerRadius(radius - 10) .innerRadius(radius - 200); var pie = d3.layout.pie() .sort(null) .value(function(d) { return d.Rate; }); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); d3.csv("proj6.csv", function(error, data) { data.forEach(function(d) { d.Rate = +d.Rate; }); var g = svg.selectAll(".arc") .data(pie(data)) .enter().append("g") .attr("class", "arc"); g.append("path") .attr("d", arc) .style("fill", function(d) { return color(d.data.id); }); g.append("text") .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; }) .attr("dy", ".35em") .style("text-anchor", "middle") .text(function(d) { return d.data.id; }); }); </script>
Modified
http://d3js.org/d3.v3.min.js
to a secure url
https://d3js.org/d3.v3.min.js