Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcGraphRenderer2d

Graph::ezcGraphRenderer2d

Class ezcGraphRenderer2d

Class to transform chart primitives into image primitives. Renders charts in a two dimensional view.

The class options are defined in the class ezcGraphRenderer2dOptions extending the basic renderer options in ezcGraphRendererOptions.

  1.    $graph = new ezcGraphPieChart();
  2.    $graph->palette = new ezcGraphPaletteBlack();
  3.    $graph->title = 'Access statistics';
  4.    $graph->options->label = '%2$d (%3$.1f%%)';
  5.  
  6.    $graph->data['Access statistics'] = new ezcGraphArrayDataSet( array(
  7.        'Mozilla' => 19113,
  8.        'Explorer' => 10917,
  9.        'Opera' => 1464,
  10.        'Safari' => 652,
  11.        'Konqueror' => 474,
  12.    ) );
  13.    $graph->data['Access statistics']->highlight['Explorer'] = true;
  14.  
  15.    // $graph->renderer = new ezcGraphRenderer2d();
  16.  
  17.    $graph->renderer->options->moveOut = .2;
  18.  
  19.    $graph->renderer->options->pieChartOffset = 63;
  20.  
  21.    $graph->renderer->options->pieChartGleam = .3;
  22.    $graph->renderer->options->pieChartGleamColor = '#FFFFFF';
  23.    $graph->renderer->options->pieChartGleamBorder = 2;
  24.  
  25.    $graph->renderer->options->pieChartShadowSize = 3;
  26.    $graph->renderer->options->pieChartShadowColor = '#000000';
  27.  
  28.    $graph->renderer->options->legendSymbolGleam = .5;
  29.    $graph->renderer->options->legendSymbolGleamSize = .9;
  30.    $graph->renderer->options->legendSymbolGleamColor = '#FFFFFF';
  31.  
  32.    $graph->renderer->options->pieChartSymbolColor = '#BABDB688';
  33.  
  34.    $graph->render( 400, 150, 'tutorial_pie_chart_pimped.svg' );

Source for this file: /Graph/src/renderer/2d.php

Implements interfaces:

ezcGraphRenderer
   |
   --ezcGraphRenderer2d
Version:   //autogentag//

Descendants

Child Class Description
ezcGraphHorizontalRenderer Class to transform horizontal bar charts primitives into image primitives.

Member Variables

protected array $axisLabels = array()
Collect axis labels, so that the axis are drawn, when all axis spaces are known.
protected array $circleSectors = array()
Collects circle sectors to draw shadow in background of all circle sectors.
protected array $linePostSymbols = array()
Array with symbols for post processing, which ensures, that the symbols are rendered topmost.
protected ezcGraphRenderer2dOptions $options
Options
protected ezcGraphBoundings $pieSegmentBoundings = false
Contains the boundings used for pie segments
protected array $pieSegmentLabels = array(
0 => array(),1=>array(),)

Pie segment labels divided into two array, containing the labels on the left and right side of the pie chart center.

Inherited Member Variables

From ezcGraphRenderer
protected ezcGraphRenderer::$driver
protected ezcGraphRenderer::$elements
protected ezcGraphRenderer::$xAxisSpace
protected ezcGraphRenderer::$yAxisSpace

Method Summary

