Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added external radius padding #894

Merged
merged 1 commit into from
Jul 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/pie-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ dc.pieChart = function (parent, chartGroup) {
var _emptyTitle = 'empty';

var _radius,
_innerRadius = 0;
_innerRadius = 0,
_externalRadiusPadding = 0;

var _g;
var _cx;
Expand Down Expand Up @@ -251,6 +252,20 @@ dc.pieChart = function (parent, chartGroup) {
}
}

/**
#### .externalRadiusPadding([externalRadiusPadding])
Get or set the external radius padding of the pie chart. This will force the radius of the
pie chart to become smaller or larger depending on the value. Default external radius padding is 0px.

**/
_chart.externalRadiusPadding = function (_) {
if (!arguments.length) {
return _externalRadiusPadding;
}
_externalRadiusPadding = _;
return _chart;
};

/**
#### .innerRadius([innerRadius])
Get or set the inner radius of the pie chart. If the inner radius is greater than 0px then the
Expand Down Expand Up @@ -306,7 +321,7 @@ dc.pieChart = function (parent, chartGroup) {
};

function buildArcs() {
return d3.svg.arc().outerRadius(_radius).innerRadius(_innerRadius);
return d3.svg.arc().outerRadius(_radius - _externalRadiusPadding).innerRadius(_innerRadius);
}

function isSelectedSlice(d) {
Expand Down Expand Up @@ -413,8 +428,8 @@ dc.pieChart = function (parent, chartGroup) {
var centroid;
if (_externalLabelRadius) {
centroid = d3.svg.arc()
.outerRadius(_radius + _externalLabelRadius)
.innerRadius(_radius + _externalLabelRadius)
.outerRadius(_radius - _externalRadiusPadding + _externalLabelRadius)
.innerRadius(_radius - _externalRadiusPadding + _externalLabelRadius)
.centroid(d);
} else {
centroid = arc.centroid(d);
Expand Down