Zeta Components Manual :: Docs For Class ezcGraphSvgDriver
Graph::ezcGraphSvgDriver
Class ezcGraphSvgDriver
Extension of the basic Driver package to utilize the SVGlib.
This drivers options are defined in the class ezcGraphSvgDriverOptions extending the basic driver options class ezcGraphDriverOptions.
As this is the default driver you do not need to explicitely set anything to use it, but may use some of its advanced features.
- $graph->background->color = '#FFFFFFFF';
- $graph->title = 'Access statistics';
- $graph->legend = false;
- 'Mozilla' => 19113,
- 'Explorer' => 10917,
- 'Opera' => 1464,
- 'Safari' => 652,
- 'Konqueror' => 474,
- ) );
- // SVG driver options
Source for this file: /Graph/src/driver/svg.php
ezcGraphDriver | --ezcGraphSvgDriver
Version: | //autogentag// |
Member Variables
protected DOMElement |
$defs
DOMElement containing all svg style definitions |
protected DOMDocument |
$dom
DOM tree of the svg document |
protected array |
$drawnGradients
= array()
List of already created gradients |
protected int |
$elementID
= 0
Numeric unique element id |
protected DOMElement |
$elements
DOMElement containing all svg objects |
protected ezcGraphSvgFont |
$font
= null
Font storage for SVG font glyphs and kernings. |
protected array |
$strings
= array()
List of strings to draw array ( array( 'text' => array( 'strings' ), 'options' => ezcGraphFontOptions, ) |
Inherited Member Variables
From ezcGraphDriver | |
---|---|
protected |
ezcGraphDriver::$options
|
Method Summary
protected void |
createDocument(
)
Creates the DOM object to insert SVG nodes in. |
protected void |
drawAllTexts(
)
Draw all collected texts |
public void |
drawCircle(
$center
, $width
, $height
, $color
, [ $filled
= true] )
Draw circle |
public void |
drawCircleSector(
$center
, $width
, $height
, $startAngle
, $endAngle
, $color
, [ $filled
= true] )
Draws a sector of cirlce |
public void |
drawCircularArc(
$center
, $width
, $height
, $size
, $startAngle
, $endAngle
, $color
, [ $filled
= true] )
Draws a circular arc |
public void |
drawImage(
$file
, $position
, $width
, $height
)
Draw an image |
public void |
drawLine(
$start
, $end
, $color
, [ $thickness
= 1.] )
Draws a line |
public void |
drawPolygon(
$points
, $color
, [ $filled
= true] , [ $thickness
= 1.] )
Draws a single polygon. |
public void |
drawTextBox(
$string
, $position
, $width
, $height
, $align
, [ $rotation
= null] )
Writes text in a box of desired size |
protected string |
encode(
$string
)
Encodes non-utf-8 strings |
protected string |
getGradientUrl(
$color
)
Return gradient URL |
public string |
getMimeType(
)
Return mime type for current image format |
public DOMDocument |
getResource(
)
Get resource of rendered result |
protected string |
getStyle(
$color
, [ $filled
= true] , [ $thickness
= 1.] )
Get SVG style definition |
protected ezcGraphBoundings |
getTextBoundings(
$size
, $font
, $text
)
Returns boundings of text depending on the available font extension |
protected void |
getTextWidth(
$string
, $size
)
Guess text width for string |
public void |
render(
$file
)
Finally save image |
public void |
renderToOutput(
)
Render image directly to output |
Inherited Methods
From ezcGraphDriver | |
---|---|
public abstract void |
ezcGraphDriver::drawCircle()
Draw circle |
public abstract void |
ezcGraphDriver::drawCircleSector()
Draws a sector of cirlce |
public abstract void |
ezcGraphDriver::drawCircularArc()
Draws a circular arc |
public abstract void |
ezcGraphDriver::drawImage()
Draw an image |
public abstract void |
ezcGraphDriver::drawLine()
Draws a line |
public abstract void |
ezcGraphDriver::drawPolygon()
Draws a single polygon. |
public abstract void |
ezcGraphDriver::drawTextBox()
Writes text in a box of desired size |
public abstract string |
ezcGraphDriver::getMimeType()
Return mime type for current image format |
protected abstract ezcGraphBoundings |
ezcGraphDriver::getTextBoundings()
Returns boundings of text depending on the available font extension |
protected array |
ezcGraphDriver::reduceEllipseSize()
Reduce the size of an ellipse |
protected array( |
ezcGraphDriver::reducePolygonSize()
Reduces the size of a polygon |
public abstract void |
ezcGraphDriver::render()
Finally save image |
public void |
ezcGraphDriver::renderToOutput()
Render image directly to output |
protected mixed |
ezcGraphDriver::testFitStringInTextBox()
Test if string fits in a box with given font size |
protected void |
ezcGraphDriver::tryFitShortenedString()
If it is allow to shortened the string, this method tries to extract as many chars as possible to display a decent amount of characters. |
Methods
createDocument
Creates the DOM object to insert SVG nodes in.
If the DOM document does not exists it will be created or loaded according to the settings.
drawAllTexts
Draw all collected texts
The texts are collected and their maximum possible font size is calculated. This function finally draws the texts on the image, this delayed drawing has two reasons:
1) This way the text strings are always on top of the image, what results in better readable texts 2) The maximum possible font size can be calculated for a set of texts with the same font configuration. Strings belonging to one chart element normally have the same font configuration, so that all texts belonging to one element will have the same font size.
drawCircle
Draw circle
Parameters:
Name | Type | Description |
---|---|---|
$center |
ezcGraphCoordinate | Center of ellipse |
$width |
mixed | Width of ellipse |
$height |
mixed | height of ellipse |
$color |
ezcGraphColor | Color |
$filled |
mixed | Filled |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawCircle() |
Draw circle |
drawCircleSector
Draws a sector of cirlce
Parameters:
Name | Type | Description |
---|---|---|
$center |
ezcGraphCoordinate | Center of circle |
$width |
mixed | Width |
$height |
mixed | Height |
$startAngle |
mixed | Start angle of circle sector |
$endAngle |
mixed | End angle of circle sector |
$color |
ezcGraphColor | Color |
$filled |
mixed | Filled; |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawCircleSector() |
Draws a sector of cirlce |
drawCircularArc
Draws a circular arc
Parameters:
Name | Type | Description |
---|---|---|
$center |
ezcGraphCoordinate | Center of ellipse |
$width |
integer | Width of ellipse |
$height |
integer | Height of ellipse |
$size |
integer | Height of border |
$startAngle |
float | Starting angle of circle sector |
$endAngle |
float | Ending angle of circle sector |
$color |
ezcGraphColor | Color of Border |
$filled |
bool |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawCircularArc() |
Draws a circular arc |
drawImage
Draw an image
The image will be inlined in the SVG document using data URL scheme. For this the mime type and base64 encoded file content will be merged to URL.
Parameters:
Name | Type | Description |
---|---|---|
$file |
mixed | Image file |
$position |
ezcGraphCoordinate | Top left position |
$width |
mixed | Width of image in destination image |
$height |
mixed | Height of image in destination image |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawImage() |
Draw an image |
drawLine
Draws a line
Parameters:
Name | Type | Description |
---|---|---|
$start |
ezcGraphCoordinate | Start point |
$end |
ezcGraphCoordinate | End point |
$color |
ezcGraphColor | Line color |
$thickness |
float | Line thickness |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawLine() |
Draws a line |
drawPolygon
Draws a single polygon.
Parameters:
Name | Type | Description |
---|---|---|
$points |
array | Point array |
$color |
ezcGraphColor | Polygon color |
$filled |
mixed | Filled |
$thickness |
float | Line thickness |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawPolygon() |
Draws a single polygon. |
drawTextBox
Writes text in a box of desired size
Parameters:
Name | Type | Description |
---|---|---|
$string |
string | Text |
$position |
ezcGraphCoordinate | Top left position |
$width |
float | Width of text box |
$height |
float | Height of text box |
$align |
int | Alignement of text |
$rotation |
ezcGraphRotation |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::drawTextBox() |
Writes text in a box of desired size |
encode
Encodes non-utf-8 strings
Transforms non-utf-8 strings to their hex entities, because ext/DOM fails here with conversion errors.
Parameters:
Name | Type | Description |
---|---|---|
$string |
string |
getGradientUrl
Return gradient URL
Creates the definitions needed for a gradient, if a proper gradient does not yet exists. In each case a URL referencing the correct gradient will be returned.
Parameters:
Name | Type | Description |
---|---|---|
$color |
ezcGraphColor | Gradient |
getMimeType
Return mime type for current image format
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::getMimeType() |
Return mime type for current image format |
getResource
Get resource of rendered result
Return the resource of the rendered result. You should not use this method before you called either renderToOutput() or render(), as the image may not be completely rendered until then.
getStyle
Get SVG style definition
Returns a string with SVG style definitions created from color, fillstatus and line thickness.
Parameters:
Name | Type | Description |
---|---|---|
$color |
ezcGraphColor | Color |
$filled |
mixed | Filled |
$thickness |
float | Line thickness. |
getTextBoundings
Returns boundings of text depending on the available font extension
Parameters:
Name | Type | Description |
---|---|---|
$size |
float | Textsize |
$font |
ezcGraphFontOptions | Font |
$text |
string | Text |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::getTextBoundings() |
Returns boundings of text depending on the available font extension |
getTextWidth
Guess text width for string
The is no way to know the font or fontsize used by the SVG renderer to render the string. We assume some character width defined in the SVG driver options, tu guess the length of a string. We discern between numeric an non numeric strings, because we often use only numeric strings to display chart data and numbers tend to be a bit wider then characters.
Parameters:
Name | Type | Description |
---|---|---|
$string |
mixed | |
$size |
mixed |
render
Finally save image
Parameters:
Name | Type | Description |
---|---|---|
$file |
string | Destination filename |
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::render() |
Finally save image |
renderToOutput
Render image directly to output
The method renders the image directly to the standard output. You normally do not want to use this function, because it makes it harder to proper cache the generated graphs.
Redefinition of:
Method | Description |
---|---|
ezcGraphDriver::renderToOutput() |
Render image directly to output |