public void drawAxis( $boundings , $start , $end , $axis , [ $labelClass = null] , [ $innerBoundings = null] )
Draw axis
protected void drawAxisLabel( $position , $boundings , $axis )
Draw axis label
protected void drawAxisLabels( )
Draw all left axis labels
public void drawBackgroundImage( $boundings , $file , [ $position = 48] , [ $repeat = ezcGraph::NO_REPEAT] )
Draw background image
public void drawBar( $boundings , $context , $color , $position , $stepSize , [ $dataNumber = 1] , [ $dataCount = 1] , [ $symbol = ezcGraph::NO_SYMBOL] , [ $axisPosition = 0.] )
Draw bar
public ezcGraphBoundings drawBox( $boundings , [ $background = null] , [ $borderColor = null] , [ $borderWidth = 0] , [ $margin = 0] , [ $padding = 0] , [ $title = false] , [ $titleSize = 16] )
Draw box
public void drawDataHighlightText( $boundings , $context , $end , [ $axisPosition = 0.] , [ $dataNumber = 1] , [ $dataCount = 1] , $font , $text , $size , [ $markLines = null] , [ $xOffset = 0] , [ $yOffset = 0] , [ $stepSize = 0.] , [ $type = ezcGraph::LINE] )
Draws a highlight textbox for a datapoint.
public void drawDataLine( $boundings , $context , $color , $start , $end , [ $dataNumber = 1] , [ $dataCount = 1] , [ $symbol = ezcGraph::NO_SYMBOL] , [ $symbolColor = null] , [ $fillColor = null] , [ $axisPosition = 0.] , [ $thickness = 1.] )
Draw data line
public void drawGridLine( $start , $end , $color )
Draw grid line
public void drawLegend( $boundings , $legend , [ $type = ezcGraph::VERTICAL] )
Draw legend
public ezcGraphBoundings drawOdometer( $boundings , $axis , $options )
Render odometer chart
public void drawOdometerMarker( $boundings , $position , $symbol , $color , $width )
Draw a single odometer marker.
public void drawPieSegment( $boundings , $context , $color , [ $startAngle = .0] , [ $endAngle = 360.] , [ $label = false] , [ $moveOut = false] )
Draw pie segment
public void drawRadarDataLine( $boundings , $context , $color , $center , $start , $end , [ $dataNumber = 1] , [ $dataCount = 1] , [ $symbol = ezcGraph::NO_SYMBOL] , [ $symbolColor = null] , [ $fillColor = null] , [ $thickness = 1.] )
Draw radar chart data line
public void drawStackedBar( $boundings , $context , $color , $start , $position , $stepSize , [ $symbol = ezcGraph::NO_SYMBOL] , [ $axisPosition = 0.] )
Draw stacked bar
public void drawStepLine( $start , $end , $color )
Draw step line
public void drawText( $boundings , $text , [ $align = ezcGraph::LEFT] , [ $rotation = null] )
Draw text
protected void finish( )
Call all postprocessing functions
protected void finishCircleSectors( )
Draws the collected circle sectors
protected void finishLineSymbols( )
Draw the collected line symbols
protected void finishPieSegmentLabels( )
Draws the collected pie segment labels
protected float getCoordinateFromAngleAndRadius( $boundings , $center , $angle , $radius )
Returns a coordinate in the given bounding box for the given angle radius with the center as base point.
protected void legacyDrawAxis( $boundings , $start , $end , $axis , [ $labelClass = null] )
Draw axis
protected void resetRenderer( )
Reset renderer properties

Inherited Methods

From ezcGraphRenderer
protected void ezcGraphRenderer::addElementReference()
Adds a element reference for context
public abstract void ezcGraphRenderer::drawAxis()
Draw axis
protected void ezcGraphRenderer::drawAxisArrowHead()
Draw axis arrow head
public abstract void ezcGraphRenderer::drawBackgroundImage()
Draw background image
public abstract void ezcGraphRenderer::drawBar()
Draw bar
public abstract ezcGraphBoundings ezcGraphRenderer::drawBox()
Draw box
public abstract void ezcGraphRenderer::drawDataHighlightText()
Draws a highlight textbox for a datapoint.
public abstract void ezcGraphRenderer::drawDataLine()
Draw data line
public abstract void ezcGraphRenderer::drawLegend()
Draw legend
public abstract void ezcGraphRenderer::drawPieSegment()
Draw pie segment
public void ezcGraphRenderer::drawSymbol()
Draw Symbol
public abstract void ezcGraphRenderer::drawText()
Draw text
protected abstract void ezcGraphRenderer::finish()
Finish rendering
public array ezcGraphRenderer::getElementReferences()
Return all chart element references
public void ezcGraphRenderer::render()
Finally renders the image
protected void ezcGraphRenderer::resetRenderer()
Reset renderer properties
public void ezcGraphRenderer::setDriver()
Set renderers driver

Methods

drawAxis

void drawAxis( $boundings , ezcGraphCoordinate $start , ezcGraphCoordinate $end , ezcGraphChartElementAxis $axis , [ezcGraphAxisLabelRenderer $labelClass = null] , [ $innerBoundings = null] )

Draw axis

Draws an axis form the provided start point to the end point. A specific angle of the axis is not required.

For the labeleing of the axis a sorted array with major steps and an array with minor steps is expected, which are build like this: array( array( 'position' => (float), 'label' => (string), ) ) where the label is optional.

