HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: Importing

» Return to Contents


sources/svg.php

Global_functions_svg.php

Function summary

void init__svg ()
string _draw_segment (string colour, integer angle, integer radius, integer start_x, integer start_y, integer end_x, integer end_y)
string _draw_key (array data, string start_colour, integer start_x, integer start_y, string units)
string _get_next_colour (string current_colour)
string _start_svg ()
string _finish_svg (string plot)
string _filter_svg_css (string plot)
string _draw_axes (float max_y, float y_scale, string x_label, string y_label)
string _draw_average (float average, float y_scale)
string create_bar_chart (array data, string x_label, string y_label, string x_units, string y_units)
string create_scatter_graph (array data, string x_label, string y_label, string x_units, string y_units)
string create_pie_chart (array data)

void init__svg()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

string _draw_segment(string colour, integer angle, integer radius, integer start_x, integer start_y, integer end_x, integer end_y)

Get the SVG markup for a segment of a circle. It is designed to be used in the construction of a pie chart

Parameters…

Name colour
Description The hexadecimal-formatted colour for the shape
Type string

Name angle
Description The angle of the segment
Type integer

Name radius
Description The radius of the segment
Type integer

Name start_x
Description The X position of the start vertex
Type integer

Name start_y
Description The Y position of the start vertex
Type integer

Name end_x
Description The X position of the end vertex
Type integer

Name end_y
Description The Y position of the end vertex
Type integer

Returns…

Description The SVG markup for the described segment
Type string

Return to the function index for this class Expand: View the source code to this function

string _draw_key(array data, string start_colour, integer start_x, integer start_y, string units)

Get the SVG markup for a key for a chart, such as a pie chart, using the specified data

Parameters…

Name data
Description An array of the data to be keyed up
Type array

Name start_colour
Description The starting colour for the key
Type string

Name start_x
Description The starting X position
Type integer

Name start_y
Description The starting Y position
Type integer

Name units
Description The units (e.g. %)
Default value
Type string

Returns…

Description The SVG markup for the described key
Type string

Return to the function index for this class Expand: View the source code to this function

string _get_next_colour(string current_colour)

Get the next hexadecimal colour from the specified one, where each of the Red, Green or Blue columns can either be 00, 33, 66 or 99, to provide a viewable contrast between two adjacent colours

Parameters…

Name current_colour
Description The hexadecimal-format colour to be incremented
Type string

Returns…

Description The incremented hexadecimal colour
Type string

Return to the function index for this class Expand: View the source code to this function

string _start_svg()

Get the markup required to start a new SVG document

Parameters…

Returns…

Description The markup
Type string

Return to the function index for this class Expand: View the source code to this function

string _finish_svg(string plot)

Get the markup required to finish an SVG document

Parameters…

Name plot
Description The plot markup to insert first
Default value
Type string

Returns…

Description The markup
Type string

Return to the function index for this class Expand: View the source code to this function

string _filter_svg_css(string plot)

Take the SVG and make all the styles inline. Disabled as not needed for native SVG implementations

Parameters…

Name plot
Description The SVG
Type string

Returns…

Description ... made to have inline styles
Type string

Return to the function index for this class Expand: View the source code to this function

string _draw_axes(float max_y, float y_scale, string x_label, string y_label)

Get the markup for a standard pair of axes

Parameters…

Name max_y
Description Maximum Y value
Type float

Name y_scale
Description Y scale
Type float

Name x_label
Description X axis label
Default value X axis
Type string

Name y_label
Description Y axis label
Default value Y axis
Type string

Returns…

Description The markup
Type string

Return to the function index for this class Expand: View the source code to this function

string _draw_average(float average, float y_scale)

Get the markup for an average line

Parameters…

Name average
Description Average value
Type float

Name y_scale
Description Y scale
Type float

Returns…

Description The markup
Type string

Return to the function index for this class Expand: View the source code to this function

string create_bar_chart(array data, string x_label, string y_label, string x_units, string y_units)

Create a bar chart from the specified data and return the SVG markup

Parameters…

Name data
Description The data to be used in the creation of the bar chart
Type array

Name x_label
Description The X axis label
Default value X axis
Type string

Name y_label
Description The Y axis label
Default value Y axis
Type string

Name x_units
Description The X axis units label
Default value
Type string

Name y_units
Description The Y axis units label
Default value
Type string

Returns…

Description The SVG markup for the described bar chart
Type string

Return to the function index for this class Expand: View the source code to this function

string create_scatter_graph(array data, string x_label, string y_label, string x_units, string y_units)

Create a scatter graph using the data provided and return the SVG markup

Parameters…

Name data
Description The data to be used in the creation of the scatter graph
Type array

Name x_label
Description The X axis label
Default value X Axis
Type string

Name y_label
Description The Y axis label
Default value Y Axis
Type string

Name x_units
Description The X axis units label
Default value
Type string

Name y_units
Description The Y axis units label
Default value
Type string

Returns…

Description The SVG markup for the described scatter graph
Type string

Return to the function index for this class Expand: View the source code to this function

string create_pie_chart(array data)

Draw a pie chart with the specified data and return the SVG markup

Parameters…

Name data
Description The data to be used in the creation of the pie chart
Type array

Returns…

Description The SVG markup for the described pie chart
Type string

Return to the function index for this class Expand: View the source code to this function