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

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • 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/a...
    👉Join Discord: / discord .
    👉👉👉 More react native animations: www.animatereactnative.com/ 👈👈👈
    Want to support me?
    - Patreon: / catalinmiron
    - BuyMeACoffee: www.buymeacoffee.com/catalinm...
    - Paypal: paypal.me/catalinmiron
    You can find me on:
    - Github: github.com/catalinmiron
    - Twitter: / 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-chart

ความคิดเห็น • 120

  • @hypersudo8092
    @hypersudo8092 3 ปีที่แล้ว +47

    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.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +7

      I can’t describe how happy I am that I can share my knowledge with you. Thank you so much for showing your support and kind words I truly appreciate it. Thanks Harshvardhan ✌️

  • @BLUEOVI
    @BLUEOVI 3 ปีที่แล้ว +2

    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 ;) !

  • @tawalioualao7444
    @tawalioualao7444 3 ปีที่แล้ว

    From Benin (Africa) I follow you. Watch your Conf and your animation tutoral. You're just amazing.

  • @chamaldezilva
    @chamaldezilva 3 ปีที่แล้ว

    amazing content!!! addicted to your tutorials!!!

  • @octaviansirbu1192
    @octaviansirbu1192 3 ปีที่แล้ว

    Mersi mult Catalin. Am incercat 1000 de metode si in final tot un roman m-a ajutat sa rezolv :)

  • @xdankitjain
    @xdankitjain 3 ปีที่แล้ว

    Great work Catalin, Very well explained.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thank you Ankit, I’m glad you like it. Thanks ✌️

  • @marianareissilveira
    @marianareissilveira 2 ปีที่แล้ว

    Amazing video, as always... Thanks for sharing!!

  • @leonelkahameni5315
    @leonelkahameni5315 3 ปีที่แล้ว

    Nice tutorial I like it. Thanks. You are one of the best react native teachers on youtube. 🙏

  • @justanotherguy8121
    @justanotherguy8121 ปีที่แล้ว +4

    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!

  • @tininottiny8685
    @tininottiny8685 3 ปีที่แล้ว

    So good man, thanks for this!

  • @enio.carlos
    @enio.carlos ปีที่แล้ว

    Thank you so much, Catalin.

  • @youssefmuhamad3213
    @youssefmuhamad3213 3 ปีที่แล้ว +1

    Awesome as always!

  • @totaltotal157
    @totaltotal157 3 ปีที่แล้ว

    Nice!!! Thanks for posting these videos!

  • @juliendevleeschauwer8226
    @juliendevleeschauwer8226 3 ปีที่แล้ว

    Thanks a lot, man. This is awesome.

  • @ayushKumar-9835
    @ayushKumar-9835 ปีที่แล้ว

    Thanks man, this tutorial helped alot..

  • @eduardopelitti7799
    @eduardopelitti7799 2 ปีที่แล้ว

    Thank you very much for sharing!

  • @sidhant500
    @sidhant500 3 ปีที่แล้ว

    Thanks a lot Catalin...Love from Canada.

  • @devina1957
    @devina1957 3 ปีที่แล้ว

    thank you, very helpful

  • @geekthegeek730
    @geekthegeek730 3 ปีที่แล้ว

    Awesome tutorial buddy!

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thanks a lot ✌️I’m glad that you liked it 👍

  • @bilelrahmouni01
    @bilelrahmouni01 2 ปีที่แล้ว

    Thank you

  • @user-zu6rm3js4d
    @user-zu6rm3js4d 3 ปีที่แล้ว

    Really Really Really Really APPRECIATED!!

  • @rahulraina711
    @rahulraina711 2 ปีที่แล้ว

    You are a saviour

  • @bilelrahmouni01
    @bilelrahmouni01 2 ปีที่แล้ว

    thank you

  • @rockNbrain
    @rockNbrain 2 ปีที่แล้ว

    Nice job bro

  • @migom6
    @migom6 3 ปีที่แล้ว +1

    Awesome content as always! Any coming tuts on pan gesture handle like pinch to zoom or tinder swipes ?

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Great suggestion! I'll consider creating a tinder like app in the upcoming videos. Thanks Madhurjya! ✌️

  • @godwinebikwo6544
    @godwinebikwo6544 3 ปีที่แล้ว

    Great video, and explanation

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Glad you liked it and thank you Godwin ✌️

  • @SamuelBotelho
    @SamuelBotelho 3 ปีที่แล้ว

    awesome, keep it up!

  • @lailabouziani7704
    @lailabouziani7704 3 ปีที่แล้ว

    thanx, very helpful

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      You’re welcome Laila, I’m glad that you found it useful. ✌️

  • @khalidkhan5308
    @khalidkhan5308 3 ปีที่แล้ว

    Wow amazing 😍

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thank you Khalid, I’m glad you found it useful ✌️

  • @charfeddinehajlaoui4572
    @charfeddinehajlaoui4572 3 ปีที่แล้ว +1

    Well done sir you have a great videos in this channel ... my question is how to fix the value and not let it change like in the tutorial .. for example i want to display the balance of holiday or the days left in a holiday.. and thanx

  • @emilsvensson7212
    @emilsvensson7212 2 ปีที่แล้ว

    This video really helped me with the project I am doing! Wanted to get you a coffee for the help but the link does not work - so I guess I need a tutorial for buying coffee next…

  • @edgardoalvarez980
    @edgardoalvarez980 3 ปีที่แล้ว +3

    How did you learn to do all of this? It's amazing!

  • @nishadpatil9886
    @nishadpatil9886 3 ปีที่แล้ว

    Really great video ..

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Thanks Nishad, I’m glad it helped you ✌️

  • @johanagamez450
    @johanagamez450 3 ปีที่แล้ว

    Amazing video!
    Can I put the donuts one inside the other?

  • @richardkirigaya8254
    @richardkirigaya8254 3 ปีที่แล้ว

    Hi Catalin, lovely vid, really enjoyed it, how i can make sure the donut doesn't animate past 100% but remains there at 100%

  • @nadeemkhan-yu4wf
    @nadeemkhan-yu4wf 3 ปีที่แล้ว

    its very nice.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Thanks Nadeem I’m glad you like it ✌️

  • @syedmoamberraza1490
    @syedmoamberraza1490 3 ปีที่แล้ว

    i have tried many time but won't get success, the actual thing is to explain in a proper general manners, which he knows very well. Great Work
    LOVE From PAKISTAN.

  • @senixcode5601
    @senixcode5601 3 ปีที่แล้ว

    cool

  • @iaxelrad
    @iaxelrad 3 ปีที่แล้ว +1

    Amazing! That's just what i was looking for. What type of adjustments would you recommend to do if I wanted to add a kind of gradient to the color ?

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +2

      Thanks Itamar. For gradients I recomment using Def + gradient svg and apply the gradient as fill for the path. Fill=“url(#grad)” ✌️

    • @iaxelrad
      @iaxelrad 3 ปีที่แล้ว

      @@CatalinMironDev thanks! I'll give it a go :)

  • @richardsonlyon8108
    @richardsonlyon8108 2 ปีที่แล้ว

    Hi, thanks for the great tutorial, but I seem to be having some problems. I seem to be getting an error message: Animated node with tag 23 does not exist, please help if you can.

  • @legcsabi
    @legcsabi 2 ปีที่แล้ว +1

    Fixes for the web:
    - originX={halfCircle} and originY={halfCircle} instead of origin={`${halfCircle}, ${halfCircle}`}
    - circleRef.current.setNativeProps is undefined, use a state to store the calculated strokeDashoffset
    - add [] as dependency to React.useEffect to prevent additional calls

  • @fouadchahd2969
    @fouadchahd2969 2 ปีที่แล้ว

    thank you sir for this amazing video but how to stop the donut from refreshing it self?

  • @anthonyamponsah1693
    @anthonyamponsah1693 2 ปีที่แล้ว +1

    Great tutorials Miron. I have a minor issue. I have followed the tutorials but there is a problem. The component does not animate on mount unless I bind the animated value to a view and later remove it from the view then it animates. What could be the issue?

  • @vietcuong7972
    @vietcuong7972 2 ปีที่แล้ว

    Can someone help me why the cicle ring is not full width and height of the view outside?

  • @appforeseen6298
    @appforeseen6298 3 ปีที่แล้ว

    I tried setting animatedValue to strokeDashoffset directly. It look like: strokeDashoffset={animatedValue}.
    But why it can't animate to final value or the round still there(strokeLinecap="round")? And your way the round will disappear!

  • @3366ashish
    @3366ashish 2 ปีที่แล้ว

    Can you please create demo on how to animate polygon as well. Couldn't find lot of assets for it.

  • @remixedOne
    @remixedOne 2 ปีที่แล้ว

    I miss his videos a lot, He lately not uploading. Hope you are doing good and will get back to youtube soon

  • @tknumber12
    @tknumber12 3 ปีที่แล้ว

    @Catalin Miron, thanks for the great video. It was very helpful. I have a question. I have used some animated svgs just as you have shown, but now my scrollview won't work unless my finger touches an animation. Outside of the animation (donut svgs) a touch event on the screen does not work and the screen won't scroll. Any tips? Thanks

    • @tknumber12
      @tknumber12 3 ปีที่แล้ว

      Never mind, It is because I was wrapping my screen in a touchableWithoutFeedback

  • @bloggerklik
    @bloggerklik 3 ปีที่แล้ว

    Hi, I want to add an svg icon above the bar chart. How can I do that?

  • @karthikbalasubramanian5122
    @karthikbalasubramanian5122 2 ปีที่แล้ว

    Hey thanks for a Great Video. One doubt though, Will this work in the React Native Web or a Web Storybook? Can anyone help me out here.

  • @krtgaming8253
    @krtgaming8253 ปีที่แล้ว

    Any idea for setting rotation to 135 degree? The origin is not correct.

  • @itsmejorday4426
    @itsmejorday4426 3 ปีที่แล้ว

    what theme did you use? the color really smooth, like it.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      My VSCode theme is Palenight and font family is Operator Mono. Thanks Jorday! ✌️

  • @sumanparajuli229
    @sumanparajuli229 3 ปีที่แล้ว +1

    Sir, i am grateful that i got your channel. Sir can you create a fully functional react native app using react native CLI with good UI, good animation and backend and finally publish to google play store.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      I plan on doing it after I'll finish the 10 Video series for Shared Element transitions in React Native. Thanks for the suggestion Suman ✌️

  • @nileshsingh7253
    @nileshsingh7253 2 ปีที่แล้ว

    Hello Sir please make video on react d3 gauge with needle which show value.

  • @harshdeepsaiyam570
    @harshdeepsaiyam570 3 ปีที่แล้ว

    how to move it anti clock wise?

  • @Dmitri_Ivanovich
    @Dmitri_Ivanovich 3 ปีที่แล้ว +4

    I don't think "percentage" means what you think it means. Other than that - great tutorial. Thanks!

  • @NaveenKumar-fo4kz
    @NaveenKumar-fo4kz 3 ปีที่แล้ว +1

    Please make a video about firebase using expo and hooks

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      I’ll start a series about firebase really soon. Thanks for the great suggestion Naveen ✌️

  • @QueenA7
    @QueenA7 3 ปีที่แล้ว

    This was a really helpful video. Thank you! I am having issues with it showing up properly on Android, though. It will show the circles properly when they are unanimated, but as soon as I animate them, it only shows circle one and never shows the animation. Any advice on what I can check to get this working?

    • @QueenA7
      @QueenA7 3 ปีที่แล้ว

      Never mind... I added useNativeDriver = {false} for android, and that seemed to fix it. Thanks for the great video!

    • @edgardoalvarez980
      @edgardoalvarez980 3 ปีที่แล้ว +1

      @@QueenA7 had the same issue, and came here to find the answer. Thank you so much for this!

    • @QueenA7
      @QueenA7 3 ปีที่แล้ว

      @@edgardoalvarez980 Glad it helped!

  • @utkarsh223
    @utkarsh223 2 ปีที่แล้ว +1

    HOW CAN I STOP THE ANIMATION ONCE IT REACHES THE MAX??
    PLEASE HELP

  • @anasalamin9164
    @anasalamin9164 3 ปีที่แล้ว

    Can you please make more content about graphs... There's a huge shortage in this context of RN

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Anas Alamin right now I have a 10 video series about shared element transition, most probably after it I’ll tackle this subject. Thanks Anas ✌️

  • @ahmadsopandi100
    @ahmadsopandi100 3 ปีที่แล้ว +1

    sorry sir, after i try yor tutorial, the animation is not working on android device

  • @umaralfaruq1304
    @umaralfaruq1304 2 ปีที่แล้ว +1

    what is the name of the font

  • @AbdulRehmanSiddiquii
    @AbdulRehmanSiddiquii 3 ปีที่แล้ว

    Bro i also need know how i can show also number at the end of the bar ???

    • @muhamadimron9785
      @muhamadimron9785 3 ปีที่แล้ว

      try to Change the initial value of percentage same as max value or extract the max value then show it
      _data.map(t => ( {t.max} ))_

    • @AbdulRehmanSiddiquii
      @AbdulRehmanSiddiquii 3 ปีที่แล้ว

      @@muhamadimron9785 dont get it where i have to add this can add this and push in the source ?

  • @muhammadmuzammil7592
    @muhammadmuzammil7592 2 ปีที่แล้ว

    please also make pie chart in expo

  • @toel_
    @toel_ 3 ปีที่แล้ว

    Hey, I really like your videos and want to know whether you have a course or something
    Amazing work btw

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      I’m working on Reanimated2 course (zero to hero) which I plan to release by the end of this month-mid of October. If you’d like to get a little discount there you can become a Patreon: patreon.com/catalinmiron (there are other benefits, including access to a private repository where I’m pushing code mostly on a daily basis). Thanks you so mich for your support Apiut ✌️

    • @toel_
      @toel_ 3 ปีที่แล้ว

      @@CatalinMironDev Nice, but I dont think reanimated2 works on expo sdk 38. Either way, can't wait to be part of your "students"

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว +1

      Apiut Toel you are right and that also bothers me:( there’s work in progress for expo which I wish to happen asap). Thanks and no problem about not becoming a student yet. ✌️

    • @toel_
      @toel_ 3 ปีที่แล้ว

      @@CatalinMironDev I meant I'll be your student irregardless because i have been having issues with reanimated v1 its complex in a way to beginners

  • @doniaelfouly4142
    @doniaelfouly4142 2 ปีที่แล้ว

    the code on snack is broken

  • @saishkalbag7103
    @saishkalbag7103 ปีที่แล้ว

    Your snack code is not animating and pasting it in my react native code didn't start the animation

  • @fernandorojo6311
    @fernandorojo6311 2 ปีที่แล้ว

    Has anyone implemented this with Reanimated 2 by chance?

    • @CatalinMironDev
      @CatalinMironDev  2 ปีที่แล้ว

      Yes, I did:) its on my Patreon. Its the same thing with Animated API you only need to useAnimatedProps

  • @zameer-haider
    @zameer-haider 3 ปีที่แล้ว

    🍎😍

  • @rp1283
    @rp1283 3 ปีที่แล้ว

    useNativeDriver is only working in expo but not in react native

  • @naishe
    @naishe 3 ปีที่แล้ว

    Not a moment ago I installed and used this library: github.com/vydimitrov/react-countdown-circle-timer and here is your video. Pleasantly surprised. Love your videos.

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      This looks amazing Nishant, I didn’t knew about it. Thanks for sharing it with us. ✌️

    • @naishe
      @naishe 3 ปีที่แล้ว

      @@CatalinMironDev yeah, I was wondering how it was done, and bam! your tutorial. Thanks for the videos. Keep them coming. I like them a lot.

  • @israel333666
    @israel333666 3 ปีที่แล้ว

    can you to make delivery app please with react native

  • @dannylamtoro8447
    @dannylamtoro8447 3 ปีที่แล้ว

    🇮🇩 Indonesia

  • @CreativeJE
    @CreativeJE 3 ปีที่แล้ว

    thanks for your tutorials but if you will explain a little more about everything which you do will help beginners understand better whats going

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      I will try my best. Can you also share some feedback? I'd like to be better at explaining stuff. Thanks!

    • @CreativeJE
      @CreativeJE 3 ปีที่แล้ว

      @@CatalinMironDev like where you used the new Nullish coalescing operator (??) and also in the if statement.
      Also if you can tell why and how animations are working like why you used text input instead of normal text.
      I know video will be longer but I am sure it will give us a deep understanding of all of your codes.
      Thanks again 🙏🎉

  • @jurianboots395
    @jurianboots395 3 ปีที่แล้ว

    Hey man, thank you for this very clear tutorial :) However it doesn't seem to work on Android, is that right?

  • @axelbryancasauran5159
    @axelbryancasauran5159 2 ปีที่แล้ว

    the source code is not working even updated the version and dependency...

    • @axelbryancasauran5159
      @axelbryancasauran5159 2 ปีที่แล้ว

      i take it back it works.. question: is it possible to loop the animation? like it is circling around?

  • @guleye
    @guleye 3 ปีที่แล้ว

    Sir you didn’t add github source code

    • @CatalinMironDev
      @CatalinMironDev  3 ปีที่แล้ว

      Added the snack for it. Thanks Murph ✌️

  • @Anas_Alaqeel
    @Anas_Alaqeel 3 ปีที่แล้ว

    This guy is good and know what he doing, but if we talk about how he teaching or explaining things, well, explaining is bad, so only people who will understand him who those have already experience in what he doing

  • @pasteancalin7826
    @pasteancalin7826 ปีที่แล้ว

    The circle (stroke) looks jagged on Android