PHP Class Graph, GotCms

Mostrar archivo Open project: gotcms/gotcms Class Usage Examples

Protected Properties

Property Type Description
$defs
$force_assoc
$gradients
$javascript
$legend_reverse
$link_base
$link_target
$links
$namespaces
$settings
$values

Public Methods

Method Description
DrawGraph ( ) Draws the selected graph
Fetch ( $header = TRUE, $defer_javascript = TRUE ) Returns the SVG document
FetchJavascript ( $onload_immediate = TRUE, $cdata_wrap = TRUE, $no_namespace = TRUE ) When using the defer_javascript option, this returns the Javascript block
InsertComment ( $details ) Insert a comment into the Javascript section - handy for debugging!
InsertVariable ( $var, $value, $more = NULL, $quote = TRUE ) Adds a Javascript variable - use $value:$more for assoc - use null:$more for array
Links ( ) Sets the links from each item
NewID ( ) Creates a new ID for an element
RelativePosition ( $pos, $top, $left, $bottom, $right, $width, $height, $pad, $text = false ) Returns the [x,y] position that is $pos relative to the top, left, bottom and right. When $text is true, returns [x,y,align right]
Render ( $header = TRUE, $content_type = TRUE, $defer_javascript = FALSE ) Renders the SVG document
Settings ( &$settings ) Sets the options
Values ( $values ) Sets the graph values
__construct ( $w, $h, $settings = NULL )
__get ( $name ) Retrieves properties from the settings array if they are not already available as properties

Protected Methods

Method Description
AddEventHandler ( &$array, $evt, $code ) Adds an inline event handler to an element's array
AddFunction ( $name ) Adds one or more javascript functions
AddOverlay ( $from, $to ) Add an overlaid copy of an element, with opacity of 0 $from and $to are the IDs of the source and destination
AssociativeKeys ( ) Checks if the keys are associative
AutoHide ( &$element ) Makes something auto-hide
BackgroundImage ( ) Displays the background image
Canvas ( $id ) Displays the background
CheckValues ( &$values ) Checks that the data are valid
ContrastText ( $x, $y, $text, $fcolour = 'black', $bcolour = 'white', $properties = NULL, $styles = NULL ) Displays high-contrast text
CountLines ( $text ) Returns the number of lines in a string
Draw ( ) This should be overridden by subclass!
DrawLegend ( ) Draws the legend
DrawLegendEntry ( $key, $x, $y, $w, $h ) Subclasses must draw the entry, if they can
DrawTitle ( ) Draws the graph title, if there is one
Element ( $name, $attribs = NULL, $styles = NULL, $content = NULL ) Draws an element
ErrorText ( $error ) Displays readable (hopefully) error message
GetColour ( $key, $no_gradient = FALSE ) Returns a colour reference
GetFirst ( ) Returns the first non-empty argument
GetKey ( $index ) Returns the key value for an index, if associative
GetLink ( $key, $content, $row ) Retrieves a link
GetLinkURL ( $key, $row ) Returns a link URL or NULL if none
GetMaxKey ( ) Returns the maximum key value
GetMaxValue ( ) Returns the maximum value
GetMinKey ( ) Returns the minimum key value
GetMinValue ( ) Returns the minimum value
GetValues ( $row ) Returns a row of values
ParsePosition ( $pos, $w, $h, $pad ) Parses a position string, returning x and y coordinates
SetDraggable ( &$element ) Makes an item draggable
SetFader ( &$element, $in, $out, $target = NULL, $duplicate = FALSE ) Sets the fader for an element
SetStroke ( &$attr, $line_join = null ) Sets the stroke options for an element
SetTooltip ( &$element, $key, $value = NULL, $duplicate = FALSE ) Default tooltip contents are key and value, or whatever $key is if $value is not set
Text ( $text, $line_spacing, $attribs, $styles = NULL ) Returns a text element, with tspans for subsequent lines
TextFit ( $text, $x, $y, $w, $h, $attribs = NULL, $styles = NULL ) Fits text to a box - text will be bottom-aligned
TextLines ( $text, $x, $line_spacing ) Formats lines of text
TextSize ( $text, $font_size, $font_adjust, $angle, $line_spacing ) Returns [width,height] of text $text = string OR text length
TooltipText ( $key, $value = NULL ) Sets the text to use for a tooltip

Private Methods

Method Description
LoadJavascript ( ) Loads the Javascript class
MakeLinearGradient ( $id, $colours ) Creates a linear gradient element

Method Details

AddEventHandler() protected method

Adds an inline event handler to an element's array
protected AddEventHandler ( &$array, $evt, $code )

AddFunction() protected method

Adds one or more javascript functions
protected AddFunction ( $name )

AddOverlay() protected method

Add an overlaid copy of an element, with opacity of 0 $from and $to are the IDs of the source and destination
protected AddOverlay ( $from, $to )

AssociativeKeys() protected method

Checks if the keys are associative
protected AssociativeKeys ( )

AutoHide() protected method

Makes something auto-hide
protected AutoHide ( &$element )

BackgroundImage() protected method

