Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

#Phighcharts Project Build Status SensioLabsInsight A PHP (Requires PHP 5.3) library for the Highcharts JavaScript charting library


composer require "catchamonkey/phighcharts"

##What does it do? Along with providing a nice OO interface to create your charts, it also extends the functionality by adding such useful tools as "Sticky Keys"

###Sticky Keys A sticky key, is a configuration option that allows you to always use the same colour for certain keys. For example, you may want to always use green for apples when charting apples vs oranges.

##Example Pie Chart


    use Phighchart\Chart;
    use Phighchart\Options\Container;
    use Phighchart\Options\ExtendedContainer;
    use Phighchart\Data;
    use Phighchart\Renderer\Pie;
    use Phighchart\Renderer\Line;

    $extOptions = new ExtendedContainer();
    $extOptions->setStickyColour('apples', '#629632');
    $extOptions->setStickyColour('oranges', '#CD3700');

    $options = new Container('chart');

    $titleOptions = new Container('title');
    $titleOptions->setText('Monthly Details');

    $data = new Data();
        ->addCount('Apples', 32)
        ->addCount('Oranges', 68)
        ->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18

    // put it all together
    $chart  = new Chart();
        ->setRenderer(new Pie());

    // a line chart is similar, and our data container holds series data for this
    $lineChart = clone $chart;
    $options = new Container('chart');
    $lineChart->addOptions($options)->setRenderer(new Line());

    // and render in the template
    // or to change the element rendered
    // $chart->renderContainer('span');

    // and for the line

for rendering the labels as datetime format, provide an instance of the format class. Note: Phighchart uses the Linear format by default


    use Phighchart\Format\Datetime;

    //set up chart and chart data
    $dateTimeFormat = new Datetime();


The Datetime formatter will now attempt to parse the chart data keys as DateTime objects. The Datetime format class can parse the standard PHP date time string formats out-of-the-box.


For parsing custom date time string formats, provide the datetime string pattern to the Phighchart Datetime format class as follows:


    use Phighchart\Format\Datetime;

    //set up chart and chart data
    $dateTimeFormat = new Datetime();
    //for parsing date time string of pattern "1st August, 2012 12:09:32"
    $dateTimeFormat->setDateTimeFormat('jS F, Y H:i:s');


##Unit Tests

You can run the Unit Test suite with;

phpunit -c . tests/


PHP interface for the Highcharts JavaScript charting library




No packages published