EZ-Components

This commit is contained in:
Andreas Österreicher
2009-02-17 15:27:43 +00:00
parent 359c3c55c9
commit 0a8e90a8b3
572 changed files with 64490 additions and 0 deletions
@@ -0,0 +1,100 @@
<?php
/**
* File containing the ezcGraphCairoDriverOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended options for the SVG driver.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->background->color = '#FFFFFFFF';
* $graph->title = 'Access statistics';
* $graph->legend = false;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->driver = new ezcGraphCairoDriver();
*
* // No options yet.
*
* $graph->render( 400, 200, 'tutorial_driver_cairo.png' );
* </code>
*
* @property float $imageMapResolution
* Degree step used to interpolate round image primitives by
* polygons for image maps
* @property float $circleResolution
* Resolution for circles, until I understand how to draw ellipses
* with SWFShape::curveTo()
*
* @version 1.3
* @package Graph
*/
class ezcGraphCairoDriverOptions extends ezcGraphDriverOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['imageMapResolution'] = 10;
$this->properties['circleResolution'] = 2.;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'imageMapResolution':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['imageMapResolution'] = (int) $propertyValue;
break;
case 'circleResolution':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue <= 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['circleResolution'] = (float) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
break;
}
}
}
?>
@@ -0,0 +1,107 @@
<?php
/**
* File containing the ezcGraphChartOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic options for charts.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzBlue();
* $graph->title = 'Access statistics';
*
* // Global font options
* $graph->options->font->name = 'serif';
*
* // Special font options for sub elements
* $graph->title->background = '#EEEEEC';
* $graph->title->font->name = 'sans-serif';
*
* $graph->options->font->maxFontSize = 8;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->render( 400, 150, 'tutorial_chart_title.svg' );
* </code>
*
* @property int $width
* Width of the chart.
* @property int $height
* Height of the chart.
* @property ezcGraphFontOptions $font
* Font used in the graph.
*
* @version 1.3
* @package Graph
*/
class ezcGraphChartOptions extends ezcBaseOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['width'] = null;
$this->properties['height'] = null;
$this->properties['font'] = new ezcGraphFontOptions();
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'width':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['width'] = (int) $propertyValue;
break;
case 'height':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['height'] = (int) $propertyValue;
break;
case 'font':
$this->properties['font']->path = $propertyValue;
break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
break;
}
}
}
?>
@@ -0,0 +1,157 @@
<?php
/**
* File containing the ezcGraphDriverOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic driver options.
*
* <code>
* require_once 'tutorial_autoload.php';
*
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzBlue();
* $graph->title = 'Access statistics';
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->driver->options->autoShortenString = false;
*
* $graph->render( 400, 150, 'tutorial_chart_title.svg' );
* </code>
*
* @property int $width
* Width of the chart.
* @property int $height
* Height of the chart.
* @property float $shadeCircularArc
* Percent to darken circular arcs at the sides
* @property float $lineSpacing
* Percent of font size used for line spacing
* @property int $font
* Font used in the graph.
* @property bool $autoShortenString
* Automatically shorten string if it does not fit into a box
* @property string $autoShortenStringPostFix
* String to append to shortened strings, if there is enough space
*
* @version 1.3
* @package Graph
*/
abstract class ezcGraphDriverOptions extends ezcBaseOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['width'] = null;
$this->properties['height'] = null;
$this->properties['lineSpacing'] = .1;
$this->properties['shadeCircularArc'] = .5;
$this->properties['font'] = new ezcGraphFontOptions();
$this->properties['font']->color = ezcGraphColor::fromHex( '#000000' );
$this->properties['autoShortenString'] = true;
$this->properties['autoShortenStringPostFix'] = '..';
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'width':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['width'] = (int) $propertyValue;
break;
case 'height':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['height'] = (int) $propertyValue;
break;
case 'lineSpacing':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties['lineSpacing'] = (float) $propertyValue;
break;
case 'shadeCircularArc':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties['shadeCircularArc'] = (float) $propertyValue;
break;
case 'font':
if ( $propertyValue instanceof ezcGraphFontOptions )
{
$this->properties['font'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
}
break;
case 'autoShortenString':
if ( is_bool( $propertyValue ) )
{
$this->properties['autoShortenString'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'boolean' );
}
break;
case 'autoShortenStringPostFix':
$this->properties['autoShortenStringPostFix'] = (string) $propertyValue;
break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
break;
}
}
}
?>
@@ -0,0 +1,103 @@
<?php
/**
* File containing the ezcGraphFlashDriverOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended configuration options for the flash driver.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->title = 'Access statistics';
* $graph->legend = false;
*
* $graph->driver = new ezcGraphFlashDriver();
* $graph->driver->options->compresion = 0;
*
* $graph->options->font = 'tutorial_font.fdb';
*
* $graph->driver->options->compression = 7;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->render( 400, 200, 'tutorial_driver_flash.swf' );
* </code>
*
* @property int $compression
* Compression level used for generated flash file
* @see http://php.net/manual/en/function.swfmovie.save.php
* @property float $circleResolution
* Resolution for circles, until I understand how to draw ellipses
* with SWFShape::curveTo()
*
* @version 1.3
* @package Graph
*/
class ezcGraphFlashDriverOptions extends ezcGraphDriverOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['compression'] = 9;
$this->properties['circleResolution'] = 2.;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'compression':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 9 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' );
}
$this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) );
break;
case 'circleResolution':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue <= 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['circleResolution'] = (float) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
break;
}
}
}
?>
@@ -0,0 +1,292 @@
<?php
/**
* File containing the ezcGraphFontOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the options for font configuration.
*
* Global font settings will only affect the font settings of chart elements
* until they were modified once. Form then on the font configuration of one
* chart element has been copied and can only be configured independently.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzBlue();
* $graph->title = 'Access statistics';
*
* $graph->options->font->name = 'serif';
* $graph->options->font->maxFontSize = 12;
*
* $graph->title->background = '#EEEEEC';
* $graph->title->font->name = 'sans-serif';
*
* $graph->options->font->maxFontSize = 8;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->render( 400, 150, 'tutorial_chart_title.svg' );
* </code>
*
* @property string $name
* Name of font.
* @property string $path
* Path to font file.
* @property int $type
* Type of used font. May be one of the following:
* - TTF_FONT Native TTF fonts
* - PS_FONT PostScript Type1 fonts
* - FT2_FONT FreeType 2 fonts
* @property float $minFontSize
* Minimum font size for displayed texts.
* @property float $maxFontSize
* Maximum font size for displayed texts.
* @property float $minimalUsedFont
* The minimal used font size for this element.
* @property ezcGraphColor $color
* Font color.
* @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.
* @property bool $textShadow
* Draw shadow for texts
* @property int $textShadowOffset
* Offset for text shadow
* @property ezcGraphColor $textShadowColor
* Color of text shadow. If false the inverse color of the text
* color will be used.
*
* @version 1.3
* @package Graph
*/
class ezcGraphFontOptions extends ezcBaseOptions
{
/**
* Indicates if path already has been checked for correct font
*
* @var bool
*/
protected $pathChecked = false;
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['name'] = 'sans-serif';
// $this->properties['path'] = 'Graph/tests/data/font.ttf';
$this->properties['path'] = '';
$this->properties['type'] = ezcGraph::TTF_FONT;
$this->properties['minFontSize'] = 6;
$this->properties['maxFontSize'] = 96;
$this->properties['minimalUsedFont'] = 96;
$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;
$this->properties['textShadow'] = false;
$this->properties['textShadowOffset'] = 1;
$this->properties['textShadowColor'] = false;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'minFontSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 1' );
}
// Ensure min font size is smaller or equal max font size.
if ( $propertyValue > $this->properties['maxFontSize'] )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float <= ' . $this->properties['maxFontSize'] );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'maxFontSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 1' );
}
// Ensure max font size is greater or equal min font size.
if ( $propertyValue < $this->properties['minFontSize'] )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float >= ' . $this->properties['minFontSize'] );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'minimalUsedFont':
$propertyValue = (float) $propertyValue;
if ( $propertyValue < $this->minimalUsedFont )
{
$this->properties['minimalUsedFont'] = $propertyValue;
}
break;
case 'color':
case 'background':
case 'border':
case 'textShadowColor':
$this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
case 'borderWidth':
case 'padding':
case 'textShadowOffset':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'minimizeBorder':
case 'textShadow':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties[$propertyName] = (bool) $propertyValue;
break;
case 'name':
if ( is_string( $propertyValue ) )
{
$this->properties['name'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'string' );
}
break;
case 'path':
if ( is_file( $propertyValue ) && is_readable( $propertyValue ) )
{
$this->properties['path'] = realpath( $propertyValue );
$parts = pathinfo( $this->properties['path'] );
switch ( strtolower( $parts['extension'] ) )
{
case 'fdb':
$this->properties['type'] = ezcGraph::PALM_FONT;
break;
case 'pfb':
$this->properties['type'] = ezcGraph::PS_FONT;
break;
case 'ttf':
$this->properties['type'] = ezcGraph::TTF_FONT;
break;
case 'svg':
$this->properties['type'] = ezcGraph::SVG_FONT;
$this->properties['name'] = ezcGraphSvgFont::getFontName( $propertyValue );
break;
default:
throw new ezcGraphUnknownFontTypeException( $propertyValue, $parts['extension'] );
}
$this->pathChecked = true;
}
else
{
throw new ezcBaseFileNotFoundException( $propertyValue, 'font' );
}
break;
case 'type':
if ( is_int( $propertyValue ) )
{
$this->properties['type'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int' );
}
break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
break;
}
}
/**
* __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 'textShadowColor':
// Use inverted font color if false
if ( $this->properties['textShadowColor'] === false )
{
$this->properties['textShadowColor'] = $this->properties['color']->invert();
}
return $this->properties['textShadowColor'];
case 'path':
if ( $this->pathChecked === false )
{
// Enforce call of path check
$this->__set( 'path', $this->properties['path'] );
}
// No break to use parent return
default:
return parent::__get( $propertyName );
}
}
}
?>
@@ -0,0 +1,181 @@
<?php
/**
* File containing the ezcGraphDriverOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended driver options for the gd driver.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzGreen();
* $graph->title = 'Access statistics';
* $graph->legend = false;
*
* $graph->driver = new ezcGraphGdDriver();
* $graph->options->font = 'tutorial_font.ttf';
*
* // Generate a Jpeg with lower quality. The default settings result in a better
* // quality image
* $graph->driver->options->supersampling = 1;
* $graph->driver->options->jpegQuality = 100;
* $graph->driver->options->imageFormat = IMG_JPEG;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->render( 400, 200, 'tutorial_dirver_gd.jpg' );
* </code>
*
* @property int $imageFormat
* Type of generated image.
* Should be one of those: IMG_PNG, IMG_JPEG
* @property int $jpegQuality
* Quality of generated jpeg
* @property int $detail
* Count of degrees to render one polygon for in circular arcs
* @property int $supersampling
* Factor of supersampling used to simulate antialiasing
* @property string $background
* Background image to put the graph on
* @property string $resampleFunction
* Function used to resample / resize images
* @property bool $forceNativeTTF
* Force use of native ttf functions instead of free type 2
* @property float $imageMapResolution
* Degree step used to interpolate round image primitives by
* polygons for image maps
*
* @version 1.3
* @package Graph
*/
class ezcGraphGdDriverOptions extends ezcGraphDriverOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['imageFormat'] = IMG_PNG;
$this->properties['jpegQuality'] = 70;
$this->properties['detail'] = 1;
$this->properties['shadeCircularArc'] = .5;
$this->properties['supersampling'] = 2;
$this->properties['background'] = false;
$this->properties['resampleFunction'] = 'imagecopyresampled';
$this->properties['forceNativeTTF'] = false;
$this->properties['imageMapResolution'] = 10;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'imageFormat':
if ( imagetypes() & $propertyValue )
{
$this->properties['imageFormat'] = (int) $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'Unsupported image type.' );
}
break;
case 'jpegQuality':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 100 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 100' );
}
$this->properties['jpegQuality'] = (int) $propertyValue;
break;
case 'detail':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['detail'] = (int) $propertyValue;
break;
case 'supersampling':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['supersampling'] = (int) $propertyValue;
break;
case 'background':
if ( $propertyValue === false ||
( is_file( $propertyValue ) && is_readable( $propertyValue ) ) )
{
$this->properties['background'] = realpath( $propertyValue );
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'readable file' );
}
break;
case 'resampleFunction':
if ( ezcBaseFeatures::hasFunction( $propertyValue ) )
{
$this->properties['resampleFunction'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'function' );
}
break;
case 'forceNativeTTF':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties['forceNativeTTF'] = (bool) $propertyValue;
break;
case 'imageMapResolution':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties['imageMapResolution'] = (int) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
break;
}
}
}
?>
@@ -0,0 +1,189 @@
<?php
/**
* File containing the ezcGraphLineChartOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic options for line charts.
*
* <code>
* $graph = new ezcGraphLineChart();
* $graph->title = 'Wikipedia articles';
*
* $graph->options->fillLines = 220;
* $graph->options->lineThickness = 3;
*
* // Add data
* foreach ( $wikidata as $language => $data )
* {
* $graph->data[$language] = new ezcGraphArrayDataSet( $data );
* }
*
* $graph->render( 400, 150, 'tutorial_line_chart.svg' );
* </code>
*
* @property float $lineThickness
* Thickness of chart lines
* @property mixed $fillLines
* Status wheather the space between line and axis should get filled.
* - FALSE to not fill the space at all.
* - (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.
* @property true $stackBars
* Stack bars
*
* @version 1.3
* @package Graph
*/
class ezcGraphLineChartOptions extends ezcGraphChartOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['lineThickness'] = 1;
$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;
$this->properties['stackBars'] = false;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'lineThickness':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'symbolSize':
case 'highlightSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'fillLines':
if ( ( $propertyValue !== false ) &&
!is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 255 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= int <= 255' );
}
$this->properties[$propertyName] = (
$propertyValue === false
? false
: (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']->path = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
}
break;
$this->properties['highlightSize'] = max( 1, (int) $propertyValue );
break;
case 'highlightLines':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties['highlightLines'] = $propertyValue;
break;
case 'stackBars':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties['stackBars'] = $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 );
}
}
}
?>
@@ -0,0 +1,113 @@
<?php
/**
* File containing the ezcGraphOdometerChartOptions class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the options for odometer charts
*
* <code>
* $graph = new ezcGraphOdoMeterChart();
*
* $graph->data['Test'] = new ezcGraphArrayDataSet( array( 0, 1, 23, 30 ) );
*
* $graph->options->odometerHeight = .3;
* $graph->options->borderColor = '#2e3436';
*
* $graph->render( 150, 50, 'odometer.svg' );
* </code>
*
* @property ezcGraphColor $borderColor
* Color of border around odometer chart
* @property int $borderWidth
* Width of border around odometer chart
* @property ezcGraphColor $startColor
* Start color of grdient used as the odometer chart background.
* @property ezcGraphColor $endColor
* End color of grdient used as the odometer chart background.
* @property int $markerWidth
* Width of odometer markers
* @property float $odometerHeight
* Height consumed by odometer chart
*
* @version 1.3
* @package Graph
*/
class ezcGraphOdometerChartOptions extends ezcGraphChartOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['borderColor'] = ezcGraphColor::create( '#000000' );
$this->properties['borderWidth'] = 0;
$this->properties['startColor'] = ezcGraphColor::create( '#4e9a06A0' );
$this->properties['endColor'] = ezcGraphColor::create( '#A40000A0' );
$this->properties['markerWidth'] = 2;
$this->properties['odometerHeight'] = 0.5;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'borderWidth':
case 'markerWidth':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'borderColor':
case 'startColor':
case 'endColor':
$this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
case 'odometerHeight':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
default:
return parent::__set( $propertyName, $propertyValue );
}
}
}
?>
@@ -0,0 +1,143 @@
<?php
/**
* File containing the ezcGraphPieChartOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic options for pie charts.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzRed();
* $graph->title = 'Access statistics';
* $graph->legend = false;
*
* $graph->options->label = '%1$s (%3$.1f)';
* $graph->options->percentThreshold = .05;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
* $graph->data['Access statistics']->highlight['Explorer'] = true;
*
* $graph->render( 400, 150, 'tutorial_pie_chart_options.svg' );
* </code>
*
* @property string $label
* String used to label pies
* %1$s 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.
* @property float $percentThreshold
* Values with a lower percentage value are aggregated.
* @property float $absoluteThreshold
* Values with a lower absolute value are aggregated.
* @property string $summarizeCaption
* Caption for values summarized because they are lower then the
* configured tresh hold.
*
* @version 1.3
* @package Graph
*/
class ezcGraphPieChartOptions extends ezcGraphChartOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
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['percentThreshold'] = .0;
$this->properties['absoluteThreshold'] = .0;
$this->properties['summarizeCaption'] = 'Misc';
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'label':
$this->properties['label'] = (string) $propertyValue;
break;
case 'labelCallback':
if ( is_callable( $propertyValue ) )
{
$this->properties['labelCallback'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'callback function' );
}
break;
case 'sum':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue <= 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['sum'] = (float) $propertyValue;
break;
case 'percentThreshold':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties['percentThreshold'] = (float) $propertyValue;
break;
case 'absoluteThreshold':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue <= 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['absoluteThreshold'] = (float) $propertyValue;
break;
case 'summarizeCaption':
$this->properties['summarizeCaption'] = (string) $propertyValue;
break;
default:
return parent::__set( $propertyName, $propertyValue );
}
}
}
?>
@@ -0,0 +1,172 @@
<?php
/**
* File containing the ezcGraphRadarChartOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic options for radar charts.
*
* <code>
* $wikidata = include 'tutorial_wikipedia_data.php';
*
* $graph = new ezcGraphRadarChart();
* $graph->title = 'Wikipedia articles';
*
* $graph->options->fillLines = 220;
*
* // Add data
* foreach ( $wikidata as $language => $data )
* {
* $graph->data[$language] = new ezcGraphArrayDataSet( $data );
* $graph->data[$language][] = reset( $data );
* }
*
* $graph->render( 400, 150, 'tutorial_radar_chart.svg' );
* </code>
*
* @property float $lineThickness
* Theickness of chart lines
* @property mixed $fillLines
* Status wheather the space between line and axis should get filled.
* - FALSE to not fill the space at all.
* - (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 $highlightRadars
* If true, it adds lines to highlight the values position on the
* axis.
*
* @version 1.3
* @package Graph
*/
class ezcGraphRadarChartOptions extends ezcGraphChartOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['lineThickness'] = 1;
$this->properties['fillLines'] = false;
$this->properties['symbolSize'] = 8;
$this->properties['highlightFont'] = new ezcGraphFontOptions();
$this->properties['highlightFontCloned'] = false;
$this->properties['highlightSize'] = 14;
$this->properties['highlightRadars'] = false;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'lineThickness':
case 'symbolSize':
case 'highlightSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'fillLines':
if ( ( $propertyValue !== false ) &&
!is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 255 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= int <= 255' );
}
$this->properties[$propertyName] = (
$propertyValue === false
? false
: (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']->path = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
}
break;
$this->properties['highlightSize'] = max( 1, (int) $propertyValue );
break;
case 'highlightRadars':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties['highlightRadars'] = $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 );
}
}
}
?>
@@ -0,0 +1,212 @@
<?php
/**
* File containing the ezcGraphRenderer2dOptions class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the basic options for renderers.
*
* <code>
* $wikidata = include 'tutorial_wikipedia_data.php';
*
* $graph = new ezcGraphBarChart();
* $graph->title = 'Wikipedia articles';
*
* // Add data
* foreach ( $wikidata as $language => $data )
* {
* $graph->data[$language] = new ezcGraphArrayDataSet( $data );
* }
*
* // $graph->renderer = new ezcGraphRenderer2d();
*
* $graph->renderer->options->barMargin = .2;
* $graph->renderer->options->barPadding = .2;
*
* $graph->renderer->options->dataBorder = 0;
*
* $graph->render( 400, 150, 'tutorial_bar_chart_options.svg' );
* </code>
*
* @property float $maxLabelHeight
* Percent of chart height used as maximum height for pie chart
* labels.
* @property bool $showSymbol
* Indicates wheather to show the line between pie elements and
* labels.
* @property float $symbolSize
* Size of symbols used to connect a label with a pie.
* @property float $moveOut
* Percent to move pie chart elements out of the middle on highlight.
* @property int $titlePosition
* Position of title in a box.
* @property int $titleAlignement
* Alignement of box titles.
* @property float $dataBorder
* Factor to darken border of data elements, like lines, bars and
* pie segments.
* @property float $barMargin
* Procentual distance between bar blocks.
* @property float $barPadding
* Procentual distance between bars.
* @property float $pieChartOffset
* Offset for starting with first pie chart segment in degrees.
* @property float $legendSymbolGleam
* Opacity of gleam in legend symbols
* @property float $legendSymbolGleamSize
* Size of gleam in legend symbols
* @property float $legendSymbolGleamColor
* Color of gleam in legend symbols
* @property float $pieVerticalSize
* Percent of vertical space used for maximum pie chart size.
* @property float $pieHorizontalSize
* Percent of horizontal space used for maximum pie chart size.
* @property float $pieChartSymbolColor
* Color of pie chart symbols
* @property float $pieChartGleam
* Enhance pie chart with gleam on top.
* @property float $pieChartGleamColor
* Color used for gleam on pie charts.
* @property float $pieChartGleamBorder
* Do not draw gleam on an outer border of this size.
* @property bool $syncAxisFonts
* Synchronize fonts of axis. With the defaut true value, the only
* the fonts of the yAxis will be used.
*
* @version 1.3
* @package Graph
*/
class ezcGraphRendererOptions extends ezcGraphChartOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['maxLabelHeight'] = .10;
$this->properties['showSymbol'] = true;
$this->properties['symbolSize'] = 6;
$this->properties['moveOut'] = .1;
$this->properties['titlePosition'] = ezcGraph::TOP;
$this->properties['titleAlignement'] = ezcGraph::MIDDLE | ezcGraph::CENTER;
$this->properties['dataBorder'] = .5;
$this->properties['barMargin'] = .1;
$this->properties['barPadding'] = .05;
$this->properties['pieChartOffset'] = 0;
$this->properties['pieChartSymbolColor'] = ezcGraphColor::fromHex( '#000000' );
$this->properties['pieChartGleam'] = false;
$this->properties['pieChartGleamColor'] = ezcGraphColor::fromHex( '#FFFFFF' );
$this->properties['pieChartGleamBorder'] = 0;
$this->properties['legendSymbolGleam'] = false;
$this->properties['legendSymbolGleamSize'] = .9;
$this->properties['legendSymbolGleamColor'] = ezcGraphColor::fromHex( '#FFFFFF' );
$this->properties['pieVerticalSize'] = .5;
$this->properties['pieHorizontalSize'] = .25;
$this->properties['syncAxisFonts'] = true;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'dataBorder':
case 'pieChartGleam':
case 'legendSymbolGleam':
if ( $propertyValue !== false &&
!is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
}
$this->properties[$propertyName] = (
$propertyValue === false
? false
: (float) $propertyValue );
break;
case 'maxLabelHeight':
case 'moveOut':
case 'barMargin':
case 'barPadding':
case 'legendSymbolGleamSize':
case 'pieVerticalSize':
case 'pieHorizontalSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'symbolSize':
case 'titlePosition':
case 'titleAlignement':
case 'pieChartGleamBorder':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
}
$this->properties[$propertyName] = (int) $propertyValue;
break;
case 'showSymbol':
case 'syncAxisFonts':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties[$propertyName] = (bool) $propertyValue;
break;
case 'pieChartOffset':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 360 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 360' );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'pieChartSymbolColor':
case 'pieChartGleamColor':
case 'legendSymbolGleamColor':
$this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
default:
return parent::__set( $propertyName, $propertyValue );
}
}
}
?>
@@ -0,0 +1,120 @@
<?php
/**
* File containing the ezcGraphRenderer2dOptions class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended options available in 2d renderer.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteBlack();
* $graph->title = 'Access statistics';
* $graph->options->label = '%2$d (%3$.1f%%)';
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
* $graph->data['Access statistics']->highlight['Explorer'] = true;
*
* // $graph->renderer = new ezcGraphRenderer2d();
*
* $graph->renderer->options->moveOut = .2;
*
* $graph->renderer->options->pieChartOffset = 63;
*
* $graph->renderer->options->pieChartGleam = .3;
* $graph->renderer->options->pieChartGleamColor = '#FFFFFF';
* $graph->renderer->options->pieChartGleamBorder = 2;
*
* $graph->renderer->options->pieChartShadowSize = 3;
* $graph->renderer->options->pieChartShadowColor = '#000000';
*
* $graph->renderer->options->legendSymbolGleam = .5;
* $graph->renderer->options->legendSymbolGleamSize = .9;
* $graph->renderer->options->legendSymbolGleamColor = '#FFFFFF';
*
* $graph->renderer->options->pieChartSymbolColor = '#BABDB688';
*
* $graph->render( 400, 150, 'tutorial_pie_chart_pimped.svg' );
* </code>
*
* @property int $pieChartShadowSize
* Size of shadows.
* @property float $pieChartShadowTransparency
* Used transparency for pie chart shadows.
* @property float $pieChartShadowColor
* Color used for pie chart shadows.
*
* @version 1.3
* @package Graph
*/
class ezcGraphRenderer2dOptions extends ezcGraphRendererOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['pieChartShadowSize'] = 0;
$this->properties['pieChartShadowTransparency'] = .3;
$this->properties['pieChartShadowColor'] = ezcGraphColor::fromHex( '#000000' );
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'pieChartShadowSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float >= 0' );
}
$this->properties['pieChartShadowSize'] = (int) $propertyValue;
break;
case 'pieChartShadowTransparency':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties['pieChartShadowTransparency'] = (float) $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
break;
default:
return parent::__set( $propertyName, $propertyValue );
}
}
}
?>
@@ -0,0 +1,185 @@
<?php
/**
* File containing the ezcGraphRenderer3dOptions class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended options for the three dimensional renderer.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->palette = new ezcGraphPaletteEzRed();
* $graph->title = 'Access statistics';
* $graph->options->label = '%2$d (%3$.1f%%)';
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
* $graph->data['Access statistics']->highlight['Explorer'] = true;
*
* $graph->renderer = new ezcGraphRenderer3d();
*
* $graph->renderer->options->moveOut = .2;
*
* $graph->renderer->options->pieChartOffset = 63;
*
* $graph->renderer->options->pieChartGleam = .3;
* $graph->renderer->options->pieChartGleamColor = '#FFFFFF';
*
* $graph->renderer->options->pieChartShadowSize = 5;
* $graph->renderer->options->pieChartShadowColor = '#000000';
*
* $graph->renderer->options->legendSymbolGleam = .5;
* $graph->renderer->options->legendSymbolGleamSize = .9;
* $graph->renderer->options->legendSymbolGleamColor = '#FFFFFF';
*
* $graph->renderer->options->pieChartSymbolColor = '#55575388';
*
* $graph->renderer->options->pieChartHeight = 5;
* $graph->renderer->options->pieChartRotation = .8;
*
* $graph->render( 400, 150, 'tutorial_pie_chart_3d.svg' );
* </code>
*
* @property bool $seperateLines
* Indicates wheather the full depth should be used for each line in
* the chart, or beeing seperated by the count of lines.
* @property float $fillAxis
* Transparency used to fill the axis polygon.
* @property float $fillGrid
* Transparency used to fill the grid lines.
* @property float $depth
* Part of picture used to simulate depth of three dimensional chart.
* @property float $pieChartHeight
* Height of the pie charts border.
* @property float $pieChartRotation
* Rotation of pie chart. Defines the percent of width used to
* calculate the height of the ellipse.
* @property int $pieChartShadowSize
* Size of shadows.
* @property float $pieChartShadowTransparency
* Used transparency for pie chart shadows.
* @property float $pieChartShadowColor
* Color used for pie chart shadows.
* @property float $barDarkenSide
* Factor to darken the color used for the bars side polygon.
* @property float $barDarkenTop
* Factor to darken the color used for the bars top polygon.
* @property float $barChartGleam
* Transparancy for gleam on bar charts
*
* @version 1.3
* @package Graph
*/
class ezcGraphRenderer3dOptions extends ezcGraphRendererOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['seperateLines'] = true;
$this->properties['fillAxis'] = .8;
$this->properties['fillGrid'] = 0;
$this->properties['depth'] = .1;
$this->properties['pieChartHeight'] = 10.;
$this->properties['pieChartRotation'] = .6;
$this->properties['pieChartShadowSize'] = 0;
$this->properties['pieChartShadowTransparency'] = .3;
$this->properties['pieChartShadowColor'] = ezcGraphColor::fromHex( '#000000' );
$this->properties['pieChartGleam'] = false;
$this->properties['pieChartGleamColor'] = ezcGraphColor::fromHex( '#FFFFFF' );
$this->properties['barDarkenSide'] = .2;
$this->properties['barDarkenTop'] = .4;
$this->properties['barChartGleam'] = false;
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'fillAxis':
case 'fillGrid':
if ( $propertyValue !== false &&
!is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
}
$this->properties[$propertyName] = (
$propertyValue === false
? false
: (float) $propertyValue );
break;
case 'depth':
case 'pieChartRotation':
case 'pieChartShadowTransparency':
case 'barDarkenSide':
case 'barDarkenTop':
case 'barChartGleam':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) ||
( $propertyValue > 1 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'pieChartHeight':
case 'pieChartShadowSize':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue <= 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties[$propertyName] = (float) $propertyValue;
break;
case 'seperateLines':
if ( !is_bool( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
}
$this->properties['seperateLines'] = $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
break;
default:
return parent::__set( $propertyName, $propertyValue );
}
}
}
?>
@@ -0,0 +1,272 @@
<?php
/**
* File containing the ezcGraphSvgDriverOption class
*
* @package Graph
* @version 1.3
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
* Class containing the extended options for the SVG driver.
*
* <code>
* $graph = new ezcGraphPieChart();
* $graph->background->color = '#FFFFFFFF';
* $graph->title = 'Access statistics';
* $graph->legend = false;
*
* $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
* 'Mozilla' => 19113,
* 'Explorer' => 10917,
* 'Opera' => 1464,
* 'Safari' => 652,
* 'Konqueror' => 474,
* ) );
*
* $graph->driver->options->templateDocument = dirname( __FILE__ ) . '/template.svg';
* $graph->driver->options->graphOffset = new ezcGraphCoordinate( 25, 40 );
* $graph->driver->options->insertIntoGroup = 'ezcGraph';
*
* $graph->render( 400, 200, 'tutorial_driver_svg.svg' );
* </code>
*
* @property string $encoding
* Encoding of the SVG XML document
* @property float $assumedNumericCharacterWidth
* Assumed percentual average width of chars in numeric strings with
* the used font.
* @property float $assumedTextCharacterWidth
* Assumed percentual average width of chars in non numeric strings
* with the used font.
* @property string $strokeLineCap
* This specifies the shape to be used at the end of open subpaths
* when they are stroked.
* @property string $strokeLineJoin
* This specifies the shape to be used at the edges of paths.
* @property string $shapeRendering
* "The creator of SVG content might want to provide a hint to the
* implementation about what tradeoffs to make as it renders vector
* graphics elements such as 'path' elements and basic shapes such as
* circles and rectangles."
* @property string $colorRendering
* "The creator of SVG content might want to provide a hint to the
* implementation about how to make speed vs. quality tradeoffs as it
* performs color interpolation and compositing. The
* 'color-rendering' property provides a hint to the SVG user agent
* about how to optimize its color interpolation and compositing
* operations."
* @property string $textRendering
* "The creator of SVG content might want to provide a hint to the
* implementation about what tradeoffs to make as it renders text."
* @property mixed $templateDocument
* Use existing SVG document as template to insert graph into. If
* insertIntoGroup is not set, a new group will be inserted in the
* svg root node.
* @property mixed $insertIntoGroup
* ID of a SVG group node to insert the graph. Only works with a
* custom template document.
* @property ezcGraphCoordinate $graphOffset
* Offset of the graph in the svg.
* @property string $idPrefix
* Prefix used for the ids in SVG documents.
* @property string $linkCursor
* CSS value for cursor property used for linked SVG elements
*
* @version 1.3
* @package Graph
*/
class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions
{
/**
* Constructor
*
* @param array $options Default option array
* @return void
* @ignore
*/
public function __construct( array $options = array() )
{
$this->properties['encoding'] = null;
$this->properties['assumedNumericCharacterWidth'] = .62;
$this->properties['assumedTextCharacterWidth'] = .53;
$this->properties['strokeLineJoin'] = 'round';
$this->properties['strokeLineCap'] = 'round';
$this->properties['shapeRendering'] = 'geometricPrecision';
$this->properties['colorRendering'] = 'optimizeQuality';
$this->properties['textRendering'] = 'optimizeLegibility';
$this->properties['templateDocument'] = false;
$this->properties['insertIntoGroup'] = false;
$this->properties['graphOffset'] = new ezcGraphCoordinate( 0, 0 );
$this->properties['idPrefix'] = 'ezcGraph';
$this->properties['linkCursor'] = 'pointer';
parent::__construct( $options );
}
/**
* Set an option value
*
* @param string $propertyName
* @param mixed $propertyValue
* @throws ezcBasePropertyNotFoundException
* If a property is not defined in this class
* @return void
* @ignore
*/
public function __set( $propertyName, $propertyValue )
{
switch ( $propertyName )
{
case 'assumedNumericCharacterWidth':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['assumedNumericCharacterWidth'] = (float) $propertyValue;
break;
case 'assumedTextCharacterWidth':
if ( !is_numeric( $propertyValue ) ||
( $propertyValue < 0 ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
$this->properties['assumedTextCharacterWidth'] = (float) $propertyValue;
break;
case 'strokeLineJoin':
$values = array(
'round',
'miter',
'bevel',
'inherit',
);
if ( in_array( $propertyValue, $values, true ) )
{
$this->properties['strokeLineJoin'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) );
}
break;
case 'strokeLineCap':
$values = array(
'round',
'butt',
'square',
'inherit',
);
if ( in_array( $propertyValue, $values, true ) )
{
$this->properties['strokeLineCap'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) );
}
break;
case 'shapeRendering':
$values = array(
'auto',
'optimizeSpeed',
'crispEdges',
'geometricPrecision',
'inherit',
);
if ( in_array( $propertyValue, $values, true ) )
{
$this->properties['shapeRendering'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) );
}
break;
case 'colorRendering':
$values = array(
'auto',
'optimizeSpeed',
'optimizeQuality',
'inherit',
);
if ( in_array( $propertyValue, $values, true ) )
{
$this->properties['colorRendering'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) );
}
break;
case 'textRendering':
$values = array(
'auto',
'optimizeSpeed',
'optimizeLegibility',
'geometricPrecision',
'inherit',
);
if ( in_array( $propertyValue, $values, true ) )
{
$this->properties['textRendering'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) );
}
break;
case 'templateDocument':
if ( !is_file( $propertyValue ) || !is_readable( $propertyValue ) )
{
throw new ezcBaseFileNotFoundException( $propertyValue );
}
else
{
$this->properties['templateDocument'] = realpath( $propertyValue );
}
break;
case 'insertIntoGroup':
if ( !is_string( $propertyValue ) )
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'string' );
}
else
{
$this->properties['insertIntoGroup'] = $propertyValue;
}
break;
case 'graphOffset':
if ( $propertyValue instanceof ezcGraphCoordinate )
{
$this->properties['graphOffset'] = $propertyValue;
}
else
{
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphCoordinate' );
}
break;
case 'idPrefix':
$this->properties['idPrefix'] = (string) $propertyValue;
break;
case 'encoding':
$this->properties['encoding'] = (string) $propertyValue;
break;
case 'linkCursor':
$this->properties['linkCursor'] = (string) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
break;
}
}
}
?>