Source for file Curve.php
Documentation is available at Curve.php
* $Source: /cvsroot/svggrapher/svggrapher/mains/Curve.php,v $
* @version $Id: Curve.php,v 1.7 2007/10/23 09:22:53 geelweb Exp $
* @author Guillaume L. <guillaume@geelweb.org>
* @copyright Copyright (c) 2006, Guillaume Luchet.
* @license http://opensource.org/licenses/bsd-license.php BSD License
* define the default curve style
if(!defined('DEFAULT_CURVE_STYLE')) {
define('DEFAULT_CURVE_STYLE', 'stroke-width:2;visibility:visible;');
* include the plugin manager
require_once SVGGRAPHER_CLASS_PATH .
'/mains/PluginManager.php';
* include the svg style element
require_once SVGGRAPHER_CLASS_PATH .
'/mains/SvgStyle.php';
* @author Guillaume L. <guillaume@geelweb.org>
* @link http://www.geelweb.org
* @license http://opensource.org/licenses/bsd-license.php BSD License
* @copyright Copyright (c) 2006, Guillaume Luchet.
* @version CVS: $Id: Curve.php,v 1.7 2007/10/23 09:22:53 geelweb Exp $
* @var string or SvgStyle
* color of the curve, string or array of string if the curve have many
* legend of the curve, string or array of string if the curve have many
* name of the visual plugin to use to render the curve.
// Curve::__construct() {{{
* Initialize the object with the params.
* the key of the array params are:
* - labels : curve abscisse data (array)
* - values : curve ordinate data (array)
* - style : curve style (string)
* - color : curve color (string or array of string)
* - legend : curve legend (string or array of string)
* - visual : curve visual (string)
* - filter : plugin filter name (string or array of string)
* - marker : plugin marker params (array) see Curve::setMarker() to params
* @param array $params key / value array params
* @param int $id curve id
if(isset
($params['labels'])) {
$this->labels =
$params['labels'];
if(isset
($params['values'])) {
$this->values =
$params['values'];
if(isset
($params['legend'])) {
$this->legend =
$params['legend'];
if(isset
($params['visual'])) {
$this->visual =
$params['visual'];
if(isset
($params['filter'])) {
if(isset
($params['marker'])) {
$this->style = isset
($params['style']) ?
if(isset
($params['color'])) {
foreach($this->legend as $key=>
$text) {
if(!isset
($this->color[$key])) {
// Curve::setFilter() {{{
* Add filters to the curve calling the according filter plugin.
* @param mixed $filters filter plugin name, array of string to set many
$filters =
is_array($filters) ?
$filters :
array($filters);
foreach($filters as $filter) {
// Curve::setMarker() {{{
* Add a marker to the curve calling the according marker plugin.
* - plugin : plugin to use (string)
* @param mixed $marker marker plugin name, array of marker params array to
$marker =
is_array($marker) ?
$marker['plugin'] :
$marker;
$color = isset
($marker['color']) ?
$marker['color'] :
$this->color;
$markerId = isset
($marker['id']) ?
$marker['id'] :
NULL;
$markerId =
'markerCurve_' .
$markerId .
'_' .
$this->id;
* set the curve color, if $color is string (when the curve use only on
* color) the color is add to the style attributes (stroke and fill)
$style->setAttribute('stroke', $color);
$style->setAttribute('fill', $color);
$this->style =
$style->toString();
* magic method to the properties who needs specials actions (like filter,
* @param string $property
public function __get($property)
$getter =
'get' .
$property;
* magic method to the properties who needs specials action (filters, color
* @param string $property
public function __set($property, $value)
$setter =
'set' .
$property;
return $this->$setter($value);
return $this->$property =
$value;
* Render the curve using the PluginManager
Documentation generated on Tue, 23 Oct 2007 11:31:54 +0200 by phpDocumentor 1.4.0