Beispiel #1
0
<?php

/**
 * Created by Hisune.
 * User: hi@hisune.com
 * Date: 2015/7/3
 * Time: 18:26
 */
header('Content-Type: text/html; charset=utf-8');
require 'vendor/autoload.php';
use Hisune\EchartsPHP\ECharts;
$chart = new ECharts();
$chart->tooltip->trigger = 'axis';
$chart->legend->data = array('蒸发量', '降水量', '最低气温', '最高气温');
$chart->toolbox = array('show' => true, 'feature' => array('mark' => array('show' => true), 'dataView' => array('show' => true), 'magicType' => array('show' => true, 'type' => array('line', 'bar')), 'restore' => array('show' => true), 'saveAsImage' => array('show' => true)));
$chart->xAxis[] = array('type' => 'category', 'position' => 'bottom', 'boundaryGap' => true, 'axisLine' => array('show' => true, 'lineStyle' => array('color' => 'green', 'type' => 'solid', 'width' => 2)), 'axisTick' => array('show' => true, 'length' => 10, 'lineStyle' => array('color' => 'red', 'type' => 'solid', 'width' => 2)), 'axisLabel' => array('show' => true, 'interval' => 'auto', 'rotate' => 45, 'margin' => 8, 'formatter' => '{value}月', 'textStyle' => array('color' => 'blue', 'fontFamily' => 'sans-serif', 'fontSize' => 15, 'fontStyle' => 'italic', 'fontWeight' => 'bold')), 'splitLine' => array('show' => true, 'lineStyle' => array('color' => '#483d8b', 'type' => 'dashed', 'width' => 1)), 'splitArea' => array('show' => true, 'areaStyle' => array('color' => array('rgba(144,238,144,0.3)', 'rgba(135,200,250,0.3)'))), 'data' => array('1', '2', '3', '4', '5', array('value' => '6', 'textStyle' => array('color' => 'red', 'fontSize' => 30, 'fontStyle' => 'normal', 'fontWeight' => 'bold')), '7', '8', '9', '10', '11', '12'));
$chart->xAxis[] = array('type' => 'category', 'data' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
$chart->yAxis[] = array('type' => 'value', 'position' => 'left', 'boundaryGap' => array(0, 0.1), 'axisLine' => array('show' => true, 'lineStyle' => array('color' => 'red', 'type' => 'dashed', 'width' => 2)), 'axisTick' => array('show' => true, 'length' => 10, 'lineStyle' => array('color' => 'green', 'type' => 'solid', 'width' => 2)), 'axisLabel' => array('show' => true, 'interval' => 'auto', 'rotate' => -45, 'margin' => 18, 'formatter' => '{value} ml', 'textStyle' => array('color' => '#1e90ff', 'fontFamily' => 'verdana', 'fontSize' => 10, 'fontStyle' => 'normal', 'fontWeight' => 'bold')), 'splitLine' => array('show' => true, 'lineStyle' => array('color' => '#483d8b', 'type' => 'dotted', 'width' => 2)), 'splitArea' => array('show' => true, 'areaStyle' => array('color' => array('rgba(205,92,92,0.3)', 'rgba(255,215,0,0.3)'))));
$chart->yAxis[] = array('type' => 'value', 'splitNumber' => 10, 'axisLabel' => array('formatter' => "\n            function (value)\n            {\n                return value + ' °C'\n            }\n        "), 'splitLine' => array('show' => true));
$chart->series[] = array('name' => '蒸发量', 'type' => 'bar', 'data' => array(2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3));
$chart->series[] = array('name' => '降水量', 'type' => 'bar', 'data' => array(2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3));
$chart->series[] = array('name' => '最低气温', 'type' => 'line', 'yAxisIndex' => 1, 'data' => array(2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2));
$chart->series[] = array('name' => '最高气温', 'type' => 'line', 'yAxisIndex' => 1, 'data' => array(12.0, 12.2, 13.3, 14.5, 16.3, 18.2, 28.3, 33.4, 31.0, 24.5, 18.0, 16.2));
echo $chart->render('advance-custom-id');
Beispiel #2
0
 */
use app\assets\EchartsAsset;
use Hisune\EchartsPHP\ECharts;
use yii\helpers\Html;
$this->title = '销售趋势图';
$this->params['breadcrumbs'][] = $this->title;
$asset = EchartsAsset::register($this);
$chart = new ECharts();
$chart->tooltip->show = true;
$chart->color = array();
$chart->legend->data = array('销售量柱状', '销售量折线');
$chart->calculable = true;
$chart->xAxis = array(array('type' => 'category', 'data' => array_keys($list)));
$chart->yAxis = array(array('type' => 'value', 'name' => '销售额', 'max' => 50000, 'splitNumber' => 10, 'axisLabel' => array('formatter' => '{value} 元')));
$chart->series = array(array('name' => '销售量柱状', 'type' => 'bar', 'data' => array_values($list)), array('name' => '销售量折线', 'type' => 'line', 'data' => array_values($list)));
echo $chart->render('main');
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <?php 
echo Html::csrfMetaTags();
Beispiel #3
0
<?php

/**
 * Created by Hisune.
 * User: hi@hisune.com
 * Date: 2015/7/3
 * Time: 18:24
 */
header('Content-Type: text/html; charset=utf-8');
require 'vendor/autoload.php';
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');