PHPackages                             iamamirsalehi/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. iamamirsalehi/sparkline

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

iamamirsalehi/sparkline
=======================

00PHP

Since Jan 14Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

sparkline
=========

[](#sparkline)

[![License](https://camo.githubusercontent.com/26ab1535f1229bb53244216703003b2d86dc6cd18b6732858ee0dd40f053cbff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a7878652f737061726b6c696e65)](https://github.com/jxxe/sparkline/blob/master/LICENSE)[![Download](https://camo.githubusercontent.com/619c0d36611b21ef76e8893c40293d6f924eab7a98b789db8bdf5490d3e5c1ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f776e6c6f61642d253343324b422d627269676874677265656e)](https://raw.githubusercontent.com/jxxe/sparkline/master/sparkline.php)[![GitHub stars](https://camo.githubusercontent.com/5fc241e27a3f75f143cbf1e4461d3c89fb5bff49d96bb4da10a6cf0d21d5003c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a7878652f737061726b6c696e653f7374796c653d736f6369616c)](https://github.com/jxxe/sparkline)

This is a port of [fnando/sparkline](https://github.com/fnando/sparkline). Due to the nature of PHP, it does not have many of the features that the JavaScript version does, but can still generate pretty SVG sparklines from a dataset. Here's how it works:

Usage
-----

[](#usage)

This is a minimum working example:

```
require_once('sparkline.php'); // Or whatever the path is
echo sparkline('sparkline', [1, 5, 2, 4, 8, 3, 7]);
```

It will output an SVG that looks like this:

[![](https://camo.githubusercontent.com/0f7a9f07b094775f37e20d28852de2c3fbafa358bffa7e91322df248c656d0b2/68747470733a2f2f692e696d6775722e636f6d2f55695a4b6d48302e706e67)](https://camo.githubusercontent.com/0f7a9f07b094775f37e20d28852de2c3fbafa358bffa7e91322df248c656d0b2/68747470733a2f2f692e696d6775722e636f6d2f55695a4b6d48302e706e67)

API
---

[](#api)

### `sparkline($svgClass, $values, $lineColor, $fillColor, $options)`

[](#sparklinesvgclass-values-linecolor-fillcolor-options)

ParameterDefault ValueDescription$svgClass(Required)The CSS class for your sparkline. You can use this to style specific sparklines.$values(Required)An array of the values to be graphed. Example: `[1,2,3,4,5]`;$lineColor`'red'`A value that will be put into the `stroke` attribute of the line path. Any CSS color values work.$fillColor`'none'`A value that will be put into the `fill` attribute of the sparkline's fill. CSS colors work.$options`['strokeWidth' => 3, 'width' => 100, 'height' => 30]`An array of options for the sparkline.License
-------

[](#license)

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 79.3% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2724dc2377b191a357923d280618c8ac0383c902b18ad3677a44ef20b8fc2835?d=identicon)[iamamirsalehi](/maintainers/iamamirsalehi)

---

Top Contributors

[![jxxe](https://avatars.githubusercontent.com/u/64276359?v=4)](https://github.com/jxxe "jxxe (23 commits)")[![iamamirsalehi](https://avatars.githubusercontent.com/u/54236454?v=4)](https://github.com/iamamirsalehi "iamamirsalehi (6 commits)")

### Embed Badge

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

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

###  Alternatives

[cleaniquecoders/shrinkr

Shrinkr is a Laravel package for shortening URLs, with custom slugs, analytics, branded domains, and seamless API integration.

142.9k](/packages/cleaniquecoders-shrinkr)

PHPackages © 2026

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