[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/ezc/Graph/src/options/ -> line_chart.php (source)

   1  <?php
   2  /**
   3   * File containing the ezcGraphLineChartOption class
   4   *
   5   * @package Graph
   6   * @version 1.5
   7   * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
   8   * @license http://ez.no/licenses/new_bsd New BSD License
   9   */
  10  /**
  11   * Class containing the basic options for line charts.
  12   *
  13   * This class contains basic options relevant for line and bar charts, which
  14   * are just an extension of line charts.
  15   *
  16   * For additional options configuring the apperance of the chart you may also
  17   * want to check the option classes to configure the respective renderer you
  18   * are using:
  19   *
  20   * - ezcGraphRendererOptions
  21   * - ezcGraphRenderer2dOptions
  22   * - ezcGraphRenderer3dOptions
  23   *
  24   * <code>
  25   *   $graph = new ezcGraphLineChart();
  26   *   $graph->title = 'Wikipedia articles';
  27   *
  28   *   $graph->options->fillLines = 220;
  29   *   $graph->options->lineThickness = 3;
  30   *   
  31   *   // Add data
  32   *   foreach ( $wikidata as $language => $data )
  33   *   {
  34   *       $graph->data[$language] = new ezcGraphArrayDataSet( $data );
  35   *   }
  36   *   
  37   *   $graph->render( 400, 150, 'tutorial_line_chart.svg' );
  38   * </code>
  39   *
  40   * @property float $lineThickness
  41   *           Thickness of chart lines
  42   * @property mixed $fillLines
  43   *           Status wheather the space between line and axis should get filled.
  44   *            - FALSE to not fill the space at all.
  45   *            - (int) Opacity used to fill up the space with the lines color.
  46   * @property int $symbolSize
  47   *           Size of symbols in line chart.
  48   * @property ezcGraphFontOptions $highlightFont
  49   *           Font configuration for highlight tests
  50   * @property int $highlightSize
  51   *           Size of highlight blocks
  52   * @property bool $highlightLines
  53   *           If true, it adds lines to highlight the values position on the 
  54   *           axis.
  55   * @property float $highlightXOffset
  56   *           Horizontal offset for highlight strings, applied to all chart 
  57   *           highlight strings
  58   * @property float $highlightYOffset
  59   *           Vertical offset for highlight strings, applied to all chart 
  60   *           highlight strings
  61   * @property true $stackBars
  62   *           Stack bars
  63   *
  64   * @version 1.5
  65   * @package Graph
  66   */
  67  class ezcGraphLineChartOptions extends ezcGraphChartOptions
  68  {
  69      /**
  70       * Constructor
  71       * 
  72       * @param array $options Default option array
  73       * @return void
  74       * @ignore
  75       */
  76      public function __construct( array $options = array() )
  77      {
  78          $this->properties['lineThickness'] = 1;
  79          $this->properties['fillLines'] = false;
  80          $this->properties['symbolSize'] = 8;
  81          $this->properties['highlightFont'] = new ezcGraphFontOptions();
  82          $this->properties['highlightFontCloned'] = false;
  83          $this->properties['highlightSize'] = 14;
  84          $this->properties['highlightXOffset'] = 0;
  85          $this->properties['highlightYOffset'] = 0;
  86          $this->properties['highlightLines'] = false;
  87          $this->properties['stackBars'] = false;
  88      
  89          parent::__construct( $options );
  90      }
  91  
  92      /**
  93       * Set an option value
  94       * 
  95       * @param string $propertyName 
  96       * @param mixed $propertyValue 
  97       * @throws ezcBasePropertyNotFoundException
  98       *          If a property is not defined in this class
  99       * @return void
 100       */
 101      public function __set( $propertyName, $propertyValue )
 102      {
 103          switch ( $propertyName )
 104          {
 105              case 'lineThickness':
 106                  if ( !is_numeric( $propertyValue ) ||
 107                       ( $propertyValue < 0 ) ) 
 108                  {
 109                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
 110                  }
 111  
 112                  $this->properties[$propertyName] = (int) $propertyValue;
 113                  break;
 114              case 'symbolSize':
 115              case 'highlightSize':
 116                  if ( !is_numeric( $propertyValue ) ||
 117                       ( $propertyValue < 1 ) ) 
 118                  {
 119                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
 120                  }
 121                  $this->properties[$propertyName] = (int) $propertyValue;
 122                  break;
 123              case 'highlightXOffset':
 124              case 'highlightYOffset':
 125                  if ( !is_numeric ( $propertyValue ) )
 126                  {
 127                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'int' );
 128                  }
 129                  $this->properties[$propertyName] = (int) $propertyValue;
 130                  break;
 131              case 'fillLines':
 132                  if ( ( $propertyValue !== false ) &&
 133                       !is_numeric( $propertyValue ) ||
 134                       ( $propertyValue < 0 ) ||
 135                       ( $propertyValue > 255 ) )
 136                  {
 137                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= int <= 255' );
 138                  }
 139  
 140                  $this->properties[$propertyName] = ( 
 141                      $propertyValue === false
 142                      ? false
 143                      : (int) $propertyValue );
 144                  break;
 145              case 'highlightFont':
 146                  if ( $propertyValue instanceof ezcGraphFontOptions )
 147                  {
 148                      $this->properties['highlightFont'] = $propertyValue;
 149                  }
 150                  elseif ( is_string( $propertyValue ) )
 151                  {
 152                      if ( !$this->properties['highlightFontCloned'] )
 153                      {
 154                          $this->properties['highlightFont'] = clone $this->font;
 155                          $this->properties['highlightFontCloned'] = true;
 156                      }
 157  
 158                      $this->properties['highlightFont']->path = $propertyValue;
 159                  }
 160                  else
 161                  {
 162                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
 163                  }
 164                  break;
 165                  $this->properties['highlightSize'] = max( 1, (int) $propertyValue );
 166                  break;
 167              case 'highlightLines':
 168                  if ( !is_bool( $propertyValue ) )
 169                  {
 170                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
 171                  }
 172  
 173                  $this->properties['highlightLines'] = $propertyValue;
 174                  break;
 175              case 'stackBars':
 176                  if ( !is_bool( $propertyValue ) )
 177                  {
 178                      throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
 179                  }
 180  
 181                  $this->properties['stackBars'] = $propertyValue;
 182                  break;
 183              default:
 184                  return parent::__set( $propertyName, $propertyValue );
 185          }
 186      }
 187      
 188      /**
 189       * __get 
 190       * 
 191       * @param mixed $propertyName 
 192       * @throws ezcBasePropertyNotFoundException
 193       *          If a the value for the property options is not an instance of
 194       * @return mixed
 195       * @ignore
 196       */
 197      public function __get( $propertyName )
 198      {
 199          switch ( $propertyName )
 200          {
 201              case 'highlightFont':
 202                  // Clone font configuration when requested for this element
 203                  if ( !$this->properties['highlightFontCloned'] )
 204                  {
 205                      $this->properties['highlightFont'] = clone $this->properties['font'];
 206                      $this->properties['highlightFontCloned'] = true;
 207                  }
 208                  return $this->properties['highlightFont'];
 209              default:
 210                  return parent::__get( $propertyName );
 211          }
 212      }
 213  }
 214  
 215  ?>


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7