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
View.xml
Run Reset Copy Open in playground
<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
View.xml
Run Reset Copy Open in playground
<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 Name Type Default Description 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 Name Type Description slicesPieSlice[]Slices
Events Name Type Description slicePresskey: stringkeys: objectA slice was pressed. For "Other" key is empty and keys lists its slices
Methods Name Description getParts(): Part[]Drawn slices and their shares. tone 0 is the "Other" slice.
PieSlice A slice of a pie chart.
Properties Name Type Default Description keystringKey labelstringName valueanynullValue. Zero and negative values draw no slice but appear in the list
Related BarChart Trend Stat