Default Pie Slices
http://stackoverflow.com/questions/37008892/modify-donut-chart-slices-in-c3-d3
by ggamir
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.css Copy"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<div id="chart"></div>
JavaScript
var selected = ['A', 'B', 'C'];
var _ARC = '.c3-arc';
var _SCALING = '1.1';
function getCurrentlySelected() {
var _PREFIX = _ARC + '-';
return d3.selectAll(_PREFIX + selected.join(', ' + _PREFIX));
}
var chart = c3.generate({
bindto: '#chart',
data: {
columns: [
['A', 30, 200, 100, 400, 150, 250],
['B', 130, 100, 140, 200, 150, 50],
['C', 50, 100, 130, 240, 200, 150],
['D', 130, 100, 140, 200, 150, 50],
['E', 130, 150, 200, 300, 200, 100]
],
type: 'pie',
onmouseover: function(d, i) {
// Reset scaling
d3.selectAll(_ARC).attr('transform', 'scale(1)');
// Set selected, and expand
var selected = [d.id];
d3.select(i).attr('transform', 'scale(' + _SCALING + ')');
},
onmouseout: function(d, i) {
// Reset scaling
d3.selectAll(_ARC).attr('transform', 'scale(1)');
}
},
onrendered: function() {
setTimeout(function() {
if (selected.length > 0) {
getCurrentlySelected().attr('transform', 'scale(' + _SCALING + ')');
}
});
}
});