React Native Animated Donut Chart with React Native SVG and Animated API

42,856
0
Published 2020-09-02
In this video tutorial you'll learn how to create an animated donut chart component in React Native using React Native Animated API and React Native SVG.

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)
  • @hypersudo8092
    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.
  • @BLUEOVI
    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.
  • 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!
  • Nice tutorial I like it. Thanks. You are one of the best react native teachers on youtube. πŸ™
  • @sidhant500
    Thanks a lot Catalin...Love from Canada.
  • @migom6
    Awesome content as always! Any coming tuts on pan gesture handle like pinch to zoom or tinder swipes ?