Pie & Donut Chart
In depth guide to the PieChart Widget.
A Pie Chart represents the numeric data as a section or pie of an entire circle. The total of all values in the data set is the entire angle of the circle i.e. 360°.
An alternative version of the Pie Chart representation is a Donut Chart, where an inner area of removed from the Pie Chart, resulting into a Donut of numeric sections.
To draw a Pie Chart, we will use the PieChart
widget.
Let's use the widget to draw a simple pie chart with two pie pieces.
Before moving forward, let's understand the above example code.
The widget PieChart
requires a mandatory field data
of type PieSeries
. This is a series class that ensures that any data provided to this series will be represented as a Pie or Donut Chart.
The PieSeries
requires slices
which is a List of SliceData
. Each SliceData represents a Pie piece of the entire circle. The total of all the value
in the slices will the total area of the circle.
We can use the same Widget to convert a PieChart into a DonutChart! Let's convert the above example into a Donut Chart.
Now we have converted our existing PieChart example into a Donut Chart! Sweet.
Last updated