jxlwqq / echarts
echarts for laravel-admin
v1.0.2
2019-06-27 10:40 UTC
Requires
- php: >=7.0.0
- encore/laravel-admin: ~1.6
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-09-15 00:40:19 UTC
README
安装
composer require jxlwqq/echarts php artisan vendor:publish --tag=laravel-admin-echarts
配置
打开 config/admin.php
文件,在 extensions
部分添加此扩展的配置。
'extensions' => [ 'echarts' => [ // Set to `false` if you want to disable this extension 'enable' => true, ] ]
用法
在 views 目录下创建一个视图,例如 resources/views/admin/echarts.blade.php
,并添加以下代码
<!-- prepare a DOM container with width and height --> <div id="main" style="width: 600px;height:400px;"></div> <script type="text/javascript"> $(function () { // based on prepared DOM, initialize echarts instance var myChart = echarts.init(document.getElementById('main')); // specify chart configuration item and data var option = { title: { text: 'ECharts entry example' }, tooltip: {}, legend: { data: ['Sales'] }, xAxis: { data: ["shirt", "cardign", "chiffon shirt", "pants", "heels", "socks"] }, yAxis: {}, series: [{ name: 'Sales', type: 'bar', data: [5, 20, 36, 10, 10, 20] }] }; // use configuration item and data specified to show chart myChart.setOption(option); }); </script>
然后在页面上展示它
class EchartsController extends Controller { public function index(Content $content) { return $content ->header('Echarts') ->body(new Box('echarts demo', view('admin.echarts'))); } }
更多用法请参考 echarts 的官方 网站。
许可协议
在 MIT 许可协议 (MIT) 下授权。