Back to LibraryCharts
Bar Chart
Added Jun 14, 2026
A vertical bar chart powered by a Power Apps collection. Inspired by the shadcn/ui Bar Chart.
Dark Mode
Bar 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 a collection: ClearCollect(colBarChartData, {month: "January", Value: 186}, ...)
- Paste the copied YAML into Power Apps Studio (Ctrl+V).
- On your screen's OnVisible, add: Set(varBarChartAnimate, true); Set(varTooltipBarIdx, 0)
- To replay animation: Set(varBarChartAnimate, false); ClearCollect(...); Set(varBarChartAnimate, true)
Problem Solved
Renders a dynamic SVG bar chart inside a Power Apps Image control with a grow-up animation driven by a hidden Timer. Click any bar to show its value.
Integration
Bind colBarChartData to any data source with {month, Value} columns.
YAML Code
- conBarChart:
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: =320
RadiusBottomLeft: =12
RadiusBottomRight: =12
RadiusTopLeft: =12
RadiusTopRight: =12
Width: =440
Children:
- tmrChartAnimate:
Control: Timer@2.0.0
Properties:
Duration: =1200
Height: =1
OnTimerEnd: =Set(varBarChartAnimate, false)
Repeat: =false
Start: =varBarChartAnimate
Visible: =false
Width: =1
X: =0
Y: =0
- lblChartTitle:
Control: Label@2.5.1
Properties:
Color: =RGBA(15, 23, 42, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Bold
Height: =24
Size: =14
Text: ="Bar Chart"
Width: =400
X: =20
Y: =14
- lblChartDescription:
Control: Label@2.5.1
Properties:
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =20
Size: =12
Text: ="January - June 2024"
Width: =400
X: =20
Y: =44
- rectHeaderLine:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =72
- imgBarChart:
Control: Image@2.2.3
Properties:
Height: =176
Width: =416
X: =12
Y: =80
Image: |-
=With(
{
_n: CountRows(colBarChartData),
_max: Max(colBarChartData, Value),
_p: Min(1, tmrChartAnimate.Value / 1200)
},
With(
{
_range: Max(1, _max),
_slot: Int(400 / Max(1, _n)),
_barW: Int(400 / Max(1, _n) * 0.55),
_ease: If(varBarChartAnimate, 1 - Power(Max(0, 1 - _p), 3), 1)
},
"data:image/svg+xml;utf8, " & EncodeUrl(
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 416 176'>" &
"<line x1='8' y1='8' x2='408' y2='8' stroke='#e2e8f0' stroke-width='1'/>" &
"<line x1='8' y1='41' x2='408' y2='41' stroke='#e2e8f0' stroke-width='1'/>" &
"<line x1='8' y1='74' x2='408' y2='74' stroke='#e2e8f0' stroke-width='1'/>" &
"<line x1='8' y1='107' x2='408' y2='107' stroke='#e2e8f0' stroke-width='1'/>" &
"<line x1='8' y1='140' x2='408' y2='140' stroke='#e2e8f0' stroke-width='1'/>" &
Concat(Sequence(_n),
"<rect x='" & Text(Int(8 + (Value - 1) * _slot + (_slot - _barW) / 2)) &
"' y='" & Text(Int(140 - Index(colBarChartData, Value).Value / _range * 132 * _ease)) &
"' width='" & Text(_barW) &
"' height='" & Text(Int(Index(colBarChartData, Value).Value / _range * 132 * _ease)) &
"' fill='" & If(varTooltipBarIdx = Value, "#2563eb", "#3b82f6") &
"' rx='4' ry='4'/>"
) &
Concat(Sequence(_n),
"<text x='" & Text(Int(8 + (Value - 0.5) * _slot)) &
"' y='163' text-anchor='middle' font-family='Arial,sans-serif' font-size='11' fill='#94a3b8'>" &
Left(Index(colBarChartData, Value).month, 3) & "</text>"
) &
"</svg>"
)
)
)
- galChartInteract:
Control: Gallery@2.15.0
Variant: Horizontal
Properties:
Fill: =RGBA(0, 0, 0, 0)
Height: =140
Items: =Sequence(CountRows(colBarChartData))
ShowScrollbar: =false
TemplatePadding: =0
TemplateSize: =416 / Max(1, CountRows(colBarChartData))
Width: =416
X: =12
Y: =83
Children:
- btnChartHit:
Control: Button@0.0.45
Properties:
Appearance: ='ButtonCanvas.Appearance'.Transparent
Height: =Parent.TemplateHeight
OnSelect: =If(varTooltipBarIdx = ThisItem.Value, Set(varTooltipBarIdx, 0), Set(varTooltipBarIdx, ThisItem.Value))
Text: =""
Width: =Parent.TemplateWidth
X: =0
Y: =0
- conTooltip:
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: =50
RadiusBottomLeft: =8
RadiusBottomRight: =8
RadiusTopLeft: =8
RadiusTopRight: =8
Visible: =varTooltipBarIdx > 0
Width: =110
X: =Max(8, Min(322, 20 + (varTooltipBarIdx - 0.5) * (400 / Max(1, CountRows(colBarChartData))) - 55))
Y: =Max(4, 162 - Index(colBarChartData, Max(1, varTooltipBarIdx)).Value / Max(1, Max(colBarChartData, Value)) * 132)
Children:
- lblTooltipMonth:
Control: Label@2.5.1
Properties:
Color: =RGBA(100, 116, 139, 1)
Font: =Font.'Open Sans'
Height: =18
Size: =10
Text: =If(varTooltipBarIdx > 0, Index(colBarChartData, varTooltipBarIdx).month, "")
Width: =100
X: =8
Y: =5
- imgTooltipDot:
Control: Image@2.2.3
Properties:
Fill: =RGBA(59, 130, 246, 1)
Height: =8
Image: =Blank()
RadiusBottomLeft: =4
RadiusBottomRight: =4
RadiusTopLeft: =4
RadiusTopRight: =4
Width: =3
X: =8
Y: =28
- lblTooltipValue:
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(varTooltipBarIdx > 0, Text(Index(colBarChartData, varTooltipBarIdx).Value), "")
Width: =90
X: =16
Y: =26
- rectFooterLine:
Control: Rectangle@2.3.0
Properties:
Fill: =RGBA(226, 232, 240, 1)
Height: =1
Width: =440
X: =0
Y: =259
- lblTrendText:
Control: Label@2.5.1
Properties:
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: =272
- lblDateRange:
Control: Label@2.5.1
Properties:
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: =296Implementation
Copies the customized component code directly to your clipboard. Use Ctrl+V in Power Apps Studio.
Something not pasting right? Troubleshooting guide