PHPackages                             brendt/php-sparkline - 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. [Image &amp; Media](/categories/media)
4. /
5. brendt/php-sparkline

ActiveLibrary[Image &amp; Media](/categories/media)

brendt/php-sparkline
====================

Generate sparkline SVGs in PHP

2.0.1(7mo ago)35172.8k↑39.5%14[2 issues](https://github.com/brendt/php-sparkline/issues)MITPHPPHP ^8.1CI passing

Since Dec 8Pushed 7mo ago5 watchersCompare

[ Source](https://github.com/brendt/php-sparkline)[ Packagist](https://packagist.org/packages/brendt/php-sparkline)[ Docs](https://github.com/brendt/php-sparkline)[ RSS](/packages/brendt-php-sparkline/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

Generate sparkline SVGs in PHP
==============================

[](#generate-sparkline-svgs-in-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a8e65122d62fa4faf6e4911ab97c2dba4272da13ec5c7f4c54ae8c44c8eb3f06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272656e64742f7068702d737061726b6c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brendt/php-sparkline)[![Tests](https://github.com/brendt/php-sparkline/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/brendt/php-sparkline/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/884ca508105741d3f6fdd6c2f62128a89470ae506fa4dc34a9514888a7fe3419/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272656e64742f7068702d737061726b6c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brendt/php-sparkline)

PHP-Sparkline generates GitHub style sparkline graphs. Read this guide to know how to use it.

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

[](#installation)

You can install the package via composer:

```
composer require brendt/php-sparkline
```

Usage
-----

[](#usage)

```
$sparkLine = new SparkLine(1, 2, 5, 10, 2);

$total = $sparkLine->getTotal();

$svg = $sparkLine->make();
```

[![](./.github/img/0.png)](./.github/img/0.png)

To construct a sparkline, you'll have to pass in an array of values.

### Customization

[](#customization)

You can pick any amount of colors and the sparkline will automatically generate a gradient from them:

```
$sparkLine = (new SparkLine($days))->withColors('#4285F4', '#31ACF2', '#2BC9F4');
```

[![](./.github/img/1.png)](./.github/img/1.png)

You can configure the stroke width:

```
$sparkLine = (new SparkLine($days))->withStrokeWidth(4);
```

As well as the dimensions (in pixels):

```
$sparkLine = SparkLine::new($days)->withDimensions(width: 500, height: 100);
```

[![](./.github/img/2.png)](./.github/img/2.png)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Brent Roose](https://github.com/brendt)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance64

Regular maintenance activity

Popularity50

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~207 days

Recently: every ~259 days

Total

6

Last Release

222d ago

Major Versions

0.1.0 → 1.0.02022-12-08

1.1.1 → 2.0.02024-06-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cb3720658b52133e7200a378eae26508fb343534a3c115bd3ee74ea9d501ba2?d=identicon)[brendt](/maintainers/brendt)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (98 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (29 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (27 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (13 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")[![gregkos](https://avatars.githubusercontent.com/u/6676236?v=4)](https://github.com/gregkos "gregkos (4 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (4 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (2 commits)")[![erikn69](https://avatars.githubusercontent.com/u/4933954?v=4)](https://github.com/erikn69 "erikn69 (2 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (2 commits)")[![jamessessford](https://avatars.githubusercontent.com/u/17096446?v=4)](https://github.com/jamessessford "jamessessford (2 commits)")[![mnaderian](https://avatars.githubusercontent.com/u/30769988?v=4)](https://github.com/mnaderian "mnaderian (1 commits)")[![LarsWiegers](https://avatars.githubusercontent.com/u/20204608?v=4)](https://github.com/LarsWiegers "LarsWiegers (1 commits)")[![dietercoopman](https://avatars.githubusercontent.com/u/4672752?v=4)](https://github.com/dietercoopman "dietercoopman (1 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (1 commits)")[![dejurin](https://avatars.githubusercontent.com/u/4470015?v=4)](https://github.com/dejurin "dejurin (1 commits)")

---

Tags

brendtphp-sparkline

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/brendt-php-sparkline/health.svg)

```
[![Health](https://phpackages.com/badges/brendt-php-sparkline/health.svg)](https://phpackages.com/packages/brendt-php-sparkline)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[contao/image

Contao image library

131.7M9](/packages/contao-image)[intervention/image-driver-vips

libvips driver for Intervention Image

4495.5k6](/packages/intervention-image-driver-vips)

PHPackages © 2026

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