PHPackages                             mohsen-mhm/laravel-image-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. [Image &amp; Media](/categories/media)
4. /
5. mohsen-mhm/laravel-image-charts

ActiveLaravel-package[Image &amp; Media](/categories/media)

mohsen-mhm/laravel-image-charts
===============================

Image-charts PHP library to make chart in image format

v1.5.3(1y ago)54971MITPHPPHP ^8.2|^8.3

Since Jul 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Mohsen-mhm/laravel-image-charts)[ Packagist](https://packagist.org/packages/mohsen-mhm/laravel-image-charts)[ Docs](https://github.com/Mohsen-mhm/laravel-image-charts)[ RSS](/packages/mohsen-mhm-laravel-image-charts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Image Charts
====================

[](#laravel-image-charts)

Image-charts PHP library to generate charts in image format for your Laravel application.

[![Logo](art/logo.png)](art/logo.png)

[![PHP Version Require](https://camo.githubusercontent.com/af6e822e3efa2191b0874b6dc19394f63391120e3df2154efb642484503bb7e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f4d6f6873656e2d6d686d2f6c61726176656c2d696d6167652d6368617274732f7068702e737667)](https://packagist.org/packages/Mohsen-mhm/laravel-image-charts)[![Required Laravel Version](https://camo.githubusercontent.com/3c4d00795aad8fe88faec584def07985b508e0f94824029b6e565dbc360b7f5c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f4d6f6873656e2d6d686d2f6c61726176656c2d696d6167652d6368617274732f6c61726176656c2f6672616d65776f726b2e7376673f636f6c6f723d253233663133633266)](https://packagist.org/packages/Mohsen-mhm/laravel-image-charts)[![Latest Stable Version](https://camo.githubusercontent.com/30ceff9c19da2b8ec8d01ad5eb65cfc5df845ab96791d28470194666ec8dad79/68747470733a2f2f706f7365722e707567782e6f72672f4d6f6873656e2d6d686d2f6c61726176656c2d696d6167652d6368617274732f76)](https://packagist.org/packages/Mohsen-mhm/laravel-image-charts)[![Total Downloads](https://camo.githubusercontent.com/8d3c43ae341b931debdce22e93671f359f1459bca09a950096806b31ebd6e1cf/68747470733a2f2f706f7365722e707567782e6f72672f4d6f6873656e2d6d686d2f6c61726176656c2d696d6167652d6368617274732f646f776e6c6f616473)](https://packagist.org/packages/Mohsen-mhm/laravel-image-charts)[![License](https://camo.githubusercontent.com/e66eaf4d6ae3bdd3b644af7f86743d0dfef41cf7de58dd1dd31b37d16040c66f/68747470733a2f2f706f7365722e707567782e6f72672f4d6f6873656e2d6d686d2f6c61726176656c2d696d6167652d6368617274732f6c6963656e7365)](https://packagist.org/packages/Mohsen-mhm/laravel-image-charts)

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

[](#installation)

You can install the package via Composer:

```
composer require mohsen-mhm/laravel-image-charts
```

### Publish the Configuration File

[](#publish-the-configuration-file)

To publish the configuration file, use the following command:

```
php artisan vendor:publish --provider="MohsenMhm\LaravelImageCharts\Providers\ImageChartsServiceProvider" --tag="config"
```

This will create a configuration file named `image-charts.php` in the `config` directory.

---

Configuration
-------------

[](#configuration)

You can configure the package settings in the `config/image-charts.php` file. The default configuration values are:

```
return [
    'base_url' => env('IMAGE_CHARTS_BASE_URL', 'https://image-charts.com/chart.js/2.8.0'),
    'default_bg_color' => '#2B2B2B',
    'default_dataset_bg_color' => '#FCBB3D',
    'default_dataset_border_color' => '#FCBB3D',
    'default_width' => '900',
    'default_height' => '600',
    'default_title_text' => 'mohsen.sbs',
    'default_image_path' => storage_path('app/public/charts'),
];
```

Usage
-----

[](#usage)

### Generating a Chart URL

[](#generating-a-chart-url)

Here's an example of how to use the package to generate a chart URL:

```
use MohsenMhm\LaravelImageCharts\ImageChart;

$chartUrl = (new ImageChart())
        ->setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getUrl();
```

or use Facade:

```
use MohsenMhm\LaravelImageCharts\Facades\ImageChartFacade as ImageChart;

$chartUrl = ImageChart::setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getUrl();
```

You can then use this URL to display the chart in your application.

```

```

### Downloading the Chart Image

[](#downloading-the-chart-image)

You can also download the generated chart image to a local file. If no path is specified, the image will be saved to the default path specified in the configuration file.

```
use MohsenMhm\LaravelImageCharts\ImageChart;

$fullImagePath = (new ImageChart())
        ->setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getImage();
```

or use Facade:

```
use MohsenMhm\LaravelImageCharts\Facades\ImageChartFacade as ImageChart;

$fullImagePath = ImageChart::setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getImage();
```

This will save the image to the default path with a generated file name and return the full path to the saved image. You can also specify a custom path:

```
use MohsenMhm\LaravelImageCharts\ImageChart;

$customPath = storage_path('app/public/custom_charts');

$fullImagePath = (new ImageChart())
        ->setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getImage($customPath);
```

or use Facade:

```
use MohsenMhm\LaravelImageCharts\Facades\ImageChartFacade as ImageChart;

$customPath = storage_path('app/public/custom_charts');

$fullImagePath = ImageChart::setData([10, 20, 30])
        ->setLabels(['January', 'February', 'March'])
        ->getImage($customPath);
```

### Output

[](#output)

[![Example chart](art/example.png)](art/example.png)

Full Usage Example
------------------

[](#full-usage-example)

```
use MohsenMhm\LaravelImageCharts\ImageChart;

try {
    $imageChart = (new ImageChart())
        ->setLabels(['January', 'February', 'March'])
        ->setData([10, 20, 30])
        ->setBackgroundColor('#FFFFFF')
        ->setDatasetBackgroundColor('#FF0000')
        ->setDatasetBorderColor('#0000FF')
        ->setWidth('800')
        ->setHeight('400')
        ->setTitleText('Monthly Data');

    $chartUrl = $imageChart->getUrl();
    $imagePath = $imageChart->getImage();
    $binaryData = $imageChart->getBinary();

    echo "Chart URL: $chartUrl\n";
    echo "Image saved at: $imagePath\n";
    echo "image in binary format: $binaryData\n";
} catch (InvalidArgumentException $e) {
    echo 'Error: ' . $e->getMessage();
}
```

### Output

[](#output-1)

```
Chart URL: https://image-charts.com/chart.js/2.8.0 ...
Image saved at: .../storage/app/public/charts/chart_1718432986.png
image in binary format: b"ëPNG \x1A \x00\ ..."

```

[![Example chart](art/full-example.png)](art/full-example.png)

Methods
-------

[](#methods)

The ImageChart class provides the following methods for configuring your chart:

- `setData(array $data)`: Set the data points for the chart.
- `setLabels(array $labels)`: Set the labels for the chart.
- `setBackgroundColor(string $color)`: Set the background color for the chart.
- `setDatasetBackgroundColor(string $color)`: Set the background color for the dataset.
- `setDatasetBorderColor(string $color)`: Set the border color for the dataset.
- `setWidth(string $width)`: Set the width of the chart.
- `setHeight(string $height)`: Set the height of the chart.
- `setTitleText(string $title)`: Set the title text of the chart.
- `getUrl()`: Generate and return the chart URL.
- `getImage(string $path = null)`: Download the chart image to a specified local file path, or use the default path if not specified. Returns the full path to the saved image.
- `getBinary()`: Generate and return the chart image in binary format.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://mit-license.org/).

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request on GitHub.

More chart types &amp; features coming soon... :)

Authors
-------

[](#authors)

[Mohsen Mohammadi](https://mohsen.sbs) - Developer For more information, please visit the [GitHub repository](https://github.com/Mohsen-mhm/laravel-image-charts).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Unknown

Total

1

Last Release

667d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7891a1269e2d058cae6f43ce453ca6716c0d4e9aef74ac5ab3d4c454c43b14d?d=identicon)[Mohsen-mhm](/maintainers/Mohsen-mhm)

---

Top Contributors

[![Mohsen-mhm](https://avatars.githubusercontent.com/u/67678628?v=4)](https://github.com/Mohsen-mhm "Mohsen-mhm (28 commits)")[![alisalehi1380](https://avatars.githubusercontent.com/u/111766206?v=4)](https://github.com/alisalehi1380 "alisalehi1380 (3 commits)")

---

Tags

chart-librarychartjsimage-chartslaravellaravel-chartjslaravel-chartslaravel-packagephpphp-chartphp-charting-libraryphplaravelchartchartjs

### Embed Badge

![Health badge](/badges/mohsen-mhm-laravel-image-charts/health.svg)

```
[![Health](https://phpackages.com/badges/mohsen-mhm-laravel-image-charts/health.svg)](https://phpackages.com/packages/mohsen-mhm-laravel-image-charts)
```

###  Alternatives

[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[nikkanetiya/laravel-color-palette

Laravel Wrapper for `ksubileau/color-thief-php`. Grabs the dominant color or a representative color palette from an image. Uses PHP and GD or Imagick.

3312.6k](/packages/nikkanetiya-laravel-color-palette)[epessine/axis

Draw charts with a simple API on Laravel

265.6k](/packages/epessine-axis)

PHPackages © 2026

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