PHPackages                             llabbasmkhll/laravel-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. llabbasmkhll/laravel-sparkline

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

llabbasmkhll/laravel-sparkline
==============================

generate small chart and sparklines in your laravel app

v1.1(3y ago)8161[1 issues](https://github.com/abbasudo/laravel-sparkline/issues)MITPHPPHP 8.\*

Since Feb 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

laravel-sparkline
=================

[](#laravel-sparkline)

Generate small chart and sparklines in your laravel app like a breeze.
this package helps you to plot prices of stock ,currencies ,crypto, etc, into an image in your laravel app.
it uses [image intervention](https://image.intervention.io/v2) and [PHP gd](https://www.php.net/manual/en/book.image.php) to generate the image.

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

[](#installation)

```
composer require abbaudo/laravel-sparkline
```

Usage
-----

[](#usage)

to use sparkline all you have to is providing the numbers that you want to plot to data function and render the chart like below:

```
$metrics = [76, 80, 50, 62, 32, 55, 42, 5, 10, 2, 22, 5, 6, 26, 25, 55, 40, 32, 55, 42, 5, 10, 2, 22, 56];

return Sparkline::data($metrics)->render()->response('png');
```

this will generate an sparkline like this:
[![sparkline](https://user-images.githubusercontent.com/86796762/170678251-11c4835a-f00b-4a92-b62c-fe0d66f02e24.png)](https://user-images.githubusercontent.com/86796762/170678251-11c4835a-f00b-4a92-b62c-fe0d66f02e24.png)

### Note

[](#note)

`render()` will return an `Intervention\Image` object. more information in [image intervention](https://image.intervention.io/v2).
if your too lazy to read intervention docs simply use `->response('png')` to return the sparkline to the browser.
or `->save('public/fou.jpg')` to save the sparkline.

Customization
-------------

[](#customization)

### Color

[](#color)

#### line

[](#line)

set the color of the sparkline by `color` function. by defult its yellow.

```
$red   = 250;
$green = 100;
$blue  = 100;
$alpha = 1;

Sparkline::data($metrics)->color($red, $green, $blue, $alpha)->render()->response('png');
```

[![d8l94xyhh](https://user-images.githubusercontent.com/86796762/170679405-ed38cb2b-5c75-41bf-82bb-25a07872837e.png)](https://user-images.githubusercontent.com/86796762/170679405-ed38cb2b-5c75-41bf-82bb-25a07872837e.png)

#### background

[](#background)

set the background color by `backgorund` function. by defult its transparent.

```
$red   = 250;
$green = 70;
$blue  = 70;
$alpha = 0.2;

Sparkline::data($metrics)->backgound($red, $green, $blue, $alpha)->render()->response('png');
```

[![KTGrO6VsI](https://user-images.githubusercontent.com/86796762/170682706-77515cd5-4e2a-449a-a497-cc6cdddec08b.png)](https://user-images.githubusercontent.com/86796762/170682706-77515cd5-4e2a-449a-a497-cc6cdddec08b.png)

#### fill

[](#fill)

to fill the sparkline use `fill` function. by defult its transparent.

```
$red   = 250;
$green = 70;
$blue  = 70;
$alpha = 0.2;

Sparkline::data($metrics)->fill($red, $green, $blue, $alpha)->render()->response('png');
```

[![a4OK4h092](https://user-images.githubusercontent.com/86796762/170683086-e7fefbc6-5358-4f60-9abd-0e4d5ed51dd8.png)](https://user-images.githubusercontent.com/86796762/170683086-e7fefbc6-5358-4f60-9abd-0e4d5ed51dd8.png)

### Thickness

[](#thickness)

set line thikness by calling `thickness` like so :

```
Sparkline::data($metrics)->thikness(3)->render()->response('png');
```

[![z_qh8IEhz](https://user-images.githubusercontent.com/86796762/170683690-ba9b1498-1ede-4fcd-9ed0-bf1aca66189b.png)](https://user-images.githubusercontent.com/86796762/170683690-ba9b1498-1ede-4fcd-9ed0-bf1aca66189b.png)

### Fade

[](#fade)

by defult sparklines made with faded color in the begining of the line. to customize it use `fade`.

```
Sparkline::data($metrics)->fade(0.2)->render()->response('png');
```

[![FCRHK8Zpq](https://user-images.githubusercontent.com/86796762/170690936-90bd2e77-0f5d-4e2d-8c98-de9fbde4d022.png)](https://user-images.githubusercontent.com/86796762/170690936-90bd2e77-0f5d-4e2d-8c98-de9fbde4d022.png)
1.0 to maximum fade and 0.0 to remove the fade

### Size

[](#size)

to change the size of the sparkline use `size`. the defult size is 80px for height and 200px for width.

```
$width = 500;
$height = 100;

Sparkline::data($metrics)->size($width, $height)->render()->response('png');
```

[![9Sbe60Lvx](https://user-images.githubusercontent.com/86796762/170690363-6078132c-ae35-46e3-b479-82888f46366a.png)](https://user-images.githubusercontent.com/86796762/170690363-6078132c-ae35-46e3-b479-82888f46366a.png)

use `width` and `heigt` to change the size seperatly.

```
Sparkline::data($metrics)->width(400)->render()->response('png');

Sparkline::data($metrics)->height(100)->render()->response('png');

Sparkline::data($metrics)->width(300)->height(80)->render()->response('png');
```

Example
-------

[](#example)

SparklineController.php

```
class SparklineController extends Controller
{
    public function index(Currency $currency)
    {
        $metrics   = Coingecko::getMetrics($currency->code);
        $sparkline = Sparkline::data($metrics);

        if ($metrics[0] - end($metrics) > 0) {
            $sparkline->color(250, 100, 100);
        } elseif ($metrics[0] - end($metrics) < 0) {
            $sparkline->color(100, 250, 100);
        }

        return $sparkline->render()->response('png');
    }
}
```

web.php

```
Route::get('/currencies/{currency}/sparkline.png', [SparklineController::class, 'index'])->name('currencies.sparkline');
```

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Contact
-------

[](#contact)

Abbas mkhzomi - [Telegram@abbaudox](https://t.me/abbaudox) -

Project Link:

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~57 days

Total

3

Last Release

1446d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a0ca6557a86a960db779a28137c6bfaebecee04c511c341c27ae8aa1ce2b228?d=identicon)[abbasudo](/maintainers/abbasudo)

---

Top Contributors

[![abbasudo](https://avatars.githubusercontent.com/u/86796762?v=4)](https://github.com/abbasudo "abbasudo (26 commits)")

---

Tags

chartimagelaravelphpsparkline

### Embed Badge

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

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

###  Alternatives

[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[justbetter/statamic-image-optimize

Image optimization after upload

1315.2k](/packages/justbetter-statamic-image-optimize)

PHPackages © 2026

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