Back to LibraryCharts
Pie Chart - Donut
Added Jun 18, 2026
A donut chart with a clock-sweep animation and click-to-reveal tooltips via the legend. The donut hole is rendered via an SVG circle overlay. Powered by a Power Apps collection. Inspired by the shadcn/ui Pie Chart - Donut.
Dark Mode
Pie Chart - Donut
January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months
CopySnips Live Preview
How to Use
- Create the collection: ClearCollect(colPieDntData, {label: "Chrome", value: 275}, {label: "Safari", value: 200}, {label: "Firefox", value: 187}, {label: "Edge", value: 173}, {label: "Other", value: 90})
- On your screen's OnVisible, add: Set(varPieDntAnimate, true); Set(varTooltipPieDntIdx, 0)
- Paste the copied YAML into Power Apps Studio (Ctrl+V).
- The donut sweeps in from 12 o'clock. Click a legend item to highlight the slice and show a tooltip.
- To replay the animation: Set(varPieDntAnimate, false); Set(varPieDntAnimate, true)
- Replace colPieDntData with any data source that has {label, value} columns.
Problem Solved
Renders an animated SVG donut chart with an interactive legend inside a Power Apps Image control. The donut hole is achieved by overlaying a white circle on top of the full pie slices.
Integration
Bind colPieDntData to any data source with {label, value} columns. The chart redraws automatically when the collection changes.
YAML Code
- conPieDntChart:
Control: GroupContainer@1.5.0
Variant: ManualLayout
Properties:
BorderColor: =RGBA(226, 232, 240, 1)
BorderStyle: =BorderStyle.Solid
BorderThickness: =1
DropShadow: =DropShadow.Regular
Fill: =RGBA(255, 255, 255, 1)
Height: =390
RadiusBottomLeft: =12
RadiusBottomRight: =12
RadiusTopLeft: =12
RadiusTopRight: =12
Width: =440
Children:
- tmrPieDntAnimate:
Control: Timer@2.1.0
Properties:
Duration: =1200
Height: =1
OnTimerEnd: =Set(varPieDntAnimate, false)
Repeat: =false
Start: =varPieDntAnimate
Visible: =false
Width: =1
X: =0
Y: =0
- lblPieDntTitle:
Control: Label@2.5.1
Properties:
Align: =Align.Center
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Bold
Height: =24
Size: =14
Text: ="Pie Chart - Donut"
Width: =400
X: =20
Y: =14
- lblPieDntDesc:
Control: Label@2.5.1
Properties:
Align: =Align.Center
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =20
Size: =12
Text: ="January - June 2024"
Width: =400
X: =20
Y: =44
- rectPieDntHeader:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =68
- imgPieDntChart:
Control: Image@2.2.3
Properties:
Height: =216
Width: =416
X: =12
Y: =72
Image: |-
=With(
{
_n: CountRows(colPieDntData),
_total: Sum(colPieDntData, value),
_p: Min(1, tmrPieDntAnimate.Value / 1200)
},
With(
{ _ease: 1 - Power(Max(0, 1 - _p), 3) },
"data:image/svg+xml;utf8, " & EncodeUrl(
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 416 216'>" &
Concat(Sequence(_n),
With(
{
_cf: Sum(FirstN(colPieDntData, Value - 1), value) / _total,
_tf: Index(colPieDntData, Value).value / _total
},
With(
{
_sf: _cf,
_ef: Min(_cf + _tf, _ease)
},
If(_sf < _ease And _ef - _sf > 0.001,
With(
{
_sa: _sf * 2 * Pi() - Pi() / 2,
_ea: _ef * 2 * Pi() - Pi() / 2,
_df: _ef - _sf
},
With(
{
_x1: Text(Round(208 + 96 * Cos(_sa), 1)),
_y1: Text(Round(108 + 96 * Sin(_sa), 1)),
_x2: Text(Round(208 + 96 * Cos(_ea), 1)),
_y2: Text(Round(108 + 96 * Sin(_ea), 1)),
_la: If(_df > 0.5, "1", "0"),
_col: Switch(Value, 1, "#3b82f6", 2, "#10b981", 3, "#f59e0b", 4, "#8b5cf6", "#6b7280"),
_str: If(varTooltipPieDntIdx = Value, " stroke='white' stroke-width='3'", "")
},
"<path d='M 208,108 L " & _x1 & "," & _y1 &
" A 96,96 0 " & _la & ",1 " & _x2 & "," & _y2 &
" Z' fill='" & _col & "'" & _str & "/>"
)
),
""
)
)
)
) &
"<circle cx='208' cy='108' r='50' fill='white'/>" &
"</svg>"
)
)
)
- galPieDntLegend:
Control: Gallery@2.15.0
Variant: Horizontal
Properties:
Fill: =RGBA(0, 0, 0, 0)
Height: =36
Items: =Sequence(CountRows(colPieDntData))
ShowScrollbar: =false
TemplatePadding: =0
TemplateSize: =440 / Max(1, CountRows(colPieDntData))
Width: =440
X: =0
Y: =296
Children:
- imgPieDntLegDot:
Control: Image@2.2.3
Properties:
Fill: =Switch(ThisItem.Value, 1, RGBA(59, 130, 246, 1), 2, RGBA(16, 185, 129, 1), 3, RGBA(245, 158, 11, 1), 4, RGBA(139, 92, 246, 1), RGBA(107, 114, 128, 1))
Height: =10
Image: =Blank()
RadiusBottomLeft: =5
RadiusBottomRight: =5
RadiusTopLeft: =5
RadiusTopRight: =5
Width: =10
X: =14
Y: =13
- lblPieDntLegLabel:
Control: Label@2.5.1
Properties:
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
Height: =14
Size: =10
Text: =Index(colPieDntData, ThisItem.Value).label
Width: =62
X: =28
Y: =11
- btnPieDntLegHit:
Control: Button@0.0.45
Properties:
Appearance: ='ButtonCanvas.Appearance'.Transparent
Height: =Parent.TemplateHeight
OnSelect: =If(varTooltipPieDntIdx = ThisItem.Value, Set(varTooltipPieDntIdx, 0), Set(varTooltipPieDntIdx, ThisItem.Value))
Text: =""
Width: =Parent.TemplateWidth
X: =0
Y: =0
- conPieDntTooltip:
Control: GroupContainer@1.5.0
Variant: ManualLayout
Properties:
BorderColor: =RGBA(226, 232, 240, 1)
BorderStyle: =BorderStyle.Solid
BorderThickness: =1
DropShadow: =DropShadow.Regular
Fill: =RGBA(255, 255, 255, 1)
Height: =72
RadiusBottomLeft: =8
RadiusBottomRight: =8
RadiusTopLeft: =8
RadiusTopRight: =8
Visible: =varTooltipPieDntIdx > 0
Width: =130
X: =Max(10, Min(300, (varTooltipPieDntIdx - 1) * (440 / Max(1, CountRows(colPieDntData))) + 22 - 65))
Y: =218
Children:
- lblTooltipPieDntLabel:
Control: Label@2.5.1
Properties:
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Semibold
Height: =18
Size: =10
Text: =If(varTooltipPieDntIdx > 0, Index(colPieDntData, varTooltipPieDntIdx).label, "")
Width: =116
X: =8
Y: =6
- imgTooltipPieDntDot:
Control: Image@2.2.3
Properties:
Fill: =Switch(varTooltipPieDntIdx, 1, RGBA(59, 130, 246, 1), 2, RGBA(16, 185, 129, 1), 3, RGBA(245, 158, 11, 1), 4, RGBA(139, 92, 246, 1), RGBA(107, 114, 128, 1))
Height: =8
Image: =Blank()
RadiusBottomLeft: =4
RadiusBottomRight: =4
RadiusTopLeft: =4
RadiusTopRight: =4
Width: =8
X: =8
Y: =30
- lblTooltipPieDntValue:
Control: Label@2.5.1
Properties:
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Semibold
Height: =18
Size: =11
Text: =If(varTooltipPieDntIdx > 0, Text(Index(colPieDntData, varTooltipPieDntIdx).value), "")
Width: =108
X: =20
Y: =28
- lblTooltipPieDntPct:
Control: Label@2.5.1
Properties:
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =18
Size: =10
Text: =If(varTooltipPieDntIdx > 0, Text(Round(Index(colPieDntData, varTooltipPieDntIdx).value / Max(1, Sum(colPieDntData, value)) * 100, 1)) & "% of total", "")
Width: =116
X: =8
Y: =50
- rectPieDntFooter:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =340
- lblPieDntTrend:
Control: Label@2.5.1
Properties:
Align: =Align.Center
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Semibold
Height: =20
Size: =12
Text: ="Trending up by 5.2% this month"
Width: =400
X: =20
Y: =350
- lblPieDntDateRange:
Control: Label@2.5.1
Properties:
Align: =Align.Center
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =20
Size: =11
Text: ="Showing total visitors for the last 6 months"
Width: =400
X: =20
Y: =374Implementation
Copies the customized component code directly to your clipboard. Use Ctrl+V in Power Apps Studio.
Something not pasting right? Troubleshooting guide