{"id":13405133,"url":"https://github.com/hisune/Echarts-PHP","last_synced_at":"2025-03-14T09:32:27.939Z","repository":{"id":41092754,"uuid":"38486537","full_name":"hisune/Echarts-PHP","owner":"hisune","description":"Echarts-PHP a PHP library that works as a wrapper for the Echarts js library ","archived":false,"fork":false,"pushed_at":"2023-03-03T01:48:49.000Z","size":890,"stargazers_count":315,"open_issues_count":2,"forks_count":62,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-03-16T07:10:52.600Z","etag":null,"topics":["chart","echarts","echartsphp","php","wrapper"],"latest_commit_sha":null,"homepage":"https://hisune.com/view/38/echarts-php-library","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hisune.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-03T10:11:17.000Z","updated_at":"2024-06-05T14:33:00.454Z","dependencies_parsed_at":"2024-06-05T14:32:59.234Z","dependency_job_id":"cea4c774-f4c3-4a70-9901-d1343164da70","html_url":"https://github.com/hisune/Echarts-PHP","commit_stats":{"total_commits":118,"total_committers":7,"mean_commits":"16.857142857142858","dds":"0.34745762711864403","last_synced_commit":"6086cdaf56393083fc097cea4538aa2b39016236"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisune%2FEcharts-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisune%2FEcharts-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisune%2FEcharts-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hisune%2FEcharts-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hisune","download_url":"https://codeload.github.com/hisune/Echarts-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221454074,"owners_count":16824598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","echarts","echartsphp","php","wrapper"],"created_at":"2024-07-30T19:01:56.243Z","updated_at":"2024-10-25T19:31:43.767Z","avatar_url":"https://github.com/hisune.png","language":"PHP","funding_links":[],"categories":["PHP","Languages"],"sub_categories":["PHP"],"readme":"# Echarts-PHP\n[![Latest Stable Version](http://poser.pugx.org/hisune/echarts-php/v)](https://packagist.org/packages/hisune/echarts-php) [![Total Downloads](http://poser.pugx.org/hisune/echarts-php/downloads)](https://packagist.org/packages/hisune/echarts-php) [![Latest Unstable Version](http://poser.pugx.org/hisune/echarts-php/v/unstable)](https://packagist.org/packages/hisune/echarts-php) [![License](http://poser.pugx.org/hisune/echarts-php/license)](https://packagist.org/packages/hisune/echarts-php) [![PHP Version Require](http://poser.pugx.org/hisune/echarts-php/require/php)](https://packagist.org/packages/hisune/echarts-php)\n\nEcharts-PHP is a PHP library that works as a wrapper for the **Echarts js** library (https://github.com/apache/echarts). Support [Apache ECharts (incubating)](https://github.com/apache/echarts) from version 2.2.x to 5.x.\n\nWelcome star ⭐️!\n\n## Setup\n\nThe recommended way to install Echarts-PHP is through  [`Composer`](http://getcomposer.org). Just run the composer command to install it:\n```sh\ncomposer require hisune/echarts-php\n```\n\n## Table of Contents\n  - Class: ECharts\n    - [__construct([string] $dist = '')](#simple-recommend-using-php-property)\n    - [addSeries(Series $series)](#add-series-with-property) \n    - [addXAxis(XAxis $xAxis)](#add-xaxis-with-property) \n    - [addYAxis(YAxis $yAxis)](#add-yaxis-with-property) \n    - [setOption(array $option)](#or-you-can-set-option-array-directly) \n    - [getOption([array] $render = null, [boolean] $jsObject = false)](#or-you-can-set-option-array-directly) \n    - [setJsVar(string $name = null)](#customer-js-variable-name) \n    - [getJsVar()](#customer-js-variable-name) \n    - [render(string $id, [array] $attribute = [], [string] $theme = null)](#customer-attribute) \n    - [on(string $event, string $callback)](#events-for-3x) \n  - Class: Config\n    - [jsExpr(string $string)](#javascript-function)\n    - [eventMethod(string $name)](#events-for-3x)\n    - [addExtraScript(string $file, [string] $dist = null)](#add-extra-script-from-cdn)\n    - [$dist](#customer-dist)\n    - [$distType](#dist-type)\n    - [$minify](#whether-or-not-load-minify-js-file)\n    - $renderScript\n    - $version\n  - [Theme](#the-example-for-echarts-theme-use-addextrascript)\n  - [PHPDoc for property](#full-echarts-phpdoc)\n    \n## Usage\n\n### Simple, recommend using PHP property\n`public ECharts::__construct([string] $dist = '')`\n - Param `dist` is your customer dist url.\n```php\n// The most simple example\nuse Hisune\\EchartsPHP\\ECharts;\n$chart = new ECharts();\n$chart-\u003etooltip-\u003eshow = true;\n$chart-\u003elegend-\u003edata[] = '销量';\n$chart-\u003exAxis[] = array(\n    'type' =\u003e 'category',\n    'data' =\u003e array(\"衬衫\",\"羊毛衫\",\"雪纺衫\",\"裤子\",\"高跟鞋\",\"袜子\")\n);\n$chart-\u003eyAxis[] = array(\n    'type' =\u003e 'value'\n);\n$chart-\u003eseries[] = array(\n    'name' =\u003e '销量',\n    'type' =\u003e 'bar',\n    'data' =\u003e array(5, 20, 40, 10, 10, 20)\n);\necho $chart-\u003erender('simple-custom-id');\n```\n\n### Add series with property\n`void ECharts::addSeries(\\Hisune\\EchartsPHP\\Doc\\IDE\\Series $series)`\n```php\nuse \\Hisune\\EchartsPHP\\Doc\\IDE\\Series;\n$series = new Series();\n$series-\u003etype = 'map';\n$series-\u003emap = 'world';\n$series-\u003edata = array(\n    array(\n        'name' =\u003e 'China',\n        'value' =\u003e 100,\n    )\n);\n$series-\u003elabel-\u003eemphasis-\u003etextStyle-\u003ecolor = '#fff';\n$series-\u003eroam = true;\n$series-\u003escaleLimit-\u003emin = 1;\n$series-\u003escaleLimit-\u003emax = 5;\n$series-\u003eitemStyle-\u003enormal-\u003eborderColor = '#F2EFF4';\n$series-\u003eitemStyle-\u003enormal-\u003eareaColor = '#993399';\n$series-\u003eitemStyle-\u003eemphasis-\u003eareaColor = '#993399';\n$chart-\u003eaddSeries($series);\n```\n\n### Add XAxis with property\n`void ECharts::addXAxis(\\Hisune\\EchartsPHP\\Doc\\IDE\\XAxis $xAxis)`\n```php\nuse Hisune\\EchartsPHP\\Doc\\IDE\\XAxis;\n$xAxis = new XAxis();\n$xAxis-\u003etype = 'category';\n$xAxis-\u003edata = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');\n$chart-\u003eaddXAxis($xAxis);\n```\n\n### Add YAxis with property\n`void ECharts::addYAxis(\\Hisune\\EchartsPHP\\Doc\\IDE\\YAxis $yAxis)`\n```php\nuse Hisune\\EchartsPHP\\Doc\\IDE\\YAxis;\n$yAxis = new YAxis();\n$yAxis-\u003etype = 'value';\n$chart-\u003eaddYAxis($yAxis);\n```\n\n### Or you can set option array directly\n`void ECharts::setOption(array $option)`\n - Param `option` is ECharts option array to be set.\n\n`array|string ECharts::getOption([array] $render = null, [boolean] $jsObject = false)`\n - Param `render` is ECharts option array.\n - Param `jsObject` is whether or not to return json string, return PHP array by default.\n```php\n$option = array (\n  'tooltip' =\u003e\n  array (\n    'show' =\u003e true,\n  ),\n  'legend' =\u003e\n  array (\n    'data' =\u003e\n    array (\n      0 =\u003e '销量',\n    ),\n  ),\n  // ...\n)\n$chart-\u003esetOption($option);\n```\n\n### Array key support\n\n```php\n$chart-\u003elegend-\u003edata[] = '销量';\n$chart-\u003eyAxis[0] = array('type' =\u003e 'value');\n```\n\n### Empty object assignment\nIf you need to assign a value to an empty object, you can use `StdClass`, for example: `$chart-\u003eyAxis = new \\StdClass;`\n\n### Javascript function\n`string Config::jsExpr(string $string)`\n```php\n// With 'function' letter startup\n'axisLabel' =\u003e array(\n    // this array value will automatic conversion to js callback function\n    'formatter' =\u003e \"\n        function (value)\n        {\n            return value + ' °C'\n        }\n    \"\n)\n```\n```php\n// Or you can add any js expr with jsExpr\nuse \\Hisune\\EchartsPHP\\Config;\n'backgroundColor' =\u003e Config::jsExpr('\n    new echarts.graphic.RadialGradient(0.5, 0.5, 0.4, [{\n        offset: 0,\n        color: \"#4b5769\"\n    }, {\n        offset: 1,\n        color: \"#404a59\"\n    }])\n');\n```\n### Customer JS variable name\n`void ECharts::setJsVar(string $name = null)`\n - Param `name` is your customer js variable name. By default, js variable name will generate by random.  \n\n`string ECharts::getJsVar()`\n```php\n$chart-\u003esetJsVar('test');\necho $chart-\u003egetJsVar(); // echo test\n// var chart_test = echarts.init( ...\n```\n\n### Customer attribute\n`string ECharts::render(string $id, [array] $attribute = [], [string] $theme = null)`\n - Param `id` is your html dom ID.\n - Param `attribute` is your html dom attribute.\n - Param `theme` is your ECharts theme.\n - Return html string.\n```php\n$chart-\u003erender('simple-custom-id2', array('style' =\u003e 'height: 500px;'));\n```\n\n### Events (for 3.x+)\n`void ECharts::on(string $event, string $callback)`\n - Param `event` is event name, available: `click`, `dblclick`, `mousedown`, `mousemove`, `mouseup`, `mouseover`, `mouseout`\n - Param `callback` is event callback.\n\n`string Config::eventMethod(string $name)`\n - Param `name` is your js function name which to be run in event callback.\n - Return js string, eg: Config::eventMethod('test') =\u003e test(params);\n```php\nuse \\Hisune\\EchartsPHP\\Config;\n// Recommend standard\n$chart-\u003eon('click', Config::eventMethod('console.log'));\n// Or write js directly\n$chart-\u003eon('mousedown', 'console.log(params);');\n```\n\n### Customer dist\n```php\nHisune\\EchartsPHP\\Config::$dist = 'your dist url';\n```\n\n### Dist type\n```php\n\\Hisune\\EchartsPHP\\Config::$distType = 'common'; // '' or 'common' or 'simple'\n```\n\n### Whether or not load minify js file\n```php\n\\Hisune\\EchartsPHP\\Config::$minify = false; // default is true\n```\n\n### Add extra script from cdn\n`string Config::addExtraScript(string $file, [string] $dist = null)`\n - Param `file` is your extra script filename.\n - Param `dist` is your dist CDN uri.\n```php\nHisune\\EchartsPHP\\Config::addExtraScript('extension/dataTool.js'); // the second param is your customer dist url\n```\n### The example for ECharts theme use `addExtraScript`\n```php\nuse \\Hisune\\EchartsPHP\\Config;\nConfig::addExtraScript('vintage.js', 'http://echarts.baidu.com/asset/theme/');\necho $chart-\u003erender('simple-custom-id', array(), 'vintage');\n```\n\n### Full Echarts PHPDoc\nFor more detail visit: https://hisune.com/view/50/echarts-php-property-phpdoc-auto-generate\n\n## Demos\n\nhttps://demo.hisune.com/echarts-php/\n\n[demo](demo)\n\nAll the Echarts live demos present on https://echarts.apache.org/\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisune%2FEcharts-PHP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhisune%2FEcharts-PHP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisune%2FEcharts-PHP/lists"}