Top
You are looking at an outdated 7.3.1 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.charts.Pie Improve this Doc

Extends: anychart.core.Chart

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.
fill()Getter for the pie slices fill in normal state.
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.
group()Gets the last values set by grouping function or null.
hatchFill()Getter for current hatch fill settings.
hatchFillPalette()Chart hatch fill palette settings.
hoverFill()Getter for the pie slices fill in the hover state.
hoverHatchFill()Getter for current hover hatch fill settings.
hoverLabels()Getter for series 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.
labels()Getter for the current pie labels.
outsideLabelsCriticalAngle()Getter for outside labels connector critical angle settings.
outsideLabelsSpace()Getter for outside labels space settings.
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 tolltip settings.

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:

Name Type Default Description
value number | string
30%
Value to set.

Returns:

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

Try it:

connectorStroke

Getter for outside labels connectors stroke settings.

Returns:

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

Params:

Name Type Default Description
fillFunction function
function() {
 return anychart.color.darken(this.sourceColor);
}
Function that looks like function(){ // this.sourceColor - color returned by fill() getter. return fillValue; // type anychart.graphics.vector.Fill }.

Returns:

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

Try it:

Setter for outside labels connectors stroke settings.
Learn more about stroke settings: https://docs.anychart.com/7.3.1/General_settings/Elements_Stroke
Note: Works only with outside labels mode.

Params:

Name Type Default Description
strokeOrFill anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | null
Fill settings or stroke settings.
thickness number
1
Line thickness.
dashpattern string
Controls the pattern of dashes and gaps used to stroke paths.
lineJoin anychart.graphics.vector.StrokeLineJoin
Line join style.
lineCap anychart.graphics.vector.StrokeLineCap
Line cap style.

Returns:

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

Try it:

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:

Name Type Description
value anychart.data.View | anychart.data.Mapping | anychart.data.Set | Array Data for the chart.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

explode

Getter for the value of pie slice exploding.

Returns:

string number - Exploding value.
Sets the value of exploding in pixels.

Params:

Name Type Default Description
value string | number
15
Value of the expansion/exploding.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

explodeSlice

Explodes slice at index.

Params:

Name Type Default Description
index number
Pie slice index that should be exploded or not.
explode boolean
true
Whether to explode.

Returns:

anychart.charts.Pie - .

Try it:

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 at: https://docs.anychart.com/7.3.1/General_settings/Elements_Fill

Params:

Name Type Default Description
value anychart.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 - An instance of anychart.charts.Pie class for method chaining.

Try it:

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.

Try it:

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.

group

Gets the last values set by grouping function or null.

Returns:

null function - Current grouping function.
Setter for points grouping function.
Groups point and adds final point to the end. Note: To disable filter function pass null or 'none'.

Params:

Name Type Description
value string | null | function Filter function or disablt value (null, 'none').

Returns:

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

Try it:

hatchFill

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

Params:

Name Type Description
patternFillOrType anychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function | anychart.graphics.vector.HatchFill.HatchFillType | string | boolean PatternFill or HatchFill instance or type of hatch fill.
color string Color.
thickness number Thickness.
size number Pattern size.

Returns:

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

Try it:

hatchFillPalette

Chart hatch fill palette settings.

Params:

Name Type Description
value Array.<anychart.graphics.vector.HatchFill.HatchFillType> | Object | anychart.palettes.HatchFills Chart hatch fill palette settings to set.

Returns:

anychart.palettes.HatchFills anychart.charts.Pie - Return current chart hatch fill palette or itself for chaining call.

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 at: https://docs.anychart.com/7.3.1/General_settings/Elements_Fill

Params:

Name Type Default Description
value anychart.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 - An instance of anychart.charts.Pie class for method chaining.

Try it:

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:

Name Type Description
patternFillOrType anychart.graphics.vector.PatternFill | anychart.graphics.vector.HatchFill | function | anychart.graphics.vector.HatchFill.HatchFillType | string | boolean PatternFill or HatchFill instance or type of hatch fill.
color string Color.
thickness number Thickness.
size number Pattern size.

Returns:

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

Try it:

hoverLabels

Getter for series hover data labels.

Returns:

anychart.core.ui.LabelsFactory - Current labels instance.

Try it:

Setter for series hover data labels.

Params:

Name Type Description
value Object | boolean | null pie hover data labels settings.

Returns:

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

Try it:

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 coloring at: https://docs.anychart.com/7.3.1/General_settings/Elements_Stroke

Params:

Name Type Default Description
value anychart.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 - An instance of anychart.charts.Pie class for method chaining.

Try it:

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:

Name Type Default Description
value string | 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 - An instance of anychart.charts.Pie class for method chaining.

Try it:

labels

Getter for the current pie labels.
It is used to access to the current (default too) settings of the labels.
Note: Default labels will appear when this getter is called for the first time.

Returns:

anychart.core.ui.LabelsFactory - An instance of anychart.core.ui.LabelsFactory class for method chaining.

Try it:

Setter for the pie labels.
Note: positioing is done using anychart.core.ui.LabelsFactory#positionFormatter method and text is formatted using anychart.core.ui.LabelsFactory#textFormatter method.

Params:

Name Type Default Description
value Object | boolean | null
LabelsFactory instance.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

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.
Labels with the connector angle greater than critical are not displayed.
Note: Works only with outside labels mode.

Params:

Name Type Default Description
value number | string
60
Value to set.

Returns:

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

Try it:

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:

Name Type Default Description
value number | string
30%
Value to set.

Returns:

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

Try it:

palette

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

Params:

Name Type Description
value anychart.palettes.RangeColors | anychart.palettes.DistinctColors | Object | Array.<string> Color palette instance.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

radius

Getter for the current pie outer radius.

Returns:

string number - Outer radius.
Setter for the outer pie radius.
Radius can be set as a number (considered as number of pixels), or as a string, e.g.'42%' or '152px'.

Params:

Name Type Default Description
value string | number
'40%'
Value of the outer radius.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

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:

Name Type Default Description
value anychart.enums.Sort | string
anychart.enums.Sort.NONE
Value of the sort setting.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

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:

Name Type Default Description
value string | number
-90
Value of the start angle.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it:

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 coloring at: https://docs.anychart.com/7.3.1/General_settings/Elements_Stroke

Params:

Name Type Default Description
value anychart.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 - An instance of anychart.charts.Pie class for method chaining.

Try it:

tooltip

Getter for tolltip settings.

Returns:

anychart.core.ui.Tooltip - An instance of anychart.core.ui.Tooltip class for method chaining.

Try it:

Setter for tolltip settings.

Params:

Name Type Description
value Object | boolean | null Tooltip settings.

Returns:

anychart.charts.Pie - An instance of anychart.charts.Pie class for method chaining.

Try it: