SVGGraph general settings

« Return to SVGGraph page

Many of the ways that things are displayed on the graphs may be changed by passing in an array of settings to the SVGGraph constructor:

<?php
require_once('SVGGraph.php');
$width = 500;
$height = 400;
$settings = array(
  'back_colour' => 'white',
  'graph_title' => 'Start of Fibonacci series'
);
 
$graph = new SVGGraph($width, $height, $settings);
$graph->Values(0, 1, 1, 2, 3, 5, 8, 13, 21);
$graph->Render('BarGraph');
?>

The list of options that are valid for all types of graph and their default values are shown below. Sizes are always in pixels - you should not append 'px' or any other CSS units.

Because the settings are stored in a standard PHP array, numbers, boolean values (true and false) and NULL values should be used without surrounding quotes. All other values (except arrays) are strings, and should be quoted with either single or double quotes.

A full list of all options which can be filtered by graph type or tag is available on the options index page.

General options - Hide table

OptionDefaultDescription
title NULL Contents of title tag, or NULL for none
description NULL Contents of desc tag, or NULL for none
auto_fit false If true, the SVG will scale to fit inside its container element
stroke_colour rgb(0,0,0) Colour of graph lines
stroke_width 1 Thickness of graph lines, 0 disables line drawing
stroke_dash[1] NULL Dash pattern for graph lines, NULL for complete lines
back_colour[2] rgb(240,240,240) Background colour of graph (use "none" for transparent)
back_round 0 Radius of rounded background edge
back_round_clip false If true, adds a clip path to the background rectangle to prevent drawing over the rounded corners
back_stroke_width 1 Thickness of background edge
back_stroke_colour rgb(0,0,0) Colour of background edge
back_image NULL Image to use for background (NULL for none). See the SVGGraph background image page for details.
back_image_width 100% Width of background image
back_image_height 100% Height of background image
back_image_opacity 1.0 Opacity of background image (0.0-1.0)
back_image_top 0 Top offset of background image
back_image_left 0 Left offset of background image
back_image_mode auto Background image display method. Options are:
auto
image will be uniformly scaled to fit in width and height;
tile
image will be tiled in blocks using width and height;
stretch
image will be stretched to fit width and height
pad_top 10 Space at top of graph
pad_bottom 10 Space at bottom of graph
pad_left 10 Space to left of graph
pad_right 10 Space to right of graph
link_base Prepended to all links
link_target _blank Link target frame
namespace false Option to use the svg: namespace prefix
doctype false Option to output the DOCTYPE
svg_class NULL Class name for root SVG element, NULL for none
encoding UTF-8 Sets the character encoding in the XML declaration
exception_details false When enabled, some extra details about thrown exceptions are displayed
exception_throw false When enabled, exceptions are not caught by SVGGraph
decimal . Decimal point character for axis labels, etc.
thousands , Thousands separator for axis labels, etc.
force_assoc false When enabled, treats values array as associative even if its keys are numeric
show_tooltips true Enables display of tooltips over graph markers
tooltip_colour black Tooltip text/border colour
tooltip_stroke_width 1 Tooltip border thickness
tooltip_back_colour[2] #ffffcc Tooltip rectangle background colour
tooltip_font sans-serif Font for tooltips
tooltip_font_weight normal Tooltip font weight
tooltip_font_size 10 Tooltip font size
tooltip_padding 3 Tooltip rectangle padding
tooltip_round 0 Radius of rounded tooltip corner
tooltip_shadow_opacity 0.3 Opacity of tooltip shadow (0.0-1.0, 0 disables shadow)
tooltip_offset 10 Distance between cursor and tooltip
tooltip_callback NULL Name of callback function for formatting tooltip text. The function will be called with three arguments: callback($dataset, $key, $value). The function should return a text string to display or NULL for no tooltip. Takes precedence over structured data tooltip values.
units_tooltip NULL Units shown after value on tooltip
units_before_tooltip NULL Units shown before value on tooltip
units_tooltip_key NULL Units shown after key (X) value on tooltip
units_before_tooltip_key NULL Units shown before key (X) value on tooltip
compat_events false Set to TRUE to fall back to inline event handlers, required by Adobe IE plugin
graph_title NULL Title displayed on the graph
graph_title_font sans-serif Font for graph title
graph_title_font_size 12 Font size for graph title
graph_title_font_weight normal Font weight for graph title
graph_title_space 10 Spacing around graph title
graph_title_colour rgb(0,0,0) Colour of graph title
graph_title_position top Where to show graph title ("top", "bottom", "left", "right")
show_legend true Enables displaying the legend. Entries for the legend must be supplied using legend_entries or structured data legend_text options.
legend_entries NULL Array of entries for the legend
legend_position top right Position of the legend. Supports "top", "bottom", "left", "right", "inner", "outer" and pairs of X and Y offsets
legend_stroke_width 1 Thickness of legend border
legend_stroke_colour rgb(0,0,0) Colour of legend border
legend_back_colour[2] rgb(255,255,255) Colour of legend background
legend_round 0 Radius of rounded corners for legend border
legend_shadow_opacity 0.3 How dark the shadow is (1 = black, 0 = no shadow)
legend_font sans-serif Font for legend entries
legend_font_weight normal Font weight for legend entries
legend_font_size 10 Font size for legend entries
legend_font_adjust 0.6 Ratio of font width to height
legend_colour rgb(0,0,0) Colour of legend entries text
legend_padding 5 Amount of spacing between entries in legend
legend_entry_width 20 Width of legend entry box
legend_entry_height 20 Height of legend entry box
legend_columns 1 Number of columns to display entries in
legend_title Title for legend
legend_title_font NULL Font for legend title (NULL = use legend_font)
legend_title_font_size NULL Font size for legend title (NULL = use legend_font_size)
legend_title_font_weight bold Font weight for legend title
legend_title_font_adjust NULL Ratio of font width to height (NULL = use legend_font_adjust)
legend_title_colour NULL Colour of legend title (NULL = use legend_colour)
legend_text_side right Which side of the entry box the text should be on ("left" or "right")
legend_draggable true Makes the legend draggable with the mouse
legend_autohide false Makes the legend hide when the cursor is over it
legend_show_empty false Set to TRUE to display legend entries for 0 or NULL values
structured_data false Set to TRUE to enable structured data support
structure NULL Sets the structure to use with structured data
datetime_keys false Turns on parsing of keys as date/time values. Enables the date/time axis for grid-based graphs
datetime_key_format NULL Parse format for use with datetime_keys option. The format string should be one supported by the DateTime::createFromFormat() function.
minify true Removes extra whitespace from SVG content
minify_js NULL Callback function for minifying Javascript code. Function must accept a string of Javascript as input and return the minified code as a string
empty_use true Outputs <use ...></use> instead of <use .../> to work around Safari bug
semantic_classes false When enabled, adds classes around bars, pie slices, graph lines and markers for use in scripting
shape NULL Shapes to be drawn on the graph. See the shapes page for details
show_data_labels false Displays labels for bars, markers, pie slices
data_label_type plain The style of label to use. Options are "plain", "box", "bubble" or "line"
data_label_space 3 The space between the label and the data item.
data_label_font sans-serif Font used for label
data_label_font_size 10 Font size for data label
data_label_font_adjust 0.6 Font adjust value for label text
data_label_font_weight normal Font weight for data label
data_label_colour rgb(0,0,0) Text colour for data label
data_label_colour_outside NULL Text colour for data label when outside bar/slice. NULL for same colour as when inside
data_label_back_colour NULL Colour for label text border, or NULL for none
data_label_back_colour_outside NULL Colour for label text border when outside bar/slice, or NULL for same as when inside
data_label_position top Position of data label relative to bar/marker/slice. See the data labels page for details
data_label_angle 0 Text angle for data labels
data_label_padding 3 Space between data label text and edge of label box
data_label_padding_x NULL Horizontal space between data label text and edge of label box, overrides data_label_padding
data_label_padding_y NULL Vertical space between data label text and edge of label box, overrides data_label_padding
data_label_round 0 Radius of rounded corners for box or bubble style data labels
data_label_fill white Background colour, gradient or pattern for box or bubble style data labels
data_label_outline_colour rgb(0,0,0) Edge colour for data labels
data_label_outline_thickness 1 Line thickness for data labels
data_label_tail_length 3 Length of tail for line or bubble style data labels
data_label_tail_width 5 Thickness of tail for bubble style data labels
data_label_shadow_opacity 0.3 Opacity of data label shadows
data_label_fade_in_speed 0 Fade in speed for data labels
data_label_fade_out_speed 0 Fade out speed for data labels
data_label_click false Set to TRUE to enable show/hide labels by clicking bar/marker/slice
data_label_popfront false Set to TRUE to pop the label of the bar/marker/slice under the cursor to top
data_label_filter NULL Filters the list of data labels to be displayed. See the data labels page for details
data_label_max_count 100 Maximum number of data labels to display for a dataset (after filtering)
data_label_min_space 0 Sets the minimum space required for a label to be shown. For vertical bars this is the height of the bar, for horizontal bars it is the width and for pie slices it is the angle in degrees. Has no effect on line and scatter graphs.
data_label_callback NULL Name of callback function for formatting data label text. The function will be called with three arguments: callback($dataset, $key, $value). The function should return a text string to display or NULL for no label. Takes precedence over structured data label values.
units_label NULL Units string to display after value in data labels
units_before_label NULL Units string to display before value in data labels
label NULL Custom labels to display on the graph. See the custom labels page for details.
General options

For details of the options specific to each type of graph, please visit the relevant page:

For more examples and for complete explanations of some of these options, take a look at the background image page, the axis and grid dimensions page, the titles and axis labels page and the legends page.

« Back to top of page Bar graphs »