Accessible SVG charts for PHP, with typed models, layout, and themes.
Compare categories, show change, or display proportions with fourteen chart families. Builders turn your values into immutable models; the renderer produces SVG with accessible titles and data descriptions.
use Atelier\Chart\Chart;
echo Chart::render(Chart::bar()
->series('Revenue', ['Q1' => 18, 'Q2' => 27, 'Q3' => 24, 'Q4' => 35])
->build());Examples from the catalogue: grouped bars and line charts.
Atelier Layout calculates the plot geometry and Atelier SVG supplies the output document. Rendering runs in PHP without JavaScript, a browser, or an external binary. Each SVG contains one chart; its viewBox lets it scale to the space available.
Catalogue · Themes · SVG output · Errors · Gallery · Documentation
composer require atelier/chartRequires PHP 8.3+ and the atelier/layout and atelier/svg packages.
Composer installs the package dependencies.
<?php
declare(strict_types=1);
use Atelier\Chart\Chart;
require __DIR__.'/vendor/autoload.php';
$model = Chart::bar()
->title('Quarterly revenue')
->description('Revenue by quarter for 2025 and 2026, in millions.')
->series('2025', ['Q1' => 18, 'Q2' => 32, 'Q3' => 24, 'Q4' => 42])
->series('2026', ['Q1' => 26, 'Q2' => 24, 'Q3' => 38, 'Q4' => 35])
->build();
echo Chart::render($model);build() validates the data and returns an immutable model. Chart::render() returns its SVG
markup. The following snippets reuse this model, its imports, and the autoloader.
See Getting started for saving the result and choosing a chart family.
|
Bar charts |
Stacked bar charts |
Diverging bar charts |
|
Line charts |
Area charts |
Radar charts |
|
Pie charts |
Donut charts |
Scatter plots |
|
Bubble charts |
Gauges |
Sparklines |
|
Activity charts |
Strip charts |
Pass a theme when rendering, without rebuilding the model:
use Atelier\Chart\Theme\Theme;
echo Chart::render($model, Theme::warm());The presets are default, alto, dark, mono, and warm. A theme owns the palette,
background, text, axes, and grid colours. Derive one with with() or supply a custom theme;
see Themes.
Chart::renderDocument($model) returns an Atelier SVG document for further composition.
The default output includes accessibility information; CSS classes and data attributes are
optional:
use Atelier\Chart\Renderer\Svg\SvgRenderOptions;
echo Chart::render($model, options: new SvgRenderOptions(
classes: true,
dataAttributes: true,
));Enable these options when a stylesheet or script needs to address chart elements.
They also apply to Chart::renderDocument() and SvgRenderer.
Invalid or incompatible input throws Atelier\Chart\Exception\InvalidArgumentException.
All package exceptions implement Atelier\Chart\Exception\ExceptionInterface.
Required series counts, category order, and accepted value ranges depend on the chart family.
See Handle invalid input for a complete example and numeric precision when working with large integers or very small values.
From a repository checkout with dependencies installed:
php examples/generate.phpWrites examples/output/index.html with examples of the chart families and themes.
- Getting started: build, render, and save a first chart.
- Chart types: choose a family and explore illustrated variants.
- Series: organize categories, points, and composition data.
- Layout: control chart dimensions, axes, labels, and legends.
- Scales: understand default domains and set consistent scales across charts.
- Labels: format displayed values.
- Themes: use a preset or define the visual roles.
Read the complete guides and generated illustrations in docs/.
Contributions are welcome. Visit the project on GitHub to report a bug, suggest a feature, or open a pull request.
Before submitting code, run:
composer qa
composer coverageChanges to public behaviour need tests and a documentation update. Keep line coverage at 95% or higher. Coverage reporting requires PCOV or Xdebug.
Bug reports, security disclosures, and contribution guidelines are collected at ateliersvg.com/support.
Atelier Chart is released under the MIT License.