The label renderer class defines how the labels are rendered. For more documentation on this topic have a look at the basic label renderer class.

Additionally it can be specified if a major and minor grid are rendered by defining a color for them. The axis label is used to add a caption for the axis.

Parameters:
Name Type Description
$boundings ezcGraphBoundings Boundings of axis
$start ezcGraphCoordinate Start point of axis
$end ezcGraphCoordinate Endpoint of axis
$axis ezcGraphChartElementAxis Axis to render
$labelClass ezcGraphAxisLabelRenderer Used label renderer
$innerBoundings ezcGraphBoundings
Redefinition of:
Method Description
ezcGraphRenderer::drawAxis() Draw axis

drawAxisLabel

void drawAxisLabel( ezcGraphCoordinate $position , $boundings , ezcGraphChartElementAxis $axis )

Draw axis label

Draw labels at the end of an axis.

Parameters:
Name Type Description
$position ezcGraphCoordinate
$boundings ezcGraphBoundings
$axis ezcGraphChartElementAxis

drawAxisLabels

void drawAxisLabels( )

Draw all left axis labels

drawBackgroundImage

void drawBackgroundImage( $boundings , string $file , [int $position = 48] , [int $repeat = ezcGraph::NO_REPEAT] )

Draw background image

Draws a background image at the defined position. If repeat is set the background image will be repeated like any texture.

Parameters:
Name Type Description
$boundings ezcGraphBoundings Boundings for the background image
$file string Filename of background image
$position int Position of background image
$repeat int Type of repetition
Redefinition of:
Method Description
ezcGraphRenderer::drawBackgroundImage() Draw background image

drawBar

void drawBar( $boundings , ezcGraphContext $context , ezcGraphColor $color , ezcGraphCoordinate $position , float $stepSize , [int $dataNumber = 1] , [int $dataCount = 1] , [int $symbol = ezcGraph::NO_SYMBOL] , [float $axisPosition = 0.] )

Draw bar

Draws a bar as a data element in a line chart

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$color ezcGraphColor Color of line
$position ezcGraphCoordinate Position of data point
$stepSize float Space which can be used for bars
$dataNumber int Number of dataset
$dataCount int Count of datasets in chart
$symbol int Symbol to draw for line
$axisPosition float Position of axis for drawing filled lines
Redefinition of:
Method Description
ezcGraphRenderer::drawBar() Draw bar
Redefined in descendants as:
Method Description
ezcGraphHorizontalRenderer::drawBar() Draw bar 

drawBox

ezcGraphBoundings drawBox( $boundings , [ezcGraphColor $background = null] , [ezcGraphColor $borderColor = null] , [int $borderWidth = 0] , [int $margin = 0] , [int $padding = 0] , [mixed $title = false] , [int $titleSize = 16] )

Draw box

Box are wrapping each major chart element and draw border, background and title to each chart element.

Optionally a padding and margin for each box can be defined.

Parameters:
Name Type Description
$boundings ezcGraphBoundings Boundings of the box
$background ezcGraphColor Background color
$borderColor ezcGraphColor Border color
$borderWidth int Border width
$margin int Margin
$padding int Padding
$title mixed Title of the box
$titleSize int Size of title in the box
Redefinition of:
Method Description
ezcGraphRenderer::drawBox() Draw box

drawDataHighlightText

void drawDataHighlightText( $boundings , ezcGraphContext $context , ezcGraphCoordinate $end , [float $axisPosition = 0.] , [int $dataNumber = 1] , [int $dataCount = 1] , ezcGraphFontOptions $font , string $text , int $size , [ezcGraphColor $markLines = null] , [int $xOffset = 0] , [int $yOffset = 0] , [float $stepSize = 0.] , [int $type = ezcGraph::LINE] )

Draws a highlight textbox for a datapoint.

A highlight textbox for line and bar charts means a box with the current value in the graph.

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$end ezcGraphCoordinate Ending point
$axisPosition float Position of axis for drawing filled lines
$dataNumber int Number of dataset
$dataCount int Count of datasets in chart
$font ezcGraphFontOptions Font used for highlight string
$text string Acutual value
$size int Size of highlight text
$markLines ezcGraphColor
$xOffset int
$yOffset int
$stepSize float
$type int
Redefinition of:
Method Description
ezcGraphRenderer::drawDataHighlightText() Draws a highlight textbox for a datapoint.

drawDataLine

