dc.pieChart('#pie01')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75);
dc.pieChart('#pie02')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.externalLabels(30)
.drawPaths(false);
dc.pieChart('#pie03')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.externalLabels(30)
.drawPaths(true);
dc.pieChart('#pie04')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.externalRadiusPadding(20);
dc.pieChart('#pie06')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.minAngleForLabel(2);
dc.pieChart('#pie07')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.slicesCap(2);
dc.pieChart('#pie08')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.slicesCap(2)
.othersLabel('Other Animals')
.ordinalColors(['red', 'green', 'blue']);
dc.pieChart('#pie09')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(75)
.renderLabel(false)
.legend(dc.legend()
.x(20)
.y(30)
.itemHeight(12)
.gap(10));
dc.pieChart('#donut01')
.dimension(petDimension)
.group(petGroup)
.width(350)
.height(300)
.radius(100)
.innerRadius(20)
.on('renderlet', function (chart) {
chart
.selectAll('text.pie-slice')
.text(function (d) {
return d.data.key + ' ' +
dc.utils.printSingleValue((d.endAngle - d.startAngle) / (2 * Math.PI) * 100) + '%';
});
});
dc.pieChart('#donut02')
.dimension(petDimension)
.group(petGroup)
.width($(donut02.anchor()).parent().width())
.height(300)
.radius(100)
.innerRadius(60)
.on('renderlet', function (chart) {
// get the number of cats selected
let pieSlice;
chart.data().forEach(function(d){if(d.key == "Cat") pieSlice = d.value;});
// create an extra text Element if it does not exist
if(d3.select('#circle-value').empty()){
let g = d3.selectAll('#donut02 .pie-slice-group')
.append("text")
.attr('text-anchor', 'middle')
.attr('y', 5)
.attr('id', 'circle-value');
};
// set value to number of cats
d3.select('#circle-value').text(pieSlice + ' Cats Selected');
// add percentages to pie slices
chart
.selectAll('text.pie-slice')
.text(function (d) {
let value = Math.round((d.endAngle - d.startAngle) / (2 * Math.PI) * 100)
return dc.utils.printSingleValue(value) + '%';
});
});