kor TürkçeGitHub

PieChart

Shows the parts of a whole as a pie or donut.

kor/ui/PieChartSource

When to use

  • Use it for a few parts that add up to a whole.
  • To compare close values, use BarChart.

Examples

Pie

Loading the example

<k:PieChart label="Sales by region" unit="thousand TRY">
	<k:PieSlice label="Marmara" value="420"/>
	<k:PieSlice label="Aegean" value="260"/>
	<k:PieSlice label="Central Anatolia" value="190"/>
	<k:PieSlice label="Mediterranean" value="130"/>
</k:PieChart>

Donut from a model

Loading the example

<k:PieChart kind="donut" label="Expenses" totalLabel="Expenses" compact="true" unit="TRY" slices="{/costs}">
	<k:PieSlice label="{name}" value="{amount}"/>
</k:PieChart>

Keyboard

Tab Enter
Moves through slices and presses one when slicePress is set.

API

Properties

NameTypeDefaultDescription
labelstringAccessible name
kindstringpiepie or donut
sizeint220Diameter in pixels
unitstringUnit
decimalsint0Decimal places
compactbooleanfalseWhether to use short numbers (1.2M)
totalLabelstringName in the center of the donut. Defaults to "Total"
maxSlicesint6Maximum slices (2-6). The rest is added up in "Other"

Aggregations

NameTypeDescription
slicesPieSlice[]Slices

Events

NameTypeDescription
slicePresskey: string
keys: object
A slice was pressed. For "Other" key is empty and keys lists its slices

Methods

NameDescription
getParts(): Part[]Drawn slices and their shares. tone 0 is the "Other" slice.

PieSlice

A slice of a pie chart.

Properties

NameTypeDefaultDescription
keystringKey
labelstringName
valueanynullValue. Zero and negative values draw no slice but appear in the list

Related

BarChartTrendStat