void drawDataLine( $boundings , ezcGraphContext $context , ezcGraphColor $color , ezcGraphCoordinate $start , ezcGraphCoordinate $end , [int $dataNumber = 1] , [int $dataCount = 1] , [int $symbol = ezcGraph::NO_SYMBOL] , [ezcGraphColor $symbolColor = null] , [ezcGraphColor $fillColor = null] , [float $axisPosition = 0.] , [float $thickness = 1.] )

Draw data line

Draws a line as a data element in a line chart

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$color ezcGraphColor Color of line
$start ezcGraphCoordinate Starting point
$end ezcGraphCoordinate Ending point
$dataNumber int Number of dataset
$dataCount int Count of datasets in chart
$symbol int Symbol to draw for line
$symbolColor ezcGraphColor Color of the symbol, defaults to linecolor
$fillColor ezcGraphColor Color to fill line with
$axisPosition float Position of axis for drawing filled lines
$thickness float Line thickness
Redefinition of:
Method Description
ezcGraphRenderer::drawDataLine() Draw data line
Redefined in descendants as:
Method Description
ezcGraphHorizontalRenderer::drawDataLine() Draw data line 

drawGridLine

void drawGridLine( ezcGraphCoordinate $start , ezcGraphCoordinate $end , ezcGraphColor $color )

Draw grid line

Draw line for the grid in the chart background

Parameters:
Name Type Description
$start ezcGraphCoordinate Start point
$end ezcGraphCoordinate End point
$color ezcGraphColor Color of the grid line

drawLegend

void drawLegend( $boundings , ezcGraphChartElementLegend $legend , [int $type = ezcGraph::VERTICAL] )

Draw legend

Will draw a legend in the bounding box

Parameters:
Name Type Description
$boundings ezcGraphBoundings Bounding of legend
$legend ezcGraphChartElementLegend Legend to draw;
$type int Type of legend: Protrait or landscape
Redefinition of:
Method Description
ezcGraphRenderer::drawLegend() Draw legend

drawOdometer

ezcGraphBoundings drawOdometer( $boundings , ezcGraphChartElementAxis $axis , ezcGraphOdometerChartOptions $options )

Render odometer chart

Parameters:
Name Type Description
$boundings ezcGraphBoundings
$axis ezcGraphChartElementAxis
$options ezcGraphOdometerChartOptions
Implementation of:
Method Description
ezcGraphOdometerRenderer::drawOdometer() Render odometer chart

drawOdometerMarker

void drawOdometerMarker( $boundings , ezcGraphCoordinate $position , int $symbol , ezcGraphColor $color , int $width )

Draw a single odometer marker.

Parameters:
Name Type Description
$boundings ezcGraphBoundings
$position ezcGraphCoordinate
$symbol int
$color ezcGraphColor
$width int
Implementation of:
Method Description
ezcGraphOdometerRenderer::drawOdometerMarker() Draw a single odometer marker.

drawPieSegment

void drawPieSegment( $boundings , ezcGraphContext $context , ezcGraphColor $color , [float $startAngle = .0] , [float $endAngle = 360.] , [mixed $label = false] , [bool $moveOut = false] )

Draw pie segment

Draws a single pie segment

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$color ezcGraphColor Color of pie segment
$startAngle float Start angle
$endAngle float End angle
$label mixed Label of pie segment
$moveOut bool Move out from middle for hilighting
Redefinition of:
Method Description
ezcGraphRenderer::drawPieSegment() Draw pie segment

drawRadarDataLine

void drawRadarDataLine( $boundings , ezcGraphContext $context , ezcGraphColor $color , ezcGraphCoordinate $center , ezcGraphCoordinate $start , ezcGraphCoordinate $end , [int $dataNumber = 1] , [int $dataCount = 1] , [int $symbol = ezcGraph::NO_SYMBOL] , [ezcGraphColor $symbolColor = null] , [ezcGraphColor $fillColor = null] , [float $thickness = 1.] )

Draw radar chart data line

Draws a line as a data element in a radar chart

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$color ezcGraphColor Color of line
$center ezcGraphCoordinate Center of radar chart
$start ezcGraphCoordinate Starting point
$end ezcGraphCoordinate Ending point
$dataNumber int Number of dataset
$dataCount int Count of datasets in chart
$symbol int Symbol to draw for line
$symbolColor ezcGraphColor Color of the symbol, defaults to linecolor
$fillColor ezcGraphColor Color to fill line with
$thickness float Line thickness
Implementation of:
Method Description
ezcGraphRadarRenderer::drawRadarDataLine() Draw radar chart data line

