PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, April 23, 2022

[FIXED] How can we draw pie chart with different radius in flutter?

 April 23, 2022     charts, dart, flutter, mobile, pie-chart     No comments   

Issue

In flutter, I am trying to implement a pie chart with different radius in each slice as shown in figure below? I searched and tried different plugins in pub.dev, but didn't find any plugin with my requirements. How can I do this in flutter? Thank you.

enter image description here


Solution

The lib fl_chart can help you.

https://pub.dev/packages/fl_chart

The use is very simple, you can pass the radius value in PieChartSectionData, which can be the same of the value or you can configure for other purpose:

PieChart(
PieChartData(centerSpaceRadius: 30, sections: [
PieChartSectionData(
    color: const Color(0xff0293ee),
    value: 40,
    title: '40%',
    radius: 40,
    titleStyle: TextStyle(
        fontSize: 12,
        fontWeight: FontWeight.bold,
        color: const Color(0xffffffff)),
),
PieChartSectionData(
    color: const Color(0xfff8b250),
    value: 30,
    title: '30%',
    radius: 30,
    titleStyle: TextStyle(
        fontSize: 14,
        fontWeight: FontWeight.bold,
        color: const Color(0xffffffff)),
)
]))

Pie Chart with different radius values result:

Pie Chart with different radius values



Answered By - Murilo Erhardt
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing