| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* ApacheBench open flash chart implementation.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* ABChart
|
| 11 |
*
|
| 12 |
* This implementation of open_flash_chart_api simply provides
|
| 13 |
* unification between all ApacheBench charts, offering common colors,
|
| 14 |
* rendering, markup, settings etc.
|
| 15 |
*/
|
| 16 |
class ABChart extends open_flash_chart_api {
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Chart ID.
|
| 20 |
*
|
| 21 |
* @var string
|
| 22 |
*/
|
| 23 |
public $id;
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Primary color.
|
| 27 |
*
|
| 28 |
* @var string
|
| 29 |
*/
|
| 30 |
public $color_primary = 'adda01';
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Secondary color.
|
| 34 |
*
|
| 35 |
* @var string
|
| 36 |
*/
|
| 37 |
public $color_secondary = '484848';
|
| 38 |
|
| 39 |
/**
|
| 40 |
* Tertiary color.
|
| 41 |
*
|
| 42 |
* @var string
|
| 43 |
*/
|
| 44 |
public $color_tertiary = 'd2e8f5';
|
| 45 |
|
| 46 |
/**
|
| 47 |
* Default opacity.
|
| 48 |
*
|
| 49 |
* @var int
|
| 50 |
*/
|
| 51 |
public $opacity = 75;
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Size class available to style sheets.
|
| 55 |
*
|
| 56 |
* @var int
|
| 57 |
*/
|
| 58 |
public $size_class = 'large';
|
| 59 |
|
| 60 |
/**
|
| 61 |
* Constructor.
|
| 62 |
*
|
| 63 |
* @param string $id
|
| 64 |
* Unique identifier for this chart.
|
| 65 |
*
|
| 66 |
* @param string $title
|
| 67 |
* (optional) Title for this chart.
|
| 68 |
*
|
| 69 |
* @param string $style
|
| 70 |
* (optional) Style of chart.
|
| 71 |
*
|
| 72 |
* @param string $size
|
| 73 |
* (optional) Size of chart which can be styled
|
| 74 |
* with a style sheet.
|
| 75 |
*/
|
| 76 |
public function __construct($id, $title = '', $style = 'normal', $size = 'large') {
|
| 77 |
$this->id = $id;
|
| 78 |
$this->size_class = $size;
|
| 79 |
parent::open_flash_chart_api();
|
| 80 |
|
| 81 |
// Set title
|
| 82 |
if (!empty($title)){
|
| 83 |
$this->set_title($title);
|
| 84 |
}
|
| 85 |
|
| 86 |
// Invoke style method
|
| 87 |
$style_method = "_style_{$style}";
|
| 88 |
if (method_exists($this, $style_method)){
|
| 89 |
call_user_method($style_method, $this);
|
| 90 |
}
|
| 91 |
}
|
| 92 |
|
| 93 |
/* -----------------------------------------------------------------
|
| 94 |
|
| 95 |
Public methods
|
| 96 |
|
| 97 |
------------------------------------------------------------------ */
|
| 98 |
|
| 99 |
/**
|
| 100 |
* Get chart markup.
|
| 101 |
*
|
| 102 |
* @return string
|
| 103 |
*/
|
| 104 |
public function render() {
|
| 105 |
return '<div id="ab-chart-' . $this->id . '" class="ab-chart size-' . $this->size_class . '">' . parent::render() . '</div>';
|
| 106 |
}
|
| 107 |
|
| 108 |
/* -----------------------------------------------------------------
|
| 109 |
|
| 110 |
Styles
|
| 111 |
|
| 112 |
------------------------------------------------------------------ */
|
| 113 |
|
| 114 |
/**
|
| 115 |
* Normal style.
|
| 116 |
*
|
| 117 |
* @since 0.1
|
| 118 |
*/
|
| 119 |
private function _style_normal() {
|
| 120 |
$this->title_style = '{ font-size: 14; color: #' . $this->color_secondary . '; }';
|
| 121 |
$this->set_width(750);
|
| 122 |
$this->set_bg_colour('ffffff');
|
| 123 |
$this->set_x_axis_colour('ffffff', 'ffffff');
|
| 124 |
$this->set_y_axis_colour($this->color_tertiary, $this->color_tertiary);
|
| 125 |
}
|
| 126 |
}
|