2017 © Pedro Peláez
 

library pchart-bundle

PHP class oriented framework designed to create charts

image

stocarul/pchart-bundle

PHP class oriented framework designed to create charts

  • Tuesday, June 25, 2013
  • by stocarul
  • Repository
  • 0 Watchers
  • 0 Stars
  • 4,005 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

README

The pChart Bundle for Symfony 2.x gives you the possibility to use the pChart library for all your charting needs., (*1)

This is an initial release and supports the rendering of all chart types. Small modification has been made to the latest release of the pChart library, since it didn't play very nicely together with Symfony 2.x and PHP5.3. pChart caching is not tested at this point., (*2)

This Bundle can be downloaded from https://github.com/rbakels/pChartBundle , but you already knew that., (*3)

License

See the LICENSE file included with this bundle., (*4)

Author

Robin Bakels (robin@xlab.nl). Software Engineer for the Dutch company Xlab B.V.. See: http://www.xlab.nl/ for more information, (*5)

Installation

Installation is quick and easy, 2 steps process:, (*6)

  1. Install XlabpChartBundle
  2. Enable the bundle

Step 1: Install xLabpChartBundle

Add the following dependency to your composer.json file: ``` json { "require": { "_some_packages": "...",, (*7)

    "stocarul/pchart-bundle": "dev-master"
}

}, (*8)


### Step 2: Enable the bundle Finally, enable the bundle in the kernel: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Xlab\pChartBundle\XlabpChartBundle(), ); }

Optionally, you can add the following to your routing.yml:, (*9)

pChart:
  resource: "@XlabpChartBundle/Resources/config/routing_pChart.yml"
  prefix:   /pChart

This gives you the possibility to a small live preview of some examples, originally released with the pChart source. The list of examples, after inclusion of the routing_pChart.yml file gives you access to the following URL:, (*10)

http://<your_hostname>/pChart/index

How to use this bundle?

There are probably more then one way to use this. Currently, I'm quite fond of generating the chart image inside a Controller action and calling this method from your Twig template file within an tag., (*11)

  1. Add a routing to your routing.yml, where you want to render the chart image from.
  2. Include the proper namespaces. The names are taken from the original files (e.g. pPie.class.php is within the Xlab\pChartBundle\pPie namespace)
  3. Create the controller method.
  4. Add the following code, after all the pChart specific calls:

Example:, (*12)

<?php
namespace Xlab\pChartBundle\Controller;

use Xlab\pChartBundle\pData;
use Xlab\pChartBundle\pDraw;
use Xlab\pChartBundle\pPie;
use Xlab\pChartBundle\pImage;
use Xlab\pChartBundle\pBarcode39;
use Xlab\pChartBundle\pBarcode128;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class ExamplesController extends Controller
{
    public function exampleAction()
    {
        $response = new Response();
        $response->headers->set('Content-Type', 'image/png');

        /* pChart stuff goes here */
        ...

        /* Capture output and return the response */
        ob_start();
        $chart->autoOutput();
        $response->setContent(ob_get_clean());

        return $respone;
    }
}

In the above example, the $chart variable is an instance of a pImage class., (*13)

See also: Xlab/pChartBundle/Controller/ExamplesController.php, (*14)

Changelog

16 March 2012:, (*15)

  • Initial release

The Versions

25/06 2013

dev-master

9999999-dev http://www.pchart.net

PHP class oriented framework designed to create charts

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.3