Locked lesson.
About this lesson
In this lesson, we'll look at how to add Doughnut Charts.
Exercise files
Download this lesson’s related exercise files.
34 - Doughnut Charts.docx57.3 KB 34 - Doughnut Charts SOLUTION.docx.docx
58.5 KB
Quick reference
Doughnut Charts
In this video we'll look at Doughnut Charts.
When to use
Use this whenever you need to use a Doughnut chart in your spreadsheet.
Instructions
# Import the charts
from openpyxl.chart import Reference, Series, DoughnutChart
from openpyxl.chart.series import DataPoint
# Create a Chart instance
chart = Doughnut()
# Cut out a slice of data
slices = [DataPoint(idx=i) for i in range(5)]
# Define our Slices
chocolate, vanilla, strawberry, blueberry, raspberry = slices
# Chart a Series
chart.series[0].data_points = slices
# Pull out our slice/wedge
chocolate.explosion = 10
Hints & tips
- from openpyxl.chart import Reference, Series, DoughnutChart
- from openpyxl.chart.series import DataPoint
- slices = [DataPoint(idx=i) for i in range(5)]
- chocolate, vanilla, strawberry, blueberry, raspberry = slices
- chart.series[0].data_points = slices
- chocolate.explosion = 10
Lesson notes are only available for subscribers.