PHP Classes

File: src/Graph/Bar.php

Recommend this page to a friend!
  Packages of Joseluis Laso   PHP Stats Graphs   src/Graph/Bar.php   Download  
File: src/Graph/Bar.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Stats Graphs
Generate SVG charts from sample data
Author: By
Last change:
Date: 10 years ago
Size: 711 bytes
 

 

Contents

Class file image Download
<?php

namespace JLaso\SimpleStats\Graph;

class Bar extends BaseGraph
{
    public function getGraphType()
    {
        return 'BarGraph';
    }

    public function getSettings($settings = array())
    {
        return array_merge($settings,
            array(
                'back_colour' => '#eee', 'stroke_colour' => '#000',
            )
        );
    }

    protected function genValues($data)
    {
        $values = array();

        foreach($data as $eventName=>$eventData) {
            if(count($eventData) > 0) {
                foreach ($eventData as $item) {
                    $values[$eventName][] = $item['count'];
                }
            }
        }

        return $values;
    }
}