brendt/php-sparkline

Generate sparkline SVGs in PHP

Maintainers

👁 brendt

Package info

github.com/brendt/php-sparkline

pkg:composer/brendt/php-sparkline

Statistics

Installs: 76 607

Dependents: 0

Suggesters: 0

Stars: 350

Open Issues: 2

2.0.1 2025-10-09 04:54 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT a8cbd21dd353e1bbbb619858148fecb9dd7437dc

  • Brent Roose <brendt.woop@stitcher.io>

brendtphp-sparkline

This package is auto-updated.

Last update: 2026-06-09 06:14:58 UTC


README

👁 Latest Version on Packagist
👁 Tests
👁 Total Downloads

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

Installation

You can install the package via composer:

composer require brendt/php-sparkline

Usage

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

$total = $sparkLine->getTotal();

$svg = $sparkLine->make();

👁 Image

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

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');

👁 Image

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);

👁 Image

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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