Displays the background image
protected BackgroundImage ( )

Canvas() protected method

Displays the background
protected Canvas ( $id )

CheckValues() protected method

Checks that the data are valid
protected CheckValues ( &$values )

ContrastText() protected method

Displays high-contrast text
protected ContrastText ( $x, $y, $text, $fcolour = 'black', $bcolour = 'white', $properties = NULL, $styles = NULL )

CountLines() protected static method

Returns the number of lines in a string
protected static CountLines ( $text )

Draw() abstract protected method

This should be overridden by subclass!
abstract protected Draw ( )

DrawGraph() public method

Draws the selected graph
public DrawGraph ( )

DrawLegend() protected method

Draws the legend
protected DrawLegend ( )

DrawLegendEntry() protected method

Subclasses must draw the entry, if they can
protected DrawLegendEntry ( $key, $x, $y, $w, $h )

DrawTitle() protected method

Draws the graph title, if there is one
protected DrawTitle ( )

Element() protected method

Draws an element
protected Element ( $name, $attribs = NULL, $styles = NULL, $content = NULL )

ErrorText() protected method

Displays readable (hopefully) error message
protected ErrorText ( $error )

Fetch() public method

Returns the SVG document
public Fetch ( $header = TRUE, $defer_javascript = TRUE )

FetchJavascript() public method

When using the defer_javascript option, this returns the Javascript block
public FetchJavascript ( $onload_immediate = TRUE, $cdata_wrap = TRUE, $no_namespace = TRUE )

GetColour() protected method

Returns a colour reference
protected GetColour ( $key, $no_gradient = FALSE )

GetFirst() protected static method

Returns the first non-empty argument
protected static GetFirst ( )

GetKey() protected method

Returns the key value for an index, if associative
protected GetKey ( $index )

GetLinkURL() protected method

Returns a link URL or NULL if none
protected GetLinkURL ( $key, $row )

GetMaxKey() protected method

Returns the maximum key value
protected GetMaxKey ( )

GetMaxValue() protected method

Returns the maximum value
protected GetMaxValue ( )

GetMinKey() protected method

Returns the minimum key value
protected GetMinKey ( )

GetMinValue() protected method

Returns the minimum value
protected GetMinValue ( )

GetValues() protected method

Returns a row of values
protected GetValues ( $row )

InsertComment() public method

Insert a comment into the Javascript section - handy for debugging!
public InsertComment ( $details )

InsertVariable() public method

Adds a Javascript variable - use $value:$more for assoc - use null:$more for array
public InsertVariable ( $var, $value, $more = NULL, $quote = TRUE )

NewID() public method

Creates a new ID for an element
public NewID ( )

ParsePosition() protected method

Parses a position string, returning x and y coordinates
protected ParsePosition ( $pos, $w, $h, $pad )

RelativePosition() public static method

Returns the [x,y] position that is $pos relative to the top, left, bottom and right. When $text is true, returns [x,y,align right]
public static RelativePosition ( $pos, $top, $left, $bottom, $right, $width, $height, $pad, $text = false )

Render() public method

Renders the SVG document
public Render ( $header = TRUE, $content_type = TRUE, $defer_javascript = FALSE )

SetDraggable() protected method

Makes an item draggable
protected SetDraggable ( &$element )

SetFader() protected method

Sets the fader for an element
protected SetFader ( &$element, $in, $out, $target = NULL, $duplicate = FALSE )

SetStroke() protected method

Sets the stroke options for an element
protected SetStroke ( &$attr, $line_join = null )

SetTooltip() protected method

Default tooltip contents are key and value, or whatever $key is if $value is not set
protected SetTooltip ( &$element, $key, $value = NULL, $duplicate = FALSE )

Settings() public method

Sets the options
public Settings ( &$settings )

Text() protected method

Returns a text element, with tspans for subsequent lines
protected Text ( $text, $line_spacing, $attribs, $styles = NULL )

TextFit() protected method

Fits text to a box - text will be bottom-aligned
protected TextFit ( $text, $x, $y, $w, $h, $attribs = NULL, $styles = NULL )

TextLines() protected method

Formats lines of text
protected TextLines ( $text, $x, $line_spacing )

TextSize() protected method

Returns [width,height] of text $text = string OR text length
protected TextSize ( $text, $font_size, $font_adjust, $angle, $line_spacing )

TooltipText() protected method

Sets the text to use for a tooltip
protected TooltipText ( $key, $value = NULL )

Values() public method

Sets the graph values
public Values ( $values )

__construct() public method

public __construct ( $w, $h, $settings = NULL )

__get() public method

Retrieves properties from the settings array if they are not already available as properties
public __get ( $name )

Property Details

$defs protected_oe property

protected $defs

$force_assoc protected_oe property

protected $force_assoc

$gradients protected_oe property

protected $gradients

$javascript protected_oe static_oe property

protected static $javascript

$legend_reverse protected_oe property

protected $legend_reverse

$namespaces protected_oe property

protected $namespaces

$settings protected_oe property

protected $settings

$values protected_oe property

protected $values