This action will force synchronization from hisune/Echarts-PHP, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
Echarts-PHP is a PHP library that works as a wrapper for the Echarts js library (https://github.com/ecomfe/echarts). Support Echarts version from 2.2.x to 3.x.
The recommended way to install Echarts-PHP is through Composer
. Just run the composer command to install it:
composer require "hisune/echarts-php"
public ECharts::__construct([string] $dist = '')
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');
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);
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);
void ECharts::addYAxis(\Hisune\EchartsPHP\Doc\IDE\YAxis $yAxis)
use Hisune\EchartsPHP\Doc\IDE\YAxis;
$yAxis = new YAxis();
$yAxis->type = 'value';
$chart->addYAxis($yAxis);
void ECharts::setOption(array $option)
option
is ECharts option array to be set.array|string ECharts::getOption([array] $render = null, [boolean] $jsObject = false)
render
is ECharts option array.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);
$chart->legend->data[] = '销量';
$chart->yAxis[0] = array('type' => 'value');
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"
}])
');
void ECharts::setJsVar(string $name = null)
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( ...
string ECharts::render(string $id, [array] $attribute = [], [string] $theme = null)
id
is your html dom ID.attribute
is your html dom attribute.theme
is your ECharts theme.$chart->render('simple-custom-id2', array('style' => 'height: 500px;'));
void ECharts::on(string $event, string $callback)
event
is event name, available: click
, dblclick
, mousedown
, mousemove
, mouseup
, mouseover
, mouseout
callback
is event callback.string Config::eventMethod(string $name)
name
is your js function name which to be run in event callback.use \Hisune\EchartsPHP\Config;
// Recommend standard
$chart->on('click', Config::eventMethod('console.log'));
// Or write js directly
$chart->on('mousedown', 'console.log(params);');
Hisune\EchartsPHP\Config::$dist = 'your dist url';
\Hisune\EchartsPHP\Config::$distType = 'common'; // '' or 'common' or 'simple'
\Hisune\EchartsPHP\Config::$minify = false; // default is true
string Config::addExtraScript(string $file, [string] $dist = null)
file
is your extra script filename.dist
is your dist CDN uri.Hisune\EchartsPHP\Config::addExtraScript('extension/dataTool.js'); // the second param is your customer dist url
addExtraScript
use \Hisune\EchartsPHP\Config;
Config::addExtraScript('vintage.js', 'http://echarts.baidu.com/asset/theme/');
echo $chart->render('simple-custom-id', array(), 'vintage');
For more detail visit: https://hisune.com/view/50/echarts-php-property-phpdoc-auto-generate
https://demo.hisune.com/echarts-php/
All the Echarts live demos present on http://echarts.baidu.com/.
MIT
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。