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

2,166

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

Share:
2,166
Pratik
Author by

Pratik

Updated on December 20, 2022

Comments

  • Pratik
    Pratik over 1 year

    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

  • darksoulsong
    darksoulsong over 3 years
    Is it possible to make the slices "grow" to the opposite direction, that is, to the center of the donut?