energieproduction / chart
适用于 Highcharts 的图表服务
v0.1
2017-09-01 16:40 UTC
Requires
- php: >=5.4.0
- illuminate/support: ~5.1
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: 5.7.*
This package is not auto-updated.
Last update: 2024-09-15 02:37:48 UTC
README
EnergieProduction/Chart
基于 Laravel 5 的 Highcharts 图表服务
安装
在控制台运行以下命令将包下载到您的项目中:
composer require energieproduction/chart
配置
对于 Laravel 5
在 /config/app.php
中添加 ChartServiceProvider
EnergieProduction\Chart\ChartServiceProvider::class,
不要忘记在包含图表的页面上使用 Highcharts 的脚本
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
用法
进行中...
示例
$chart = app('chart'); $chart->pushSubset('title', function($title){ $title->pushCriteria(new Criterias\Text('Solar Employment Growth by Sector, 2010-2016')); }); $chart->pushSubset('subtitle', function($subtitle){ $subtitle->pushCriteria(new Criterias\Text('Source: thesolarfoundation.com')); }); $chart->pushSubset('yAxis.title', function($title){ $title->pushCriteria(new Criterias\Text('Number of Employees')); }); $chart->pushSubset('legend', function($legend){ $legend->pushCriteria(new Criterias\Layout('vertical')); $legend->pushCriteria(new Criterias\Align('right')); $legend->pushCriteria(new Criterias\VerticalAlign('middle')); }); $chart->pushSubset('plotOptions.series', function($plotOptions){ $plotOptions->pushCriteria(new Criterias\PointStart(2010)); }); $chart->pushSubset('series', function($series){ $series->pushCriteria(new Criterias\Name('Installation')); $series->pushCriteria(new Criterias\Data([43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175])); }); $chartSolarEmployment = $chart->render();
<script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/highcharts-more.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id='chart'></div> <script type="text/javascript"> $(function () { $('chart').highcharts({{$chartSolarEmployment}}); }); </script>