Created
February 10, 2017 22:51
-
-
Save kfatehi/7d4283be92dc82d5d1380e229e3b659e to your computer and use it in GitHub Desktop.
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
'use strict'; | |
var width = 300; | |
var height = 300; | |
var radius = Math.min(width, height) / 2; | |
var donutWidth = 75; | |
var color = d3.scaleOrdinal(d3.schemeCategory20b); | |
var svg = d3.select('#chart') | |
.append('svg') | |
.attr('width', width) | |
.attr('height', height) | |
.append('g') | |
.attr('transform', 'translate(' + (width / 2) + | |
',' + (height / 2) + ')'); | |
var arc = d3.arc() | |
.innerRadius(radius - donutWidth) | |
.outerRadius(radius); | |
var pie = d3.pie() | |
.value(function(d) { return d.count; }) | |
.sort(null); | |
d3.csv('topics.csv', function(error, dataset) { | |
dataset.forEach(function(d) { | |
d.count = +d.count; | |
d.enabled = true; // NEW | |
}); | |
var path = svg.selectAll('path') | |
.data(pie(dataset)) | |
.enter() | |
.append('path') | |
.attr('d', arc) | |
.attr('fill', function(d, i) { | |
return color(d.data.label); | |
}) // UPDATED (removed semicolon) | |
.each(function(d) { this._current = d; }); // NEW | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment