AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated 7.6.0 version of this document. Switch to the 8.4.0 version to see the up to date information.

class anychart.charts.Pie Improve this Doc

Extends: anychart.core.SeparateChart

Pie (Donut) Chart Class.
Note: Use method anychart#pie to get an instance of this class:

Methods Overview

Miscellaneous
connectorLength()Getter for outside labels connector length.
connectorStroke()Getter for outside labels connectors stroke settings.
data()Gets current chart data.
explode()Getter for the value of pie slice exploding.
explodeSlice()Explodes slice at index.
explodeSlices()Explodes all slices.
fill()Getter for the pie slices fill in normal state.
forceHoverLabels()Getter for the current displaying of the label on hover event.
getCenterPoint()Getter for the pie chart center point.
getPixelInnerRadius()Getter for the current pie pixel inner radius.
getPixelRadius()Getter for the current pie pixel outer radius.
getType()Returns chart type.
group()Gets the last values set by grouping function or null.
hatchFill()Getter for current hatch fill settings.
hatchFillPalette()Getter for chart hatch fill palette settings.
hover()Sets the hover state on a slice by index.
hoverFill()Getter for the pie slices fill in the hover state.
hoverHatchFill()Getter for current hover hatch fill settings.
hoverLabels()Getter for pie hover data labels.
hoverStroke()Getter for the pie slices stroke in the hover state.
innerRadius()Getter for the inner radius in case of a Donut chart.
insideLabelsOffset()Getter for inside labels offset settings.
labels()Getter for the current pie labels.
outsideLabelsCriticalAngle()Getter for outside labels connector critical angle settings.
outsideLabelsSpace()Getter for outside labels space settings.
overlapMode()Getter for overlap mode for labels.
palette()Getter for the current pie palette.
radius()Getter for the current pie outer radius.
sort()Getter for the current sort setting.
startAngle()Getter for the angle from which the first slice is drawn clockwise.
stroke()Getter for the pie slices stroke in the normal state.
tooltip()Getter for tooltip settings.
unhover()Removes hover from the pie slice.

Methods Description

connectorLength

Getter for outside labels connector length.

Returns:

number | string | null - Outside labels connector length.
Setter for outside labels connector length.
Note: Works only with outside labels mode.

Params:

NameTypeDefaultDescription
valuenumber | string
20
Value to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

connectorStroke

Getter for outside labels connectors stroke settings.

Returns:

anychart.graphics.vector.Stroke - Current stroke settings.
Setter for outside labels connectors stroke settings. Learn more about stroke settings.
Note: Works only with outside labels mode.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null
{color: "black", opacity: 0.3}
Stroke settings.
thicknessnumber
1
Line thickness.
dashpatternstring
Controls the pattern of dashes and gaps used to stroke paths.
lineJoinanychart.graphics.vector.StrokeLineJoin
Line join style.
lineCapanychart.graphics.vector.StrokeLineCap
Line cap style.

Returns:

anychart.charts.Pie - Self instance for method chaining.

data

Gets current chart data.

Returns:

anychart.data.View - Current data view.
Sets data for the current chart. Learn more about mapping at anychart.data.Mapping.

Params:

NameTypeDescription
valueanychart.data.View | anychart.data.Mapping | anychart.data.Set | ArrayData for the chart.
csvSettingsObject.<string, (string|boolean)>If CSV string is passed by first param, you can pass CSV parser settings here as a hash map.

Returns:

anychart.charts.Pie - Self instance for method chaining.

explode

Getter for the value of pie slice exploding.

Returns:

string | number - Exploding value.
Sets the value of exploding in pixels.
Note: Works only with exploded points mode.

Params:

NameTypeDefaultDescription
valuestring | number
15
Value of the expansion/exploding.

Returns:

anychart.charts.Pie - Self instance for method chaining.

explodeSlice

Explodes slice at index.

Params:

NameTypeDefaultDescription
indexnumber
Pie slice index that should be exploded or not.
explodeboolean
true
Whether to explode.

Returns:

anychart.charts.Pie - Self instance for method chaining.

explodeSlices

Explodes all slices.

Params:

NameTypeDefaultDescription
valueboolean
false
Whether to explode.

Returns:

anychart.charts.Pie - Self instance for method chaining.

fill

Getter for the pie slices fill in normal state.

Returns:

anychart.graphics.vector.Fill | function - Current fill in the normal state.
Setter for the pie slices fill in the normal state. Learn more about coloring.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Fill | function
// return the fill from the default pallete.
function() {
  return this.sourceColor;
};
or Fill, or fill-function, which should look like this:function() { // this: { // index : number - the index of the current point // sourceColor : anychart.graphics.vector.Fill - fill of the current point // } return myFill; //anychart.graphics.vector.Fill };.

Returns:

anychart.charts.Pie - Self instance for method chaining.

forceHoverLabels

Getter for the current displaying of the label on hover event.

Returns:

boolean - The current displaying flag.
Setter for the displaying of the label on hover event.

Params:

NameTypeDefaultDescription
valueboolean
false
Boolean flag.

Returns:

anychart.charts.Pie - Self instance for method chaining.

getCenterPoint

Getter for the pie chart center point.
Note: Works only after anychart.charts.Pie#draw is called.

Returns:

anychart.math.Coordinate - XY coordinate of the current pie chart center.

getPixelInnerRadius

Getter for the current pie pixel inner radius. Note: Works only after anychart.charts.Pie#draw is called.

Returns:

number - XY coordinate of the pie center.

getPixelRadius

Getter for the current pie pixel outer radius.
Note: Works only after anychart.charts.Pie#draw is called.

Returns:

number - Pixel value of the pie radius.

getType

Returns chart type.

Returns:

anychart.enums.ChartTypes - Current chart type.

group

Gets the last values set by grouping function or null.

Returns:

null | function - Current grouping function.
Setter for points grouping function.

Params:

NameTypeDefaultDescription
valuestring | null | function
null
Filter function or disable value.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hatchFill

Getter for current hatch fill settings.
Setter for hatch fill settings.

Params:

NameTypeDescription
patternFillOrTypeanychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function | anychart.graphics.vector.HatchFill.HatchFillType | string | booleanPatternFill or HatchFill instance or type of hatch fill.
colorstringColor.
thicknessnumberThickness.
sizenumberPattern size.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hatchFillPalette

Getter for chart hatch fill palette settings.

Returns:

anychart.palettes.HatchFills - Hatch fills palette instance
Setter for chart hatch fill palette settings.
Note: Works only with anychart.charts.Pie#hatchFill.

Params:

NameTypeDescription
valueArray.<anychart.graphics.vector.HatchFill.HatchFillType> | Object | anychart.palettes.HatchFillsChart hatch fill palette settings to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hover

Sets the hover state on a slice by index.

Params:

NameTypeDescription
indexnumberSlice index.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hoverFill

Getter for the pie slices fill in the hover state.

Returns:

anychart.graphics.vector.Fill | function - Current fill in the hover state.
Setter for the pie slices fill in the hover state. Learn more about coloring.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Fill | function
// return lighter fill of the default pallete.
function() {
  return anychart.color.lighten(this.sourceColor);
};
or Fill, or fill-function, which should look like:function() { // this: { // index : number - the index of the current point // sourceColor : anychart.graphics.vector.Fill - fill of the current point // } return myFill; //anychart.graphics.vector.Fill };.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hoverHatchFill

Getter for current hover hatch fill settings.

Returns:

anychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function - Current hover hatch fill.
Setter for hover hatch fill settings.

Params:

NameTypeDescription
patternFillOrTypeanychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function | anychart.graphics.vector.HatchFill.HatchFillType | string | booleanPatternFill or HatchFill instance or type of hatch fill.
colorstringColor.
thicknessnumberThickness.
sizenumberPattern size.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hoverLabels

Getter for pie hover data labels.

Returns:

anychart.core.ui.LabelsFactory - LabelsFactory instance.
Setter for pie hover data labels.

Params:

NameTypeDefaultDescription
valueObject | boolean | null
true
Chart hover data labels settings.

Returns:

anychart.charts.Pie - Self instance for method chaining.

hoverStroke

Getter for the pie slices stroke in the hover state.

Returns:

anychart.graphics.vector.Stroke | function - Current stroke in the hover state.
Setter for the pie slices stroke in the hover state. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Stroke | function | string
// return stroke from the default pallete.
function() {
  return anychart.color.darken(this.sourceColor);
};
or Stroke, or stroke-function, which should look like:function() { // this: { // index : number - the index of the current point // sourceColor : anychart.graphics.vector.Stroke - stroke of the current point // } return myStroke; //anychart.graphics.vector.Stroke };.

Returns:

anychart.charts.Pie - Self instance for method chaining.
Setter for the pie slices stroke in the hover state. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | null
Stroke settings.
thicknessnumber
1
Line thickness.
dashpatternstring
Controls the pattern of dashes and gaps used to stroke paths.
lineJoinanychart.graphics.vector.StrokeLineJoin
Line join style.
lineCapanychart.graphics.vector.StrokeLineCap
Line cap style.

Returns:

anychart.charts.Pie - Self instance for method chaining.

innerRadius

Getter for the inner radius in case of a Donut chart.

Returns:

string | number | function - Current inner radius of a pie/donut chart.
Setter for the inner radius in case of a Donut chart.

Params:

NameTypeDefaultDescription
valuestring | number | function
0
The value of the inner radius in pixels, percents or function. In general the function should look like this: function(outerRadius){ ... return NUMBER; } .

Returns:

anychart.charts.Pie - Self instance for method chaining.

insideLabelsOffset

Getter for inside labels offset settings.

Returns:

number | string | null - Current inside labels offset.
Setter for inside labels space settings.
Note: Works only with inside labels mode.

Params:

NameTypeDefaultDescription
valuenumber | string
50%
Value to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

labels

Getter for the current pie labels.

Returns:

anychart.core.ui.LabelsFactory - LabelsFactory instance.
Setter for the pie labels.

Params:

NameTypeDefaultDescription
valueObject | boolean | null
true
Chart data labels settings.

Returns:

anychart.charts.Pie - Self instance for method chaining.

outsideLabelsCriticalAngle

Getter for outside labels connector critical angle settings.

Returns:

number | string | null - Outside labels critical angle.
Setter for outside labels connector critical angle settings.
Note: Works only with outside labels mode.

Params:

NameTypeDefaultDescription
valuenumber | string
60
Value to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

outsideLabelsSpace

Getter for outside labels space settings.

Returns:

number | string | null - Current outside labels space.
Setter for outside labels space settings.
Note: Works only with outside labels mode.

Params:

NameTypeDefaultDescription
valuenumber | string
30
Value to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

overlapMode

Getter for overlap mode for labels.

Returns:

anychart.enums.LabelsOverlapMode | string - Overlap mode flag.
Setter for overlap mode for labels.

Params:

NameTypeDefaultDescription
valueanychart.enums.LabelsOverlapMode | string | boolean
'noOverlap'
Value to set.

Returns:

anychart.charts.Pie - Self instance for method chaining.

palette

Getter for the current pie palette.
Setter for a pie palette.

Params:

NameTypeDescription
valueanychart.palettes.RangeColors | anychart.palettes.DistinctColors | Object | Array.<string>Color palette instance.

Returns:

anychart.charts.Pie - Self instance for method chaining.

radius

Getter for the current pie outer radius.

Returns:

string | number - Outer radius.
Setter for the outer pie radius.

Params:

NameTypeDefaultDescription
valuestring | number
'45%'
Value of the outer radius.

Returns:

anychart.charts.Pie - Self instance for method chaining.

sort

Getter for the current sort setting.

Returns:

anychart.enums.Sort - Sort setting.
Setter for the sort setting.
Ascending, Descending and No sorting is supported.

Params:

NameTypeDefaultDescription
valueanychart.enums.Sort | string
'none'
Value of the sort setting.

Returns:

anychart.charts.Pie - Self instance for method chaining.

startAngle

Getter for the angle from which the first slice is drawn clockwise.

Returns:

string | number - Current start angle.
Setter for the angle from which the first slice is drawn clockwise.

Params:

NameTypeDefaultDescription
valuestring | number
0
Value of the start angle.

Returns:

anychart.charts.Pie - Self instance for method chaining.

stroke

Getter for the pie slices stroke in the normal state.

Returns:

anychart.graphics.vector.Stroke | function - Current stroke in the normal state.
Setter for the pie slices stroke in the normal state. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Stroke | function
// return stroke from the default pallete.
function() {
  return anychart.color.darken(this.sourceColor);
};
or Stroke, or stroke-function, which should look like:function() { // this: { // index : number - the index of the current point // sourceColor : anychart.graphics.vector.Stroke - stroke of the current point // } return myStroke; //anychart.graphics.vector.Stroke };.

Returns:

anychart.charts.Pie - Self instance for method chaining.
Setter for the pie slices stroke in the normal state. Learn more about stroke settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | null
Stroke settings.
thicknessnumber
1
Line thickness.
dashpatternstring
Controls the pattern of dashes and gaps used to stroke paths.
lineJoinanychart.graphics.vector.StrokeLineJoin
Line join style.
lineCapanychart.graphics.vector.StrokeLineCap
Line cap style.

Returns:

anychart.charts.Pie - Self instance for method chaining.

tooltip

Getter for tooltip settings.

Returns:

anychart.core.ui.Tooltip - Tooltip instance.
Setter for tooltip settings.

Params:

NameTypeDescription
valueObject | boolean | nullTooltip settings.

Returns:

anychart.charts.Pie - Self instance for method chaining.

unhover

Removes hover from the pie slice.

Returns:

anychart.charts.Pie - Self instance for method chaining.