Overview
PhpSpreadsheet provides comprehensive charting capabilities. You can create various chart types, customize their appearance, and embed them in your Excel files. Charts are defined using data series, labels, and plot areas.Basic Chart Components
Every chart in PhpSpreadsheet consists of:- Data Series Values: The actual data to plot
- Data Series Labels: Labels for each data series (legend)
- X-Axis Tick Values: Category labels for the X-axis
- Plot Area: Container for the data series
- Legend: Chart legend
- Title: Chart title
Line Chart
Create a basic line chart showing data over time:Column Chart
Create a vertical column chart (bar chart with vertical orientation):Pie Chart
Create a pie chart to show proportions:Donut Chart
Similar to a pie chart but with a hole in the center:Customizing Chart Appearance
Chart Types
Available chart types:DataSeries::TYPE_LINECHART- Line chartsDataSeries::TYPE_BARCHART- Bar/Column chartsDataSeries::TYPE_PIECHART- Pie chartsDataSeries::TYPE_DONUTCHART- Donut chartsDataSeries::TYPE_AREACHART- Area chartsDataSeries::TYPE_SCATTERCHART- Scatter (XY) chartsDataSeries::TYPE_RADARCHART- Radar chartsDataSeries::TYPE_BUBBLECHART- Bubble chartsDataSeries::TYPE_STOCKCHART- Stock charts
Legend Positions
Handling Empty Values
Custom Colors
You can set custom colors for data series:Multiple Charts on One Sheet
You can add multiple charts to a single worksheet by positioning them differently:Saving Charts
Charts are only supported in Xlsx format:Reading Existing Charts
You can read charts from existing Excel files:Rendering Charts as Images
With appropriate libraries installed, you can render charts as images:Chart rendering requires additional PHP extensions like GD or Imagick, and may require JpGraph for some chart types.
Expected Output
When you open the generated Excel file:- Line charts will show trends over time with multiple series
- Column charts display vertical bars grouped by category
- Pie charts show proportional slices with optional percentages
- Charts are interactive in Excel with hover tooltips
- Legend entries correspond to data series labels

