PHPackages                             rockys/echarts-php - 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. rockys/echarts-php

ActiveLibrary

rockys/echarts-php
==================

A php wrapper for echarts javascript libraries

1.0.0(3y ago)03.7k↓100%1MITPHPPHP &gt;=5.4.0

Since Nov 15Pushed 3y agoCompare

[ Source](https://github.com/rocky-git/Echarts-PHP)[ Packagist](https://packagist.org/packages/rockys/echarts-php)[ Docs](http://hisune.com)[ RSS](/packages/rockys-echarts-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

Echarts-PHP
===========

[](#echarts-php)

[![Latest Stable Version](https://camo.githubusercontent.com/054f093422182c0ebb916077be47aa2eddb34ab18f647ec2709ff9f995920827/687474703a2f2f706f7365722e707567782e6f72672f686973756e652f656368617274732d7068702f76)](https://packagist.org/packages/hisune/echarts-php) [![Total Downloads](https://camo.githubusercontent.com/d8732898cda1109a8f11bd38ab689c2fdce16be394433bbf4b69e95338b2af72/687474703a2f2f706f7365722e707567782e6f72672f686973756e652f656368617274732d7068702f646f776e6c6f616473)](https://packagist.org/packages/hisune/echarts-php) [![Latest Unstable Version](https://camo.githubusercontent.com/5f53f286c2b907b500b27f147e8944226ec8e2b59a5d4e7aca431018db81decb/687474703a2f2f706f7365722e707567782e6f72672f686973756e652f656368617274732d7068702f762f756e737461626c65)](https://packagist.org/packages/hisune/echarts-php) [![License](https://camo.githubusercontent.com/a9a848903e0129565bc0beb5396b92c49fbf991173598d03d1010ed121b828b5/687474703a2f2f706f7365722e707567782e6f72672f686973756e652f656368617274732d7068702f6c6963656e7365)](https://packagist.org/packages/hisune/echarts-php) [![PHP Version Require](https://camo.githubusercontent.com/4840bff20618ca91aee4b00de32eeb658f7c7dfcbfc4b98cd461cf94df402dd9/687474703a2f2f706f7365722e707567782e6f72672f686973756e652f656368617274732d7068702f726571756972652f706870)](https://packagist.org/packages/hisune/echarts-php)

Echarts-PHP is a PHP library that works as a wrapper for the **Echarts js** library (). Support [Apache ECharts (incubating)](https://github.com/apache/echarts) from version 2.2.x to 5.x.

Welcome star ⭐️!

Setup
-----

[](#setup)

The recommended way to install Echarts-PHP is through [`Composer`](http://getcomposer.org). Just run the composer command to install it:

```
composer require hisune/echarts-php
```

Table of Contents
-----------------

[](#table-of-contents)

- Class: ECharts
    - [\_\_construct(\[string\] $dist = '')](#simple-recommend-using-php-property)
    - [addSeries(Series $series)](#add-series-with-property)
    - [addXAxis(XAxis $xAxis)](#add-xaxis-with-property)
    - [addYAxis(YAxis $yAxis)](#add-yaxis-with-property)
    - [setOption(array $option)](#or-you-can-set-option-array-directly)
    - [getOption(\[array\] $render = null, \[boolean\] $jsObject = false)](#or-you-can-set-option-array-directly)
    - [setJsVar(string $name = null)](#customer-js-variable-name)
    - [getJsVar()](#customer-js-variable-name)
    - [render(string $id, \[array\] $attribute = \[\], \[string\] $theme = null)](#customer-attribute)
    - [on(string $event, string $callback)](#events-for-3x)
- Class: Config
    - [jsExpr(string $string)](#javascript-function)
    - [eventMethod(string $name)](#events-for-3x)
    - [addExtraScript(string $file, \[string\] $dist = null)](#add-extra-script-from-cdn)
    - [$dist](#customer-dist)
    - [$distType](#dist-type)
    - [$minify](#whether-or-not-load-minify-js-file)
    - $renderScript
    - $version
- [Theme](#the-example-for-echarts-theme-use-addextrascript)
- [PHPDoc for property](#full-echarts-phpdoc)

Usage
-----

[](#usage)

### Simple, recommend using PHP property

[](#simple-recommend-using-php-property)

`public ECharts::__construct([string] $dist = '')`

- Param `dist` is your customer dist url.

```
// The most simple example
use Hisune\EchartsPHP\ECharts;
$chart = new ECharts();
$chart->tooltip->show = true;
$chart->legend->data[] = '销量';
$chart->xAxis[] = array(
    'type' => 'category',
    'data' => array("衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子")
);
$chart->yAxis[] = array(
    'type' => 'value'
);
$chart->series[] = array(
    'name' => '销量',
    'type' => 'bar',
    'data' => array(5, 20, 40, 10, 10, 20)
);
echo $chart->render('simple-custom-id');
```

### Add series with property

[](#add-series-with-property)

`void ECharts::addSeries(\Hisune\EchartsPHP\Doc\IDE\Series $series)`

```
use \Hisune\EchartsPHP\Doc\IDE\Series;
$series = new Series();
$series->type = 'map';
$series->map = 'world';
$series->data = array(
    array(
        'name' => 'China',
        'value' => 100,
    )
);
$series->label->emphasis->textStyle->color = '#fff';
$series->roam = true;
$series->scaleLimit->min = 1;
$series->scaleLimit->max = 5;
$series->itemStyle->normal->borderColor = '#F2EFF4';
$series->itemStyle->normal->areaColor = '#993399';
$series->itemStyle->emphasis->areaColor = '#993399';
$chart->addSeries($series);
```

### Add XAxis with property

[](#add-xaxis-with-property)

`void ECharts::addXAxis(\Hisune\EchartsPHP\Doc\IDE\XAxis $xAxis)`

```
use Hisune\EchartsPHP\Doc\IDE\XAxis;
$xAxis = new XAxis();
$xAxis->type = 'category';
$xAxis->data = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$chart->addXAxis($xAxis);
```

### Add YAxis with property

[](#add-yaxis-with-property)

`void ECharts::addYAxis(\Hisune\EchartsPHP\Doc\IDE\YAxis $yAxis)`

```
use Hisune\EchartsPHP\Doc\IDE\YAxis;
$yAxis = new YAxis();
$yAxis->type = 'value';
$chart->addYAxis($yAxis);
```

### Or you can set option array directly

[](#or-you-can-set-option-array-directly)

`void ECharts::setOption(array $option)`

- Param `option` is ECharts option array to be set.

`array|string ECharts::getOption([array] $render = null, [boolean] $jsObject = false)`

- Param `render` is ECharts option array.
- Param `jsObject` is whether or not to return json string, return PHP array by default.

```
$option = array (
  'tooltip' =>
  array (
    'show' => true,
  ),
  'legend' =>
  array (
    'data' =>
    array (
      0 => '销量',
    ),
  ),
  // ...
)
$chart->setOption($option);
```

### Array key support

[](#array-key-support)

```
$chart->legend->data[] = '销量';
$chart->yAxis[0] = array('type' => 'value');
```

### Empty object assignment

[](#empty-object-assignment)

If you need to assign a value to an empty object, you can use `StdClass`, for example: `$chart->yAxis = new \StdClass;`

### Javascript function

[](#javascript-function)

`string Config::jsExpr(string $string)`

```
// With 'function' letter startup
'axisLabel' => array(
    // this array value will automatic conversion to js callback function
    'formatter' => "
        function (value)
        {
            return value + ' °C'
        }
    "
)
```

```
// Or you can add any js expr with jsExpr
use \Hisune\EchartsPHP\Config;
'backgroundColor' => Config::jsExpr('
    new echarts.graphic.RadialGradient(0.5, 0.5, 0.4, [{
        offset: 0,
        color: "#4b5769"
    }, {
        offset: 1,
        color: "#404a59"
    }])
');
```

### Customer JS variable name

[](#customer-js-variable-name)

`void ECharts::setJsVar(string $name = null)`

- Param `name` is your customer js variable name. By default, js variable name will generate by random.

`string ECharts::getJsVar()`

```
$chart->setJsVar('test');
echo $chart->getJsVar(); // echo test
// var chart_test = echarts.init( ...
```

### Customer attribute

[](#customer-attribute)

`string ECharts::render(string $id, [array] $attribute = [], [string] $theme = null)`

- Param `id` is your html dom ID.
- Param `attribute` is your html dom attribute.
- Param `theme` is your ECharts theme.
- Return html string.

```
$chart->render('simple-custom-id2', array('style' => 'height: 500px;'));
```

### Events (for 3.x+)

[](#events-for-3x)

`void ECharts::on(string $event, string $callback)`

- Param `event` is event name, available: `click`, `dblclick`, `mousedown`, `mousemove`, `mouseup`, `mouseover`, `mouseout`
- Param `callback` is event callback.

`string Config::eventMethod(string $name)`

- Param `name` is your js function name which to be run in event callback.
- Return js string, eg: Config::eventMethod('test') =&gt; test(params);

```
use \Hisune\EchartsPHP\Config;
// Recommend standard
$chart->on('click', Config::eventMethod('console.log'));
// Or write js directly
$chart->on('mousedown', 'console.log(params);');
```

### Customer dist

[](#customer-dist)

```
Hisune\EchartsPHP\Config::$dist = 'your dist url';
```

### Dist type

[](#dist-type)

```
\Hisune\EchartsPHP\Config::$distType = 'common'; // '' or 'common' or 'simple'
```

### Whether or not load minify js file

[](#whether-or-not-load-minify-js-file)

```
\Hisune\EchartsPHP\Config::$minify = false; // default is true
```

### Add extra script from cdn

[](#add-extra-script-from-cdn)

`string Config::addExtraScript(string $file, [string] $dist = null)`

- Param `file` is your extra script filename.
- Param `dist` is your dist CDN uri.

```
Hisune\EchartsPHP\Config::addExtraScript('extension/dataTool.js'); // the second param is your customer dist url
```

### The example for ECharts theme use `addExtraScript`

[](#the-example-for-echarts-theme-use-addextrascript)

```
use \Hisune\EchartsPHP\Config;
Config::addExtraScript('vintage.js', 'http://echarts.baidu.com/asset/theme/');
echo $chart->render('simple-custom-id', array(), 'vintage');
```

### Full Echarts PHPDoc

[](#full-echarts-phpdoc)

For more detail visit:

Demos
-----

[](#demos)

[demo](demo)

All the Echarts live demos present on

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

1272d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2356ebc531ecf95396be69a4adf181e70be1d5f1aa8a0dc1b8467218f528ff19?d=identicon)[rocky-git](/maintainers/rocky-git)

---

Top Contributors

[![hisune](https://avatars.githubusercontent.com/u/7941669?v=4)](https://github.com/hisune "hisune (92 commits)")[![rocky-git](https://avatars.githubusercontent.com/u/44958386?v=4)](https://github.com/rocky-git "rocky-git (2 commits)")[![Hansz00](https://avatars.githubusercontent.com/u/46049129?v=4)](https://github.com/Hansz00 "Hansz00 (1 commits)")[![w169q169](https://avatars.githubusercontent.com/u/12460574?v=4)](https://github.com/w169q169 "w169q169 (1 commits)")

---

Tags

phpjavascriptchartsecharts

### Embed Badge

![Health badge](/badges/rockys-echarts-php/health.svg)

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

###  Alternatives

[hisune/echarts-php

A php wrapper for echarts javascript libraries

327201.9k5](/packages/hisune-echarts-php)[ghunti/highcharts-php

A php wrapper for highcharts and highstock javascript libraries

3772.3M5](/packages/ghunti-highcharts-php)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)

PHPackages © 2026

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