Class AmPieChart

AmPieChart class creates pie/donut chart. In order to display pie chart you need to set at least three properties - dataProvider, titleField and valueField.

example

var chartData = [{title:"Pie I have eaten",value:70},{title:"Pie I haven\'t eaten",value:30}]; var chart = new AmCharts.AmPieChart(); chart.valueField = "value"; chart.titleField = "title"; chart.dataProvider = chartData; chart.write("chartdiv");

Index

Properties

Methods

Properties

public alphaField: string

Name of the field in chart's dataProvider which holds slice's alpha.

public angle: number

Pie lean angle (for 3D effect). Valid range is 0 - 90.

public balloonText: string

Balloon text. The following tags can be used: value, title, percents, description. title: percents% (value)\ndescription

public chartData: Array<any>

Read-only. Array of Slice objects.

public colorField: string

Name of the field in chart's dataProvider which holds slice's color.

public colors: Array<any>

Specifies the colors of the slices, if the slice color is not set. If there are more slices than colors in this array, the chart picks random color. ["#FF0F00", "#FF6600", "#FF9E01", "#FCD202", "#F8FF01", "#B0DE09", "#04D215", "#0D8ECF", "#0D52D1", "#2A0CD0", "#8A0CCF", "#CD0D74", "#754DEB", "#DDDDDD", "#999999", "#333333", "#000000", "#57032A", "#CA9726", "#990000", "#4B0C25"]

public depth3D: number

Depth of the pie (for 3D effect).

public descriptionField: string

Name of the field in chart's dataProvider which holds a string with description.

public gradientRatio: Array<number>

Example: [-0.2,0.2]. Will make slices to be filled with color gradients.

public groupPercent: number

If there is more than one slice whose percentage of the pie is less than this number, those slices will be grouped together into one slice. This is the "other" slice. It will always be the last slice in a pie.

public groupedAlpha: number

Opacity of the group slice. Value range is 0 - 1.

default

1

public groupedColor: string

Color of the group slice. The default value is not set - this means the next available color from "colors" array will be used.

public groupedDescription: string

Description of the group slice.

public groupedPulled: boolean

If this is set to true, the group slice will be pulled out when the chart loads.

public groupedTitle: string

Title of the group slice. Other

public hideLabelsPercent: number

Slices with percent less then hideLabelsPercent won't display labels This is useful to avoid cluttering up the chart, if you have a lot of small slices. 0 means all labels will be shown.

public hoverAlpha: number

Opacity of a hovered slice. Value range is 0 - 1.

default

1

public innerRadius: any

Inner radius of the pie, in pixels or percents.

public labelRadius: number

The distance between the label and the slice, in pixels. You can use negative values to put the label on the slice.

default

30

public labelRadiusField: string

Name of the field in dataProvider which specifies the length of a tick. Note, the chart will not try to arrange labels automatically if this property is set.

public labelText: string

Label text. The following tags can be used: value, title, percents, description. title: percents%

public labelTickAlpha: number

Label tick opacity. Value range is 0 - 1. 0.2

public labelTickColor: string

Label tick color. #000000

public labelsEnabled: boolean

Specifies whether data labels are visible.

default

true

public marginBottom: number

Bottom margin of the chart.

default

5

public marginLeft: number

Left margin of the chart.

public marginRight: number

Right margin of the chart.

public marginTop: number

Top margin of the chart.

default

5

public minRadius: number

Minimum radius of the pie, in pixels.

default

10

public outlineAlpha: number

Pie outline opacity. Value range is 0 - 1.

public outlineColor: string

Pie outline color. #FFFFFF

public outlineThickness: number

Pie outline thickness.

default

1

public pieAlpha: number

Opacity of the slices. You can set the opacity of individual slice too.

default

1

public pieBaseColor: string

Color of the first slice. All the other will be colored with darker or brighter colors.

public pieBrightnessStep: number

Lightness increase of each subsequent slice. This is only useful if pieBaseColor is set. Use negative values for darker colors. Value range is from -255 to 255.

default

30

public pieX: any

You can set fixed position of a pie center, in pixels or in percents.

public pieY: any

You can set fixed position of a pie center, in pixels or in percents.

public pullOutDuration: number

Pull out duration, in seconds.

default

1

public pullOutEffect: string

Pull out effect. Possible values are ">", "<", elastic" and "bounce". bounce

public pullOutOnlyOne: boolean

If this is set to true, only one slice can be pulled out at a time. If the viewer clicks on a slice, any other pulled-out slice will be pulled in.

public pullOutRadius: any

Pull out radius, in pixels or percents 0.2

public pulledField: string

Name of the field in chart's dataProvider which holds a boolean value telling the chart whether this slice must be pulled or not.

public radius: any

Radius of a pie, in pixels or percents. By default, radius is calculated automatically.

public sequencedAnimation: boolean

Specifies whether the animation should be sequenced or all slices should appear at once.

public startAlpha: number

Initial opacity of all slices. If you set startDuration higher than 0, slices will fade in from startAlpha.

default

1

public startAngle: number

Angle of the first slice, in degrees. This will work properly only if "depth3D" is set to 0. If "depth3D" is greater than 0, then there can be two angles only: 90 and 270. Value range is 0-360.

default

90

public startDuration: number

Duration of the animation, in seconds.

default

1

public startEffect: string

Animation effect. Possible values are ">", "<", "elastic" and "bounce". bounce

public startRadius: any

Radius of the positions from which the slices will fly in. default 5

public titleField: string

Name of the field in chart's dataProvider which holds slice's title.

public urlField: string

Name of the field in chart's dataProvider which holds url which would be accessed if the user clicks on a slice.

public urlTarget: string

If url is specified for a slice, it will be opened when user clicks on it. urlTarget specifies target of this url. Use _blank if you want url to be opened in a new window. _self

public valueField: string

Name of the field in chart's dataProvider which holds slice's value.

public visibleInLegendField: string

Name of the field in chart's dataProvider which holds boolean variable defining whether this data item should have an entry in the legend.

Methods

public addListener(type: string, handler: (e: { type: string; dataItem: AmCharts.Slice; }) => void): any

Adds event listener of the type "clickSlice" or "pullInSlice" or "pullOutSlice" to the object.

Parameters

  • type: string

    Always "clickSlice" or "pullInSlice" or "pullOutSlice".

  • handler: (e: { type: string; dataItem: AmCharts.Slice; }) => void

    If the type is "clickSlice", dispatched when user clicks on a slice. If the type is "pullInSlice", dispatched when user clicks on a slice and the slice is pulled-in. If the type is "pullOutSlice", dispatched when user clicks on a slice and the slice is pulled-out. If the type is "rollOutSlice", dispatched when user rolls-out of the slice. If the type is "rollOverSlice", dispatched when user rolls-over the slice.

Returns

any

public animateAgain(): any

You can trigger the animation of the pie chart.

Returns

any

public clickSlice(index: any): any

You can trigger the click on a slice from outside. index - the number of a slice or Slice object.

Parameters

  • index: any

Returns

any

public hideSlice(index: any): any

Hides slice. index - the number of a slice or Slice object.

Parameters

  • index: any

Returns

any

public rollOutSlice(index: any): any

You can simulate roll-out of a slice from outside. index - the number of a slice or Slice object.

Parameters

  • index: any

Returns

any

public rollOverSlice(index: any): any

You can simulate roll-over a slice from outside. index - the number of a slice or Slice object.

Parameters

  • index: any

Returns

any

public showSlice(index: any): any

Shows slice. index - the number of a slice or Slice object.

Parameters

  • index: any

Returns

any