Top
You are looking at an outdated 7.7.0 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.SeparateChart

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

Methods Overview

Specific settings
connectorLength()Labels connector length.
getType()Returns chart type.
outsideLabelsCriticalAngle()Outside labels connector critical angle settings.
outsideLabelsSpace()Outside labels space settings.
overlapMode()Overlap mode for labels.
Chart Coloring
hatchFillPalette()Hatch fill palette settings.
palette()Palette settings.
Coloring
connectorStroke()Labels connectors stroke settings.
fill()Fill settings.
hatchFill()Hatch fill settings.
hoverFill()Fill settings on hover state.
hoverHatchFill()Hatch fill settings on hover state.
hoverStroke()Stroke settings on hover state.
stroke()Stroke settings.
Data
data()Data settings.
group()Grouping of the points
sort()Sort setting.
Interactivity
explode()Pie slice exploding.
explodeSlice()Explodes slice at index.
explodeSlices()Explodes all slices.
forceHoverLabels()Displaying of the label on hover event.
hover()Sets the hover state on a slice by index.
tooltip()Tooltip settings.
unhover()Removes hover from the pie slice.
Point Elements
hoverLabels()Labels settings on hover state.
insideLabelsOffset()Inside labels space settings.
labels()Labels settings.
Size and Position
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.
innerRadius()Pie inner radius for Donut chart.
radius()Pie outer radius
startAngle()Start angle for the first slice.

Methods Description

connectorLength

Getter for outside labels connector length.

Returns:

number string null - Outside labels connector length.

Try it:

Setter for outside labels connector length.
Note: Works only with outside labels mode.

Params:

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

Returns:

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

Try it:

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:

Name Type Default Description
value anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | null
"#000 0.3"
Stroke settings.
thickness number
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 - Self instance for method chaining.

Try it:

data

Gets current chart data.

Returns:

anychart.data.View - Current data view.

Try it:

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.
csvSettings Object.<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.

Try it:

Sets the value of exploding in pixels.
Note: Works only with exploded points mode.

Params:

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

Returns:

anychart.charts.Pie - Self instance 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 - Self instance for method chaining.

explodeSlices

Explodes all slices.

Params:

Name Type Default Description
value boolean
false
Whether to explode.

Returns:

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

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.

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 - Self instance for method chaining.

Try it:

forceHoverLabels

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

Returns:

boolean - The current displaying flag.

Try it:

Setter for the displaying of the label on hover event.

Params:

Name Type Default Description
value boolean
false
Boolean flag.

Returns:

anychart.charts.Pie - Self instance 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.

Try it:

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.

Try it:

getType

Returns chart type.

Returns:

anychart.enums.ChartTypes - Current chart type.

Try it:

group

Gets the last values set by grouping function or null.

Returns:

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

Params:

Name Type Default Description
value string | null | function
false
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:

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

Returns:

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

Try it:

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:

Name Type Description
value Array.<anychart.graphics.vector.HatchFill.HatchFillType> | Object | anychart.palettes.HatchFills Chart 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:

Name Type Description
index number Slice index.

Returns:

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

Try it:

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:

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 - Self instance 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 - Self instance for method chaining.

Try it:

hoverLabels

Getter for pie hover data labels.

Returns:

anychart.core.ui.LabelsFactory - LabelsFactory instance.

Try it:

Setter for pie hover data labels.

Params:

Name Type Default Description
value Object | boolean | null
null
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:

Name Type Default Description
value anychart.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:

Name Type Default Description
value anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | null
"none"
Stroke settings.
thickness number
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 - Self instance 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.

Try it:

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 - Self instance for method chaining.

insideLabelsOffset

Getter for inside labels offset settings.

Returns:

number string null - Current inside labels offset.

Try it:

Setter for inside labels space settings.
Note: Works only with inside labels mode.

Params:

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

Returns:

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

Try it:

labels

Getter for the current pie labels.

Returns:

anychart.core.ui.LabelsFactory - LabelsFactory instance.

Try it:

Setter for the pie labels.

Params:

Name Type Default Description
value Object | 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.

Try it:

Setter for outside labels connector critical angle settings.
Note: Works only with outside labels mode.

Params:

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

Returns:

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

Try it:

outsideLabelsSpace

Getter for outside labels space settings.

Returns:

number string null - Current outside labels space.

Try it:

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 - Self instance for method chaining.

Try it:

overlapMode

Getter for overlap mode for labels.

Returns:

anychart.enums.LabelsOverlapMode string - Overlap mode flag.

Try it:

Setter for overlap mode for labels.

Params:

Name Type Default Description
value anychart.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:

Name Type Description
value anychart.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.

Try it:

Setter for the outer pie radius.

Params:

Name Type Default Description
value string | number
"45%"
Value of the outer radius.

Returns:

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

Try it:

sort

Getter for the current sort setting.

Returns:

anychart.enums.Sort - Sort setting.

Try it:

Setter for the sort setting.
Ascending, Descending and No sorting is supported.

Params:

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

Returns:

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

Try it:

startAngle

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

Returns:

string number - Current start angle.

Try it:

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

Params:

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

Returns:

anychart.charts.Pie - Self instance 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 stroke settings.

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 - Self instance for method chaining.

Try it:

Setter for the pie slices stroke in the normal state. Learn more about stroke settings.

Params:

Name Type Default Description
value anychart.graphics.vector.Stroke | anychart.graphics.vector.ColoredFill | string | function | null
"none"
Stroke settings.
thickness number
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 - Self instance for method chaining.

Try it:

tooltip

Getter for tooltip settings.

Returns:

anychart.core.ui.Tooltip - Tooltip instance.

Try it:

Setter for tooltip settings.

Params:

Name Type Default Description
value Object | boolean | null
true
Tooltip 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.

Try it: