PHPackages                             maantje/charts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maantje/charts

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maantje/charts
==============

SVG Charts in PHP

v0.9.0(2mo ago)32694.4k—3.3%14[1 issues](https://github.com/maantje/charts/issues)2MITPHPCI passing

Since Sep 4Pushed 2mo ago9 watchersCompare

[ Source](https://github.com/maantje/charts)[ Packagist](https://packagist.org/packages/maantje/charts)[ GitHub Sponsors](https://github.com/maantje)[ RSS](/packages/maantje-charts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (16)Used By (2)

Charts - SVG Chart Rendering
============================

[](#charts---svg-chart-rendering)

**Charts** is a zero-dependency PHP library for generating SVG charts. It enables easy creation of SVG-based charts directly from PHP, with no additional dependencies required.

Features
--------

[](#features)

- Simple, intuitive API for chart creation
- Lightweight, with no external dependencies
- Supports various chart types: line charts, bar charts, stacked charts, and mixed charts
- Fully customizable and extendable
- Outputs pure SVG, allowing for:
    - Embedding in PDFs, [view example PDF report](https://raw.githubusercontent.com/maantje/charts/refs/heads/main/examples/output/report.pdf)

Installation
------------

[](#installation)

To get started, install the package via composer:

```
composer require maantje/charts
```

Usage Examples
--------------

[](#usage-examples)

Below are some examples of the types of charts you can create using this library. Click on the links to view the source code for each example.

- [Example Usage With mPDF](#example-usage-with-mpdf)
- [Simple Line Chart](#simple-line-chart)
- [Curved Line Chart](#curved-line-chart)
- [Step Line Chart](#step-line-chart)
- [Area Line Chart](#area-line-chart)
- [Bar Chart](#bar-chart)
- [Stacked Bar Chart](#stacked-bar-chart)
- [Grouped Bar Chart](#grouped-bar-chart)
- [Advanced Line Chart](#advanced-line-chart)
- [Advanced Bar Chart](#advanced-bar-chart)
- [Mixed Chart](#mixed-chart)
- [Negative Values Chart](#negative-values-chart)
- [Pie Chart](#pie-chart)

### Example Usage With mPDF

[](#example-usage-with-mpdf)

[📄 View PDF document](https://raw.githubusercontent.com/maantje/charts/refs/heads/main/examples/output/report.pdf)
[View source](./examples/pdf/mpdf.php)

### Simple Line Chart

[](#simple-line-chart)

[![Simple Line Chart](./examples/output/line-chart.svg)](./examples/output/line-chart.svg)
[View source](./examples/line-chart.php)

### Curved Line Chart

[](#curved-line-chart)

[![Curved Line Chart](./examples/output/curved-line-chart.svg)](./examples/output/curved-line-chart.svg)
[View source](./examples/curved-line-chart.php)

### Step line chart

[](#step-line-chart)

[![Step line chart](./examples/output/step-line-chart.svg)](./examples/output/step-line-chart.svg)
[View source](./examples/step-line-chart.php)

### Area line chart

[](#area-line-chart)

[![Area line chart](./examples/output/area-line-chart.svg)](./examples/output/area-line-chart.svg)
[View source](./examples/area-line-chart.php)

### Bar Chart

[](#bar-chart)

[![Bar Chart](./examples/output/bar-chart.svg)](./examples/output/bar-chart.svg)
[View source](./examples/bar-chart.php)

### Stacked Bar Chart

[](#stacked-bar-chart)

[![Stacked Bar Chart](./examples/output/stacked-bar-chart.svg)](./examples/output/stacked-bar-chart.svg)
[View source](./examples/stacked-bar-chart.php)

### Grouped Bar Chart

[](#grouped-bar-chart)

[![Grouped Bar Chart](./examples/output/grouped-bar-chart.svg)](./examples/output/grouped-bar-chart.svg)
[View source](./examples/grouped-bar-chart.php)

### Advanced Line Chart

[](#advanced-line-chart)

[![Advanced Line Chart](./examples/output/advanced-line-chart.svg)](./examples/output/advanced-line-chart.svg)
[View source](./examples/advanced-line-chart.php)

### Advanced Bar Chart

[](#advanced-bar-chart)

[![Advanced Bar Chart](./examples/output/advanced-bar-chart.svg)](./examples/output/advanced-bar-chart.svg)
[View source](./examples/advanced-bar-chart.php)

### Mixed chart

[](#mixed-chart)

[![Mixed chart](./examples/output/mixed-chart.svg)](./examples/output/mixed-chart.svg)
[View source](./examples/mixed-chart.php)

### Negative Values Chart

[](#negative-values-chart)

[![Negative Values Chart](./examples/output/negative-values-chart.svg)](./examples/output/negative-values-chart.svg)
[View source](./examples/negative-values-chart.php)

### Pie chart

[](#pie-chart)

[![Pie chart](./examples/output/pie-chart.svg)](./examples/output/pie-chart.svg)
[View source](./examples/pie-chart.php)

Usage
-----

[](#usage)

### Creating a Chart

[](#creating-a-chart)

You can create different types of charts using the provided classes. Below are examples of how to create a simple bar chart and a line chart.

#### Simple Bar Chart

[](#simple-bar-chart)

```
use Maantje\Charts\Bar\Bar;
use Maantje\Charts\Bar\Bars;
use Maantje\Charts\Chart;

$chart = new Chart(
    series: [
        new Bars(
            bars: [
                new Bar(name: 'Jan', value: 222301),
                new Bar(name: 'Feb', value: 189242),
                new Bar(name: 'Mar', value: 144922),
            ],
        ),
    ],
);

echo $chart->render();
```

#### Simple Line Chart

[](#simple-line-chart-1)

```
use Maantje\Charts\Chart;
use Maantje\Charts\Line\Line;
use Maantje\Charts\Line\Lines;
use Maantje\Charts\Line\Point;

$chart = new Chart(
    series: [
        new Lines(
            lines: [
                new Line(
                    points: [
                        new Point(x: 0, y: 0),
                        new Point(x: 100, y: 4),
                        new Point(x: 200, y: 12),
                        new Point(x: 300, y: 8),
                    ],
                ),
                new Line(
                    points: [
                        [0, 0],
                        [100, 4],
                        [200, 12],
                        [300, 8],
                    ],
                ),
            ],
        ),
    ],
);

echo $chart->render();
```

#### Annotations

[](#annotations)

You can add annotations to your charts for better visualization.

```
use Maantje\Charts\Annotations\PointAnnotation;
use Maantje\Charts\YAxis;

$chart = new Chart(
    yAxis: new YAxis(
        annotations: [
            new PointAnnotation(x: 200, y: 120, label: 'Important Point'),
        ],
    ),
    // ...
);
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 95.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~99 days

Total

14

Last Release

82d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f40d5cff5f8299f4f3909701969fd2c677e41245b2ce26f975f3dd806b010ee1?d=identicon)[moijamie](/maintainers/moijamie)

---

Top Contributors

[![maantje](https://avatars.githubusercontent.com/u/9058265?v=4)](https://github.com/maantje "maantje (58 commits)")[![lennyrouanet](https://avatars.githubusercontent.com/u/5269913?v=4)](https://github.com/lennyrouanet "lennyrouanet (2 commits)")[![Telio3](https://avatars.githubusercontent.com/u/92578579?v=4)](https://github.com/Telio3 "Telio3 (1 commits)")

---

Tags

chartchartsphpsvg

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maantje-charts/health.svg)

```
[![Health](https://phpackages.com/badges/maantje-charts/health.svg)](https://phpackages.com/packages/maantje-charts)
```

###  Alternatives

[caffeinated/flash

Flash Messages for Laravel

4649.5k2](/packages/caffeinated-flash)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
