PHP code example of porygon / dcat-extension-echarts

1. Go to this page and download the library: Download porygon/dcat-extension-echarts 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/ */

    

porygon / dcat-extension-echarts example snippets


// 原生调用
// Chart::make() 后链式调用option设置
// 也可以使用 ->setChartOption("grid",[...]);
// 具体方法可以直接查看源码
// 原生创建的是一个单纯的图表
use Porygon\Echarts\Chart;

Chart::make()->grid([
    "containLabel" => false,
    "left"         => "0%",
    "right"        => "0%",
    "top"          => "0%",
    "bottom"       => "0%",
])->xAxis([
    "type" => 'category',
    "boundaryGap" => false,
    "data" => ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    "show" => false,
])->yAxis([
    "type" => "value", "show" => false
])->tooltip([
    "trigger" => 'axis',
])->serie([
    "data"       => [1, 5, 74, 15, 63, 75, 91],
    "type"       => "line",
    "smooth"     => true,
    "areaStyle"  => [],
    "showSymbol" => false
]);

// 封装调用
// 这个是与封装的demo
use Porygon\Echarts\Examples\NewUser;

// 封装创建的是一个卡片
NewUser::make();
// 也可以继续设置图表属性
NewUser::make()->->xAxis([
    "type" => 'category',
    "boundaryGap" => false,
    "data" => ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    "show" => false,
])->yAxis([
    "type" => "value", "show" => false
])->tooltip([
    "trigger" => 'axis',
]);