diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-09-19 13:29:02 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-09-19 13:29:02 +0000 |
commit | fe13be6dac3b9a019cd4ee7a4e1b3272ef922871 (patch) | |
tree | 3ac7e934fb907911583e4bd4c48aec7dc12bde95 /src/options | |
parent | 27cffe45cdf9cc6d36751bcc998459ae9d8a1f4b (diff) | |
download | zetacomponents-graph-fe13be6dac3b9a019cd4ee7a4e1b3272ef922871.zip zetacomponents-graph-fe13be6dac3b9a019cd4ee7a4e1b3272ef922871.tar.gz |
- Added background and border to font configuration
- Show value for highlighted datapoints in bar and line charts
Diffstat (limited to 'src/options')
-rw-r--r-- | src/options/font.php | 50 | ||||
-rw-r--r-- | src/options/line_chart.php | 65 | ||||
-rw-r--r-- | src/options/svg_driver.php | 2 |
3 files changed, 114 insertions, 3 deletions
diff --git a/src/options/font.php b/src/options/font.php index 2da92ad..f746f73 100644 --- a/src/options/font.php +++ b/src/options/font.php @@ -19,7 +19,6 @@ * - TTF_FONT Native TTF fonts * - PS_FONT PostScript Type1 fonts * - FT2_FONT FreeType 2 fonts - * - GD_FONT Native GD bitmap fonts * @property float $minFontSize * Minimum font size for displayed texts. * @property float $maxFontSize @@ -30,6 +29,18 @@ * Font color. * @property float $lineSpacing * Percent of font size used for line spacing + * @property ezcGraphColor $background + * Background color + * @property ezcGraphColor $border + * Border color + * @property int $borderWidth + * Border width + * @property int $padding + * Padding between text and border + * @property bool $minimizeBorder + * Fit the border exactly around the text, or use the complete + * possible space. + * * * @package Graph */ @@ -54,6 +65,12 @@ class ezcGraphFontOptions extends ezcBaseOptions $this->properties['lineSpacing'] = .1; $this->properties['color'] = ezcGraphColor::fromHex( '#000000' ); + $this->properties['background'] = false; + $this->properties['border'] = false; + $this->properties['borderWidth'] = 1; + $this->properties['padding'] = 0; + $this->properties['minimizeBorder'] = true; + parent::__construct( $options ); } @@ -93,6 +110,37 @@ class ezcGraphFontOptions extends ezcBaseOptions throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphColor' ); } break; + + case 'background': + if ( $propertyValue instanceof ezcGraphColor ) + { + $this->properties['background'] = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphColor' ); + } + break; + case 'border': + if ( $propertyValue instanceof ezcGraphColor ) + { + $this->properties['border'] = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphColor' ); + } + break; + case 'borderWidth': + $this->properties['borderWidth'] = (int) $propertyValue; + break; + case 'padding': + $this->properties['padding'] = (int) $propertyValue; + break; + case 'minimizeBorder': + $this->properties['minimizeBorder'] = (bool) $propertyValue; + break; + case 'name': if ( is_string( $propertyValue ) ) { diff --git a/src/options/line_chart.php b/src/options/line_chart.php index 358f82a..c8eadb5 100644 --- a/src/options/line_chart.php +++ b/src/options/line_chart.php @@ -18,6 +18,13 @@ * - (int) Opacity used to fill up the space with the lines color. * @property int $symbolSize * Size of symbols in line chart. + * @property ezcGraphFontOptions $highlightFont + * Font configuration for highlight tests + * @property int $highlightSize + * Size of highlight blocks + * @property bool $highlightLines + * If true, it adds lines to highlight the values position on the + * axis. * * @package Graph */ @@ -35,7 +42,11 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions $this->properties['lineThickness'] = 2; $this->properties['fillLines'] = false; $this->properties['symbolSize'] = 8; - + $this->properties['highlightFont'] = new ezcGraphFontOptions(); + $this->properties['highlightFontCloned'] = false; + $this->properties['highlightSize'] = 14; + $this->properties['highlightLines'] = false; + parent::__construct( $options ); } @@ -68,10 +79,62 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions case 'symbolSize': $this->properties['symbolSize'] = max( 1, (int) $propertyValue ); break; + case 'highlightFont': + if ( $propertyValue instanceof ezcGraphFontOptions ) + { + $this->properties['highlightFont'] = $propertyValue; + } + elseif ( is_string( $propertyValue ) ) + { + if ( !$this->properties['highlightFontCloned'] ) + { + $this->properties['highlightFont'] = clone $this->font; + $this->properties['highlightFontCloned'] = true; + } + + $this->properties['highlightFont']->font = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyValue, 'ezcGraphFontOptions' ); + } + break; + case 'highlightSize': + $this->properties['highlightSize'] = max( 1, (int) $propertyValue ); + break; + case 'highlightLines': + $this->properties['highlightLines'] = (bool) $propertyValue; + break; default: return parent::__set( $propertyName, $propertyValue ); } } + + /** + * __get + * + * @param mixed $propertyName + * @throws ezcBasePropertyNotFoundException + * If a the value for the property options is not an instance of + * @return mixed + * @ignore + */ + public function __get( $propertyName ) + { + switch ( $propertyName ) + { + case 'highlightFont': + // Clone font configuration when requested for this element + if ( !$this->properties['highlightFontCloned'] ) + { + $this->properties['highlightFont'] = clone $this->properties['font']; + $this->properties['highlightFontCloned'] = true; + } + return $this->properties['highlightFont']; + default: + return parent::__get( $propertyName ); + } + } } ?> diff --git a/src/options/svg_driver.php b/src/options/svg_driver.php index 4a83ca4..53d73d8 100644 --- a/src/options/svg_driver.php +++ b/src/options/svg_driver.php @@ -57,7 +57,7 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions */ public function __construct( array $options = array() ) { - $this->properties['assumedCharacterWidth'] = .55; + $this->properties['assumedCharacterWidth'] = .55; // @TODO .6 seems to fit better $this->properties['strokeLineJoin'] = 'round'; $this->properties['strokeLineCap'] = 'round'; $this->properties['shapeRendering'] = 'geometricPrecision'; |