phpro/zf-charts

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v0.1.0) of this package.

A chart abstraction layer for ZF.

v0.1.0 2014-10-16 10:53 UTC

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:

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,
]); ?>