diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-11-02 09:05:43 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-11-02 09:05:43 +0000 |
commit | 39d55ef60b9074920a1a3fc3d0c0f8d51f303760 (patch) | |
tree | d6a24afb29f1448f051e2446f87143a8b844dc6f /src/options | |
parent | 5532c0542f6a370378102f34ec9b10e8d9533915 (diff) | |
download | zetacomponents-graph-39d55ef60b9074920a1a3fc3d0c0f8d51f303760.zip zetacomponents-graph-39d55ef60b9074920a1a3fc3d0c0f8d51f303760.tar.gz |
- Implemented #009304: Possibility to format labels via callback
Diffstat (limited to 'src/options')
-rw-r--r-- | src/options/pie_chart.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/options/pie_chart.php b/src/options/pie_chart.php index 104bc5a..5974a2d 100644 --- a/src/options/pie_chart.php +++ b/src/options/pie_chart.php @@ -15,6 +15,10 @@ * %$1s Name of pie * %2$d Value of pie * %3$.1f Percentage + * @property callback $labelCallback + * Callback function to format pie chart labels. + * Function will receive 3 parameters: + * string function( label, value, percent ) * @property float $sum * Fixed sum of values. This should be used for incomplete pie * charts. @@ -40,6 +44,7 @@ class ezcGraphPieChartOptions extends ezcGraphChartOptions public function __construct( array $options = array() ) { $this->properties['label'] = '%1$s: %2$d (%3$.1f%%)'; + $this->properties['labelCallback'] = null; $this->properties['sum'] = false; $this->properties['percentTreshHold'] = .0; @@ -66,6 +71,16 @@ class ezcGraphPieChartOptions extends ezcGraphChartOptions case 'label': $this->properties['label'] = (string) $propertyValue; break; + case 'labelCallback': + if ( is_string( $propertyValue ) && function_exists( $propertyValue ) ) + { + $this->properties['labelCallback'] = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'callback function' ); + } + break; case 'sum': $this->properties['sum'] = (float) $propertyValue; break; |