Back to LibraryCharts
Pie Chart
Added Jun 16, 2026
A solid pie chart with 5 color-coded slices, a clock-sweep animation, and click-to-reveal tooltips via the legend. Powered by a Power Apps collection. Inspired by the shadcn/ui Pie Chart.
Dark Mode
Pie Chart
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(colPieData, {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(varPieAnimate, true); Set(varTooltipPieIdx, 0)
- Paste the copied YAML into Power Apps Studio (Ctrl+V).
- The pie sweeps in from 12 o'clock on load. Click a legend item to highlight its slice and show a tooltip with the label, value, and percentage. Click it again to dismiss.
- To replay the animation: Set(varPieAnimate, false); Set(varPieAnimate, true)
- Replace colPieData with any data source that has {label, value} columns (up to 5 slices; colors cycle through blue, emerald, amber, violet, slate).
Problem Solved
Renders an animated SVG pie chart with clock-sweep animation and interactive legend inside a Power Apps Image control.
Integration
Bind colPieData to any data source with {label, value} columns. The chart redraws automatically when the collection changes.
YAML Code
- conPieChart:
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:
- tmrPieAnimate:
Control: Timer@2.1.0
Properties:
Duration: =1200
Height: =1
OnTimerEnd: =Set(varPieAnimate, false)
Repeat: =false
Start: =varPieAnimate
Visible: =false
Width: =1
X: =0
Y: =0
- lblPieTitle:
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"
Width: =400
X: =20
Y: =14
- lblPieDesc:
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
- rectPieHeader:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =68
- imgPieChart:
Control: Image@2.2.3
Properties:
Height: =216
Width: =416
X: =12
Y: =72
Image: |-
=With(
{
_n: CountRows(colPieData),
_total: Sum(colPieData, value),
_cx: 208,
_cy: 108,
_r: 96,
_p: Min(1, tmrPieAnimate.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(colPieData, Value - 1), value) / _total,
_tf: Index(colPieData, 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(varTooltipPieIdx = 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 & "/>"
)
),
""
)
)
)
) &
"</svg>"
)
)
)
- galPieLegend:
Control: Gallery@2.15.0
Variant: Horizontal
Properties:
Fill: =RGBA(0, 0, 0, 0)
Height: =36
Items: =Sequence(CountRows(colPieData))
ShowScrollbar: =false
TemplatePadding: =0
TemplateSize: =440 / Max(1, CountRows(colPieData))
Width: =440
X: =0
Y: =296
Children:
- imgPieLegDot:
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
- lblPieLegLabel:
Control: Label@2.5.1
Properties:
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
Height: =14
Size: =10
Text: =Index(colPieData, ThisItem.Value).label
Width: =62
X: =28
Y: =11
- btnPieLegHit:
Control: Button@0.0.45
Properties:
Appearance: ='ButtonCanvas.Appearance'.Transparent
Height: =Parent.TemplateHeight
OnSelect: =If(varTooltipPieIdx = ThisItem.Value, Set(varTooltipPieIdx, 0), Set(varTooltipPieIdx, ThisItem.Value))
Text: =""
Width: =Parent.TemplateWidth
X: =0
Y: =0
- conPieTooltip:
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: =varTooltipPieIdx > 0
Width: =130
X: =Max(10, Min(300, (varTooltipPieIdx - 1) * (440 / Max(1, CountRows(colPieData))) + 22 - 65))
Y: =218
Children:
- lblTooltipPieLabel:
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(varTooltipPieIdx > 0, Index(colPieData, varTooltipPieIdx).label, "")
Width: =116
X: =8
Y: =6
- imgTooltipPieDot:
Control: Image@2.2.3
Properties:
Fill: =Switch(varTooltipPieIdx, 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
- lblTooltipPieValue:
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(varTooltipPieIdx > 0, Text(Index(colPieData, varTooltipPieIdx).value), "")
Width: =108
X: =20
Y: =28
- lblTooltipPiePct:
Control: Label@2.5.1
Properties:
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =18
Size: =10
Text: =If(varTooltipPieIdx > 0, Text(Round(Index(colPieData, varTooltipPieIdx).value / Max(1, Sum(colPieData, value)) * 100, 1)) & "% of total", "")
Width: =116
X: =8
Y: =50
- rectPieFooter:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =340
- lblPieTrend:
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
- lblPieDateRange:
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