Pie Chart
How to use
PieChart(
PieChartData(
// read about it in the PieChartData section
),
duration: Duration(milliseconds: 150), // Optional
curve: Curves.linear, // Optional
);
If you have a padding widget around the PieChart, make sure to set PieChartData.centerSpaceRadius to double.infinity
Implicit Animations
When you change the chart's state, it animates to the new state internally (using implicit animations). You can control the animation duration and curve using optional duration and curve properties, respectively.
PieChartData
Radius of free space in center of the circle.
If it's not finite (like double.infinity), it is calculated from the
size of the chart.
Color of free space in center of the circle.
Defines gap between sections.
Does not work on html-renderer, https://github.com/imaNNeo/fl_chart/issues/955
PieChart draws sections from zero degree (right side of the circle) clockwise.
Handles touch behaviors and responses.
Holds data to draw the border around the chart, see FlBorderData.
Whether to rotate the titles on each section of the chart
PieChartSectionData
It determines how much space it should occupy around the circle.
This is depends on sum of all sections, each section should
occupy (value / sumValues) * 360 degrees.
value can not be null.
Defines the color of section.
Defines the gradient of section. If specified, overrides the color setting.
Defines the radius of section.
Defines show or hide the title of section.
Defines style of showing title of section, merged with the text style of the theme.
Defines text of showing title at the middle of section.
Defaults to the value of the section, if it is provided.
Defines border stroke around the section
Defines corner radius for rounded edges (applies to all corners)
Defines a widget that represents the section.
This can be anything from a text, an image, an animation, and even a combination of widgets. Use AnimatedWidgets to animate this widget.
Defines position of showing title in the section.
It should be between 0.0 to 1.0,
0.0 means near the center,
1.0 means near the outside of the PieChart.
Defines position of badge widget in the section.
It should be between 0.0 to 1.0,
0.0 means near the center,
1.0 means near the outside of the PieChart.
Stacked segments rendered on top of the main section.
Each segment defines PieChartStackSegmentData.fromRadius and
PieChartStackSegmentData.toRadius to specify its position within
the section's radius. Values are clamped to [0, radius] at render time.
PieChartStackSegmentData
The start radius of this segment (distance from center of the section).
Clamped to [0, sectionRadius] at render time.
The end radius of this segment (distance from center of the section).
Clamped to [0, sectionRadius] at render time.
Defines the color of segment.
Defines the gradient of segment. If specified, overrides the color setting.
PieTouchData (read about touch handling)
Determines whether to enable or disable touch behaviors.
touchCallback notifies you about the happened touch/pointer events.
It gives you a FlTouchEvent which is the happened event such as FlPointerHoverEvent, FlTapUpEvent, ...
It also gives you a BaseTouchResponse which is the chart specific type and contains information
about the elements that has touched.
Using mouseCursorResolver you can change the mouse cursor
based on the provided FlTouchEvent and BaseTouchResponse
This property that allows to customize the duration of the longPress gesture. If null, it uses kLongPressTimeout (500 milliseconds).
PieTouchResponse
The location of the touch in pixels on the screen.
Contains information about touched section, like index, angle, radius, ...
PieTouchedSection
The touched section, null if no section is touched.
The index of touchedSection in PieChartData.sections, -1 if no
section is touched.
some samples
Sample 1 (Source Code)
Sample 2 (Source Code)
Sample 3 (Source Code)
