ReportLab Charts — Core Concepts
What ReportLab is
ReportLab is a Python library for creating PDF documents programmatically. It has been in production use since 2000, powering document generation at organizations from Wikipedia (donation receipts) to major financial institutions (account statements). The library has two layers: a low-level canvas API for precise drawing, and a high-level Platypus framework for flowing content (paragraphs, tables, images) across pages automatically.
The charting module, reportlab.graphics.charts, sits on top of the reportlab.graphics drawing framework and produces vector charts that render crisply at any zoom level inside the PDF.
Chart types available
ReportLab includes several built-in chart types:
- Vertical and horizontal bar charts — grouped or stacked
- Line charts — with optional markers and fill areas
- Pie charts — standard and exploded, with customizable labels
- Spider (radar) charts — for multi-axis comparisons
- Scatter plots — via the line chart with markers only
- Legends — standalone components that can be positioned anywhere
These cover the majority of business reporting needs. For specialized chart types (treemaps, Sankey diagrams), you would use the underlying drawing primitives.
Architecture: Drawing → Chart → Rendering
Charts in ReportLab are special shapes within a Drawing object — a canvas-independent container for vector graphics.
- Create a Drawing with width and height
- Create a chart (e.g.,
VerticalBarChart) and configure its properties - Add the chart to the drawing
- Render the drawing — either directly to a PDF canvas or as a Platypus Flowable that integrates into a document template
This separation means the same chart can appear in a standalone PDF, inside a multi-page report, or exported to SVG and bitmap formats.
Key configuration concepts
Data
Charts accept data as a list of data series. Each series is a tuple or list of numeric values:
data = [
(120, 85, 140, 95), # Series 1
(100, 110, 130, 80), # Series 2
]
Category axis vs value axis
- The category axis labels the groups (months, products, regions). It maps discrete labels to positions.
- The value axis shows numeric values. It auto-scales by default but can be manually configured with min, max, and step.
Styling
Every visual element is configurable: bar colors, line dash patterns, marker shapes, font sizes, grid lines, and label rotation. Styles are applied per-series or per-bar through a bars (or lines, slices) attribute collection.
Platypus integration
The power of ReportLab charts comes from embedding them alongside text and tables in Platypus documents. A chart is wrapped in a Drawing flowable and added to the story just like a paragraph:
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import VerticalBarChart
story = []
story.append(Paragraph("Quarterly Revenue", style))
drawing = Drawing(400, 200)
chart = VerticalBarChart()
# ... configure chart ...
drawing.add(chart)
story.append(drawing)
doc = SimpleDocTemplate("report.pdf")
doc.build(story)
Platypus handles page breaks, headers, footers, and flowing content around the chart automatically.
Common misconception
People often assume ReportLab charts look dated or “90s-style.” While the defaults are minimal, the styling system is highly configurable. With custom colors, fonts, rounded bars, and gradient fills, ReportLab charts can match modern design standards. The library prioritizes function over flashiness, but appearance is entirely in your hands.
How it compares
- Matplotlib → PDF — Matplotlib can export to PDF, but the result is a standalone image, not part of a flowing document layout. ReportLab integrates charts into paginated reports.
- WeasyPrint — HTML/CSS to PDF. Easier for web-style layouts but less control over chart rendering.
- FPDF2 — Simpler PDF library with no built-in charting.
- Plotly → static — Can export charts to images, which you then embed. ReportLab draws natively in PDF.
One thing to remember
ReportLab charts are vector graphics drawn directly into PDF pages, integrated with the same document framework that handles text, tables, and page layout — making it the go-to choice for automated, data-driven report generation in Python.
See Also
- Python Adaptive Learning Systems How Python builds learning apps that adjust to each student like a personal tutor who knows exactly what you need next.
- Python Airflow Learn Airflow as a timetable manager that makes sure data tasks run in the right order every day.
- Python Altair Learn Altair through the idea of drawing charts by describing rules, not by hand-placing every visual element.
- Python Automated Grading How Python grades homework and exams automatically, from simple answer keys to understanding written essays.
- Python Batch Vs Stream Processing Batch processing is like doing laundry once a week; stream processing is like a self-cleaning shirt that cleans itself constantly.