1. Go to this page and download the library: Download arashdalir/echarts-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// 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"
}])
');
$chart->setJsVar('test');
echo $chart->getJsVar(); // echo test
// var chart_test = echarts.init( ...
use \Hisune\EchartsPHP\Config;
// Recommend standard
$chart->on('click', Config::eventMethod('console.log'));
// Or write js directly
$chart->on('mousedown', 'console.log(params);');