PHP Класс Graph, GotCms

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$defs
$force_assoc
$gradients
$javascript
$legend_reverse
$link_base
$link_target
$links
$namespaces
$settings
$values

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
LoadJavascript ( ) Loads the Javascript class
MakeLinearGradient ( $id, $colours ) Creates a linear gradient element

Описание методов

AddEventHandler() защищенный Метод

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

AddFunction() защищенный Метод

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

AddOverlay() защищенный Метод

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() защищенный Метод

Checks if the keys are associative
protected AssociativeKeys ( )

AutoHide() защищенный Метод

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

BackgroundImage() защищенный Метод

Displays the background image
protected BackgroundImage ( )

Canvas() защищенный Метод

Displays the background
protected Canvas ( $id )

CheckValues() защищенный Метод

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

ContrastText() защищенный Метод

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

CountLines() защищенный статический Метод

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

Draw() абстрактный защищенный Метод

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

DrawGraph() публичный Метод

Draws the selected graph
public DrawGraph ( )

DrawLegend() защищенный Метод

Draws the legend
protected DrawLegend ( )

DrawLegendEntry() защищенный Метод

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

DrawTitle() защищенный Метод

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

Element() защищенный Метод

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

ErrorText() защищенный Метод

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

Fetch() публичный Метод

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

FetchJavascript() публичный Метод

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

GetColour() защищенный Метод

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

GetFirst() защищенный статический Метод

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

GetKey() защищенный Метод

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

GetLinkURL() защищенный Метод

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

GetMaxKey() защищенный Метод

Returns the maximum key value
protected GetMaxKey ( )

GetMaxValue() защищенный Метод

Returns the maximum value
protected GetMaxValue ( )

GetMinKey() защищенный Метод

Returns the minimum key value
protected GetMinKey ( )

GetMinValue() защищенный Метод

Returns the minimum value
protected GetMinValue ( )

GetValues() защищенный Метод

Returns a row of values
protected GetValues ( $row )

InsertComment() публичный Метод

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

InsertVariable() публичный Метод

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

NewID() публичный Метод

Creates a new ID for an element
public NewID ( )

ParsePosition() защищенный Метод

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

RelativePosition() публичный статический Метод

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() публичный Метод

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

SetDraggable() защищенный Метод

Makes an item draggable
protected SetDraggable ( &$element )

SetFader() защищенный Метод

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

SetStroke() защищенный Метод

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

SetTooltip() защищенный Метод

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() публичный Метод

Sets the options
public Settings ( &$settings )

Text() защищенный Метод

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

TextFit() защищенный Метод

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

TextLines() защищенный Метод

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

TextSize() защищенный Метод

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

TooltipText() защищенный Метод

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

Values() публичный Метод

Sets the graph values
public Values ( $values )

__construct() публичный Метод

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

__get() публичный Метод

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

Описание свойств

$defs защищенное свойство

protected $defs

$force_assoc защищенное свойство

protected $force_assoc

$gradients защищенное свойство

protected $gradients

$javascript защищенное статическое свойство

protected static $javascript

$legend_reverse защищенное свойство

protected $legend_reverse

$namespaces защищенное свойство

protected $namespaces

$settings защищенное свойство

protected $settings

$values защищенное свойство

protected $values