jcsaunders / laravel-echarts
从 Apache ECharts 创建图像。
v1.0.0
2024-04-21 04:24 UTC
Requires
- codebarista/laravel-essentials: ^1.2
- laravel/framework: ^10.0|^11.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest-plugin-laravel: ^2.0
This package is not auto-updated.
Last update: 2024-09-23 05:14:59 UTC
README
使用 Laravel 和 Node.js 服务器端渲染 Apache ECharts。将图表图像渲染为 png、jpg、pdf 或 svg 并存储。
要求
- Node.js 和 npm
安装
安装包
composer require codebarista/laravel-echarts
安装 node 模块
php artisan codebarista:node-echarts install
为了更新,建议将命令添加到根 composer.json 文件中。
{ "scripts": { "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force", "@php artisan codebarista:node-echarts install" ] }, }
发布配置(可选)
php artisan vendor:publish --tag="config" --provider="Codebarista\LaravelEcharts\EchartsServiceProvider"
安装 pngcrush(可选)
apt install pngcrush
用法
存储图表图像
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: [...]);
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。