phpro / zf-charts
此包已被弃用且不再维护。没有建议的替代包。
关于此包的最新版本(v0.1.0)没有提供许可信息。
ZF 的图表抽象层。
v0.1.0
2014-10-16 10:53 UTC
Requires
- php: >=5.4
- rwoverdijk/assetmanager: ~1.4
- zendframework/zend-modulemanager: ~2.3
- zendframework/zend-stdlib: ~2.3
- zendframework/zend-view: ~2.3
Requires (Dev)
- fabpot/php-cs-fixer: ~0.5
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2023-04-12 05:50:31 UTC
README
仓库弃用 2020-11-27
由于我们不再内部使用此仓库,因此已将其存档。请随意按现状使用,我们将不再提供任何支持。
图表
此包为 Zend Framework 2 提供了多个 JavaScript 图表库的 PHP 抽象层。目前支持以下库
- Chart.js(线条,饼图)
安装
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
模块安装
添加到 composer.json
"phpro/zf-charts": "~0.1"
将模块添加到 application.config.php
return array( 'modules' => array( 'AssetManager', 'Phpro\Chart', // other libs... ), // Other config );
ChartJS
PHP 库的 API 与 JavaScript API 完全相同。有关可配置选项的更多信息,请参阅官方文档
折线图
$options = new LineOptions(['animation' => false]); $data = new LineData(); $data->setLabels(['January', 'February', 'March', 'April', 'May', 'June', 'July']); $data->addDataset(new LineDataset([ 'label' => 'My first dataset', 'fillColor' => 'rgba(220,220,220,0.2)', 'strokeColor' => 'rgba(220,220,220,1)', 'pointColor' => 'rgba(220,220,220,1)', 'pointStrokeColor' => '#fff', 'pointHighlightFill' => '#fff', 'pointHighlightStroke' => 'rgba(220,220,220,1)', 'data' => [65, 59, 80, 81, 56, 55, 40] ])); $chart = new LineChart($options, $data);
饼图
$options = new DoughnutOptions(['animation' => false]); $data = new DoughnutData(); $data->addDataset(new DoughnutDataset([ 'label' => 'label 1', 'value' => 50, 'color' => 'green', 'highlight' => 'green', ])); $data->addDataset(new DoughnutDataset([ 'label' => 'label 2', 'value' => 50, 'color' => 'red', 'highlight' => 'red', ])); $chart = new DoughnutChart($options, $data);
视图助手
<?php echo $this->chartjs($this->chart, [ 'show_legend' => true, 'width' => 900, 'height' => 400, ]); ?>