React Native Animated Donut Chart with React Native SVG and Animated API
42,856
Published 2020-09-02
The React Native Donut Chart component consist in:
- building up the donut chart using React Native SVG (Circle and G)
- how Stroke DashArray and Stroke DashOffset works and animate them
- how to animate a number in React Native based on Animation value or Animated value.
Snack (Source code): snack.expo.io/@catalinmiron/advanced-donut-animatiβ¦
πJoin Discord: discord.gg/vg7hUDU.
πππ More react native animations: www.animatereactnative.com/ πππ
Want to support me?
- Patreon: patreon.com/catalinmiron
- BuyMeACoffee: www.buymeacoffee.com/catalinmiron
- Paypal: paypal.me/catalinmiron
You can find me on:
- Github: github.com/catalinmiron
- Twitter: twitter.com/mironcatalin
- Website: batman.codes/
Timeline:
- 00:00 Intro
- 01:13 VSCode
- 01:54 Create the Donut Chart with React Native SVG
- 04:10 How StrokeDashArray and StrokeDashOffset work
- 07:47 Calculate StrokeDashOffset based on percentage
- 11:45 Animate Donut Chart component
- 14:02 Initial React Native Donut Chart animation
- 14:50 Use TextInput for Percentage number
- 16:35 Animate TextInput value
- 17:40 Final Donut Chart animation presentation
- 17:49 Show how reusable Donut Chart work
- 19:25 Final words
#reactnative #animated #donutchart #react-native-svg #react-native-chart #gauge
All Comments (21)
-
This man is really sharing good practices for react-native because many of us focus on functionality but not in good UI. Guys, please support him may be he will teach us awesome parts of react-native. Love from INDIA.
-
I came here searching for a way to animate a number text input and ended up solving 2 problems in my app. Amazing tutorial man! Keep it up ;) !
-
From Benin (Africa) I follow you. Watch your Conf and your animation tutoral. You're just amazing.
-
amazing content!!! addicted to your tutorials!!!
-
Mersi mult Catalin. Am incercat 1000 de metode si in final tot un roman m-a ajutat sa rezolv :)
-
Small note: React native recommends against setNativeProps nowadays. So instead, just make a strokeDashoffset variable with useState, then pass that into the circle. animatedValue.addListener((v) => { if (circleRef?.current) { const maxPerc = (100 * v.value) / max; const strokeDashOffset = circleCircumference - (circleCircumference * maxPerc) / 100; setStrokeDashoffset(strokeDashOffset); // I no longer use this below code // circleRef.current.setNativeProps({ // strokeDashOffset, // }); } }); Thank you so much for this!
-
Great work Catalin, Very well explained.
-
Amazing video, as always... Thanks for sharing!!
-
Nice tutorial I like it. Thanks. You are one of the best react native teachers on youtube. π
-
Awesome as always!
-
So good man, thanks for this!
-
Nice!!! Thanks for posting these videos!
-
Thank you so much, Catalin.
-
Thanks a lot, man. This is awesome.
-
Thanks man, this tutorial helped alot..
-
Thank you very much for sharing!
-
Awesome tutorial buddy!
-
Thanks a lot Catalin...Love from Canada.
-
Really Really Really Really APPRECIATED!!
-
Awesome content as always! Any coming tuts on pan gesture handle like pinch to zoom or tinder swipes ?