drawStackedBar

void drawStackedBar( $boundings , ezcGraphContext $context , ezcGraphColor $color , ezcGraphCoordinate $start , ezcGraphCoordinate $position , float $stepSize , [int $symbol = ezcGraph::NO_SYMBOL] , [float $axisPosition = 0.] )

Draw stacked bar

Draws a stacked bar part as a data element in a line chart

Parameters:
Name Type Description
$boundings ezcGraphBoundings Chart boundings
$context ezcGraphContext Context of call
$color ezcGraphColor Color of line
$start ezcGraphCoordinate
$position ezcGraphCoordinate
$stepSize float Space which can be used for bars
$symbol int Symbol to draw for line
$axisPosition float Position of axis for drawing filled lines
Implementation of:
Method Description
ezcGraphStackedBarsRenderer::drawStackedBar() Draw stacked bar

drawStepLine

void drawStepLine( ezcGraphCoordinate $start , ezcGraphCoordinate $end , ezcGraphColor $color )

Draw step line

Draw a step (marker for label position) on a axis.

Parameters:
Name Type Description
$start ezcGraphCoordinate Start point
$end ezcGraphCoordinate End point
$color ezcGraphColor Color of the grid line

drawText

void drawText( $boundings , string $text , [int $align = ezcGraph::LEFT] , [ $rotation = null] )

Draw text

Draws the provided text in the boundings

Parameters:
Name Type Description
$boundings ezcGraphBoundings Boundings of text
$text string Text
$align int Alignement of text
$rotation ezcGraphRotation
Redefinition of:
Method Description
ezcGraphRenderer::drawText() Draw text

finish

void finish( )

Call all postprocessing functions

Redefinition of:
Method Description
ezcGraphRenderer::finish() Finish rendering

finishCircleSectors

void finishCircleSectors( )

Draws the collected circle sectors

All circle sectors are collected and drawn later to be able to render the shadows of the pie segments in the back of all pie segments.

finishLineSymbols

void finishLineSymbols( )

Draw the collected line symbols

Symbols for the data lines are collected and delayed to ensure that they are not covered and hidden by other data lines.

finishPieSegmentLabels

void finishPieSegmentLabels( )

Draws the collected pie segment labels

All labels are collected and drawn later to be able to partition the available space for the labels woth knowledge of the overall label count and their required size and optimal position.

getCoordinateFromAngleAndRadius

float getCoordinateFromAngleAndRadius( $boundings , ezcGraphCoordinate $center , float $angle , float $radius )

Returns a coordinate in the given bounding box for the given angle radius with the center as base point.

Parameters:
Name Type Description
$boundings ezcGraphBoundings
$center ezcGraphCoordinate
$angle float
$radius float

legacyDrawAxis

void legacyDrawAxis( $boundings , ezcGraphCoordinate $start , ezcGraphCoordinate $end , ezcGraphChartElementAxis $axis , [ezcGraphAxisLabelRenderer $labelClass = null] )

Draw axis

Draws an axis form the provided start point to the end point. A specific angle of the axis is not required.

For the labeleing of the axis a sorted array with major steps and an array with minor steps is expected, which are build like this: array( array( 'position' => (float), 'label' => (string), ) ) where the label is optional.

The label renderer class defines how the labels are rendered. For more documentation on this topic have a look at the basic label renderer class.

Additionally it can be specified if a major and minor grid are rendered by defining a color for them. The axis label is used to add a caption for the axis.

This function is deprecated and will be removed in favor of its reimplementation using the innerBoundings parameter.

Parameters:
Name Type Description
$boundings ezcGraphBoundings Boundings of axis
$start ezcGraphCoordinate Start point of axis
$end ezcGraphCoordinate Endpoint of axis
$axis ezcGraphChartElementAxis Axis to render
$labelClass ezcGraphAxisLabelRenderer Used label renderer

resetRenderer

void resetRenderer( )

Reset renderer properties

Reset all renderer properties, which were calculated during the rendering process, to offer a clean environment for rerendering.

Redefinition of:
Method Description
ezcGraphRenderer::resetRenderer() Reset renderer properties
Documentation generated by phpDocumentor 1.4.3