Index: Series.class.php =================================================================== --- Series.class.php (revision 6456) +++ Series.class.php (working copy) @@ -13,7 +13,8 @@ class Series extends Object { var $name = '', - $values = array(); + $values = array(), + $labels = array(); // Used for displaying other values than used to calculate graph /** * Constructor @@ -22,9 +23,10 @@ * @param string name * @param float[] values default array() */ - function __construct($name, $values= array()) { + function __construct($name, $values= array(), $labels= array()) { $this->name= $name; $this->values= $values; + $this->labels= $labels; } /** @@ -36,5 +38,15 @@ function add($f) { $this->values[]= $f; } + + /** + * Adds a Label to this series + * + * @access public + * @param string l + */ + function addLabel($l) { + $this->labels[]= $l; + } } ?> Index: renderer/ImageRenderer.class.php =================================================================== --- renderer/ImageRenderer.class.php (revision 6456) +++ renderer/ImageRenderer.class.php (working copy) @@ -370,8 +370,8 @@ $py[$i], $colors[$j % sizeof($colors)]->handle ); - $py[$i] -= $h; - $v[$i] += $bc->series[$j]->values[$i]; + $py[$i]-= $h; + $v[$i]+= $bc->series[$j]->values[$i]; if ($bc->getDisplayValues() && ($j == $seriesCount -1)) { imagestring( $img->handle, @@ -393,12 +393,13 @@ $colors[$j % sizeof($colors)]->handle ); if ($bc->getDisplayValues()) { + $displayValue= $bc->displayValueOf($j, $i); imagestring( $img->handle, $font, - $offset + ($barWidth - $fontw * strlen($bc->series[$j]->values[$i])) / 2, + $offset + ($barWidth - $fontw * strlen($displayValue)) / 2, ($h < 0 ? $zero : $zero - $h) - $fonth - 5, - $bc->series[$j]->values[$i], + $displayValue, $axisColor->handle ); } @@ -518,12 +519,13 @@ $colors[$j % sizeof($colors)]->handle ); if ($lc->getDisplayValues()) { + $displayValue= $lc->displayValueOf($j, $i); imagestring( $img->handle, $font, - $offset + ($fontw * strlen($lc->series[$j]->values[$i])) / 2, + $offset + ($fontw * strlen($displayValue)) / 2, $zero - $h - $fonth - 5, - $lc->series[$j]->values[$i], + $displayValue, $axisColor->handle ); } @@ -596,12 +598,13 @@ IMG_ARC_PIE ); if ($pc->getDisplayValues()) { + $displayValue= $pc->displayValueOf(0, $i); imagestring( $img->handle, $font, - $middleX + $insetX + sin($angle) * $innerWidth / 3 - strlen($pc->series[0]->values[$i]) * $fontw / 2, + $middleX + $insetX + sin($angle) * $innerWidth / 3 - strlen($displayValue) * $fontw / 2, $middleY + $insetY + cos($angle) * $innerHeight / 3 - $fonth / 2, - $pc->series[0]->values[$i], + $displayValue, $axisColor->handle ); } Index: Chart.class.php =================================================================== --- Chart.class.php (revision 6456) +++ Chart.class.php (working copy) @@ -35,9 +35,9 @@ */ class Chart extends Object { var - $series = array(), - $colors = array(), - $theme = array( + $series = array(), + $colors = array(), + $theme = array( 'background' => '#ffffff', 'chartback' => '#efefef', 'sample' => '#990000', @@ -46,10 +46,11 @@ 'legend' => '#444444', 'legendback' => '#ffffff' ), - $gridlines = FALSE, - $labels = array(), - $displeg = FALSE, - $dispval = FALSE; + $gridlines = FALSE, + $labels = array(), + $displeg = FALSE, + $dispval = FALSE, + $dispcustomval = FALSE; /** * Add a series of data @@ -74,6 +75,19 @@ } /** + * Returns the display-value used by ImageRenderer to display the + * value if custom value labels are requested by setting + * setDisplayCustomValues(TRUE) we return the value labels. + * + * @access public + * @param int j which series we want to use + * @param int i which value should be returned + */ + function displayValueOf($j, $i) { + return $this->dispcustomval ? $this->series[$j]->labels[$i] : $this->series[$j]->values[$i]; + } + + /** * Set a color for a specified key * * @access public @@ -176,7 +190,27 @@ $this->dispval= $bool; } + /** + * Returns flag to display custom values + * + * @access public + * @return bool + */ + function getDisplayCustomValues() { + return $this->dispcustomval; + } + + /** + * Sets flag to display custom values + * + * @access public + * @param bool dispcustomval The flag + */ + function setDisplayCustomValues($dispcustomval) { + $this->dispcustomval= $dispcustomval; + } + /** * Returns the number of elements in the longest series * * @access public