Build Your own Pie Chart with Jetpack Compose in Android - Android Studio Tutorial | Canvas

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 30

  • @SiamakAshrafi
    @SiamakAshrafi 2 года назад +1

    R U kidding me. This is amazing. You should have 70K subscribers not 70 ...
    Just wrote a medium article explaining how we are using this in our sleep tacking app. Linking back to your video to help promote the channel.

  • @sandrastojanovic1849
    @sandrastojanovic1849 Год назад

    Congratulations, this is awesome! I watched the other video with Circular Progress Indicator, and it is awesome as well! Thank you for sharing this!
    Have you tried to combined those two, drag gestures with Pie Chart, where you can drag every piece of Pie Chart in order to change the percentage of each part manually?

  • @KashyapChandraPratap
    @KashyapChandraPratap 4 месяца назад

    keep doing man...that's really good

  • @SurayyoUZB
    @SurayyoUZB Год назад

    Thank you for this video. This video is so good and great. This video really helps me to create Pie Chart in compose. I recommend you to watch it

  • @murderousgod-pubglite4262
    @murderousgod-pubglite4262 2 года назад +1

    Woaah you really did it, Thanks that was amazing.

  • @ramakanaparthy1953
    @ramakanaparthy1953 Год назад

    This is great, l have to create something similar to this.

  • @mesutemrecelenk5447
    @mesutemrecelenk5447 Год назад +1

    Thanks a lot bro.

  • @ramakanaparthy1953
    @ramakanaparthy1953 Год назад

    How to add the selected part to the outside with the same width and colour should be transparent to selected part?

  • @jumps63
    @jumps63 Год назад

    Hi, How can I know what is height of this composable in db? If I remove fillMaxSize() property from Canvas and place PieChart between two composables it will overlap eachother. Do you have any tips for that?

    • @kapps7407
      @kapps7407  Год назад

      You should always pass a modifier to the canvas which defines the height. You can also pass a relative height or if you want a fixed one. The exact dp can then be accessed inside the Canvas with the size property. If you need this height outside of your Canvas you can pass a lambda function and pass the height in there and collect the value from the outside

    • @jumps63
      @jumps63 Год назад

      @@kapps7407 I need exact dp outside of canvas composable. I know i can access size value, but that gives value in float value, not in dp if I am correct?

    • @kapps7407
      @kapps7407  Год назад +1

      You can convert this float value which are actually pixels to dp then :)

  • @hanadanefa7837
    @hanadanefa7837 Год назад

    may I know your device your currently using?
    I mean what specs your device have

    • @kapps7407
      @kapps7407  Год назад

      This emulator is a Google Pixel 4XL if I remember correctly

    • @hanadanefa7837
      @hanadanefa7837 Год назад

      @@kapps7407 I mean your laptop or pc that you use for development :)

    • @kapps7407
      @kapps7407  Год назад

      Oh okay - It is a 27 inch iMac 2020 with an i7 processor and 64gb RAM

    • @hanadanefa7837
      @hanadanefa7837 Год назад

      Thank you

  • @ramakanaparthy1953
    @ramakanaparthy1953 Год назад

    Source code please

  • @cinemovieone
    @cinemovieone 2 года назад

    First of all my congratulations and thanks, you are really good at what you do.
    I was trying to feed this graph with the Room database but I get an error on the line "if (inputList.first().isTapped)"
    I'm racking my brain to solve it rsrs

    • @kapps7407
      @kapps7407  2 года назад +1

      Hello Daniel, thank you! What error do you get? Maybe the input list is empty so there is no first element and you are trying to access it. If Room takes some amount of time and your list is empty at the beginning when you invoke the composable the first time this could happen. But to give you an exact hint I need more information.

    • @cinemovieone
      @cinemovieone 2 года назад

      @@kapps7407 that's exactly it, the first time compose draws the screen, the list is empty and the "isTapped" property is false, where the error happens.
      I used "firstOrNull" or instead of just "first", but even so, the layout doesn't recompose and doesn't fetch the data in the database, and it doesn't feed the graph.
      I'm trying to see what I can do, but still nothing =/

    • @kapps7407
      @kapps7407  2 года назад

      You should make your input list state which then triggers the recomposition (For example in a view model). Then when the Room result is there you can map the result to the InputList and update your list. This should trigger the recomposition. For the first case when the list is empty by default you could for example make an if statement inside the chart composable and show the chart when list.size>0 and otherwise show a placeholder text with "Currently no data available" or something like this.

    • @cinemovieone
      @cinemovieone 2 года назад

      @@kapps7407 Yes, I'm using the viewModel, and I even check it. I have a state class that contains " val isEmpty: Boolean", when collecting the list I check if it is empty and depending on the condition, true or false, I assign it to this property. I can't understand why compose doesn't recompose itself. I made an if in the "inputList" if it is greater than 0 or not, and I put a text if it is less, saying that there is no data, however, it stays there, it doesn't recompose itself, I'm almost there, I just need to know why it it is not recovering.

    • @kapps7407
      @kapps7407  2 года назад

      How does your state list (The list For the Piechart) look and how do you update it when there is a Room result? I am pretty sure there is just a little problem with updating the state properly.