Class: PieChart

PieChart

The pie chart implementation is usually used to visualize a small categorical distribution. The pie chart uses keyAccessor to determine the slices, and valueAccessor to calculate the size of each slice relative to the sum of all values. Slices are ordered by ordering which defaults to sorting by key.

Examples:


new PieChart(parent [, chartGroup])

Create a Pie Chart

Parameters:
Name Type Argument Description
parent String | node | d3.selection

Any valid d3 single selector specifying a dom block element such as a div; or a dom element or d3 selection.

chartGroup String <optional>

The name of the chart group this chart instance should be placed in. Interaction with a chart will only trigger events and redraws within the chart's group.

Mixes In:
Source:
Example
// create a pie chart under #chart-container1 element using the default global chart group
var chart1 = new PieChart('#chart-container1');
// create a pie chart under #chart-container2 element using chart group A
var chart2 = new PieChart('#chart-container2', 'chartGroupA');

Classes

PieChart

Methods


cx( [cx])

Get or set center x coordinate position. Default is center of svg.

Parameters:
Name Type Argument Description
cx Number <optional>
Source:
Returns:
Type
Number | PieChart

cy( [cy])

Get or set center y coordinate position. Default is center of svg.

Parameters:
Name Type Argument Description
cy Number <optional>
Source:
Returns:
Type
Number | PieChart

drawPaths( [drawPaths])

Get or set whether to draw lines from pie slices to their labels.

Parameters:
Name Type Argument Description
drawPaths Boolean <optional>
Source:
Returns:
Type
Boolean | PieChart

emptyTitle( [title])

Title to use for the only slice when there is no data.

Parameters:
Name Type Argument Description
title String <optional>
Source:
Returns:
Type
String | PieChart

externalLabels( [externalLabelRadius])

Position slice labels offset from the outer edge of the chart.

The argument specifies the extra radius to be added for slice labels.

Parameters:
Name Type Argument Description
externalLabelRadius Number <optional>
Source:
Returns:
Type
Number | PieChart

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.

Parameters:
Name Type Argument Default Description
externalRadiusPadding Number <optional>
0
Source:
Returns:
Type
Number | PieChart

innerRadius( [innerRadius])

Get or set the inner radius of the pie chart. If the inner radius is greater than 0px then the pie chart will be rendered as a doughnut chart.

Parameters:
Name Type Argument Default Description
innerRadius Number <optional>
0
Source:
Returns:
Type
Number | PieChart

minAngleForLabel( [minAngleForLabel])

Get or set the minimal slice angle for label rendering. Any slice with a smaller angle will not display a slice label.

Parameters:
Name Type Argument Default Description
minAngleForLabel Number <optional>
0.5
Source:
Returns:
Type
Number | PieChart

radius( [radius])

Get or set the outer radius. If the radius is not set, it will be half of the minimum of the chart width and height.

Parameters:
Name Type Argument Description
radius Number <optional>
Source:
Returns:
Type
Number | PieChart

slicesCap( [cap])

Get or set the maximum number of slices the pie chart will generate. The top slices are determined by value from high to low. Other slices exceeding the cap will be rolled up into one single Others slice.

Parameters:
Name Type Argument Description
cap Number <optional>
Source:
Returns:
Type
Number | PieChart