phpro / zf-charts
A chart abstraction layer for ZF.
Installs: 1 279
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 1
Open Issues: 0
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
Repository abandoned 2020-11-27
This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore.
Charts
This package provides a PHP abstraction layer for multiple javascript chart libraries for Zend Framework 2. At the moment, following libraries are supported:
- Chart.js (Lines, Doughnuts)
Installation
curl -s https://getcomposer.org/installer | php
php composer.phar install
Module Installation
Add to composer.json
"phpro/zf-charts": "~0.1"
Add module to application.config.php
return array( 'modules' => array( 'AssetManager', 'Phpro\Chart', // other libs... ), // Other config );
ChartJS
The API of the PHP library works exactly the same as the javascript API. More information about the configurable options can be found in the official documentation
Line chart
$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);
Doughnut chart
$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);
View Helper
<?php echo $this->chartjs($this->chart, [ 'show_legend' => true, 'width' => 900, 'height' => 400, ]); ?>