PHP code example of codebarista / laravel-echarts

1. Go to this page and download the library: Download codebarista/laravel-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/ */

    

codebarista / laravel-echarts example snippets


use Codebarista\LaravelEcharts\Actions\StoreChartImage;

// ...

StoreChartImage::make()->handle([
    'title' => [
        'text' => 'Basic Bar Chart',
    ],
    'xAxis' => [
        'type' => 'category',
        'data' => ['Shirts', 'Cardigans', 'Chiffons', 'Pants', 'Heels', 'Socks'],
    ],
    'yAxis' => [
        'type' => 'value',
    ],
    'series' => [
        [
            'type' => 'bar',
            'data' => [5, 20, 36, 10, 10, 20],
        ],
    ],
]);

$action = StoreChartImage::make()
    ->baseOptionPath(resource_path('echarts/base-option.mjs')) // base chart to be merged
    ->mimeType(MimeTypes::PNG) // PNG, JPG, PDF, SVG
    ->optimize(true) // optimize with pngcrush
    ->filePath('app/public') // storage path
    ->fileName('simple-bar-chart') // w/o extension
    ->width(600) // image width
    ->height(600); // image height


$action->handle(options: [...]);
shell
php artisan codebarista:node-echarts install
json
{
    "scripts": {
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force",
            "@php artisan codebarista:node-echarts install"
        ]
    },
}
shell
php artisan vendor:publish --tag="config" --provider="Codebarista\LaravelEcharts\EchartsServiceProvider"