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/autoloader.php';

$width = 500;
$height = 400;

$settings = array(
  'back_colour' => 'white',
  'graph_title' => 'Start of Fibonacci series'
);

$graph = new Goat1000\SVGGraph\SVGGraph($width, $height, $settings);

$graph->values(0, 1, 1, 2, 3, 5, 8, 13, 21);
$graph->render('BarGraph');

A 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 available options, which can be filtered by graph type or tag, is available on the options index page.

The table below lists all options tagged as global from the index.

Global options - Hide table

OptionDefaultDescription
auto_fit false Enables automatic scaling of the SVG document.
back_colour "rgb(240,240,240)" Background colour of graph, or "none" for transparent background.
back_image NULL Image to use for background , or NULL for none.
back_image_height "100%" Height of background image.
back_image_left 0 Left offset of background image.
back_image_mode "auto" Background image display method.
back_image_opacity NULL Opacity of background image (0.0-1.0)
back_image_top 0 Top offset of background image.
back_image_width "100%" Width of background image.
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_shadow false Enables a shadow for the graph background rectangle.
back_shadow_blur 0 Amount of blurring for the background rectangle shadow.
back_shadow_opacity 0.3 Sets opacity of background rectangle shadow.
back_stroke_colour "rgb(0,0,0)" Colour of background edge.
back_stroke_width 1 Thickness of background edge.
compat_events false Enable inline event handlers.
context_back_colour "#fff" Background colour of context menu.
context_callback null Callback function for context menu.
context_colour "black" Colour of context menu title text and border.
context_document_menu false Enables the browser context menu.
context_font "Arial" Sets the font for the context menu.
context_font_size 15 Font size for context menu.
context_font_weight "normal" Font weight for context menu.
context_global null Sets the global context menu contents.
context_link_colour "#00f" Colour of links on context menu.
context_link_hover_colour "#f00" Colour of context menu link under cursor.
context_link_target "_top" Target for links in context menu.
context_link_underline true Enables or disables underlining context menu links.
context_min_width 60 Sets the minimum width of the context menu.
context_mouseleave 100 Time to leave context menu open after mouse leaves document.
context_padding 3 Padding inside context menu.
context_padding_x null Horizontal padding inside context menu.
context_padding_y null Vertical padding inside context menu.
context_round 0 Radius of rounded context menu corners.
context_shadow_opacity 0.3 Opacity of context menu shadow.
context_spacing 3 Spacing between context menu items.
context_stroke_width 1 Thickness of line around context menu.
data_label_align null Data label text alignment.
data_label_angle 0 Text angle for data labels.
data_label_back_colour NULL Colour of label text border.
data_label_back_colour_outside NULL Alternative label text border colour.
data_label_callback NULL Callback function for data label text.
data_label_click false Enables click-to-show/hide for data labels.
data_label_colour "rgb(0,0,0)" Text colour for data labels.
data_label_colour_outside NULL Alternative text colour for data labels.
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_fill "white" Data label background colour.
data_label_filter NULL Limits the data labels displayed.
data_label_font "Arial" Font used for data labels.
data_label_font_adjust 0.6 Font adjust value for label text.
data_label_font_size 10 Font size for data labels.
data_label_font_weight "normal" Font weight for data labels.
data_label_line_spacing null Sets line spacing for data labels.
data_label_max_count 100 Maximum number of data labels to display.
data_label_min_space 0 Minimum space required for label.
data_label_opacity 1 Sets the opacity of 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_padding 3 Space inside data label boxes.
data_label_padding_x NULL Horizontal space in data label box.
data_label_padding_y NULL Vertical space in data label box.
data_label_popfront false Enables pop-to-front for data labels.
data_label_position "top" Position of data label.
data_label_round 0 Radius of data label corners.
data_label_same_size false Determines if all data labels should be the same size.
data_label_shadow_opacity 0.3 Opacity of data label shadows.
data_label_space 3 The space between the label and the data item.
data_label_tail_end "flat" Style of data label tail ending.
data_label_tail_end_angle 45 Angle of data label tail ending.
data_label_tail_end_width 10 Width of data label tail ending.
data_label_tail_length 3 Length of data label tails.
data_label_tail_width 5 Thickness of data label tails.
data_label_type "plain" The style of label to use.
dataset null Specifies the datasets the graph should use.
datetime_key_format NULL This option specifies the date/time format of the data keys, used when the datetime_keys option is enabled. The default value of NULL means that no specific format is in use.
datetime_keys false Parses data keys as date/time values.
decimal "." Decimal point character for axis labels, etc.
description NULL The <desc> content used for the SVG document.
doctype false When enabled, outputs the SVG doctype declaration at the start of the document.
empty_use true Outputs <use ...></use> instead of <use .../> to work around Safari bug.
encoding "UTF-8" Sets the character encoding in the XML declaration and used throughout SVGGraph.
exception_details false When enabled, some extra details about thrown exceptions are displayed.
exception_throw false When enabled, exceptions are not caught by SVGGraph.
figure null Defines a shape or group of shapes for reuse.
force_assoc false Treats data keys as strings instead of numbers.
graph_subtitle null Sets the sub-title for the graph.
graph_subtitle_colour null Sets the colour of the graph sub-title.
graph_subtitle_font null Sets the font for use by the graph sub-title.
graph_subtitle_font_size 10 Sets the font size for the graph sub-title.
graph_subtitle_font_weight null Sets the font weight for the graph sub-title.
graph_subtitle_line_spacing null Sets line spacing for graph subtitles.
graph_subtitle_space 5 Sets the distance between the graph sub-title and main title.
graph_title "" Title displayed on the graph.
graph_title_colour "black" Colour of graph title text.
graph_title_font "Arial" 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_line_spacing null Sets line spacing for graph titles.
graph_title_position "top" Position of graph title.
graph_title_space 10 Spacing around graph title.
guideline_line_spacing null Sets line spacing for guideline text.
id_prefix "" Inserts a prefix string in front of all generated element ids.
label NULL Adds custom labels to the graph.
legend_autohide false Makes the legend hide when the cursor is over it.
legend_autohide_opacity 0 Opacity of legend when hidden.
legend_back_colour "white" Colour of legend background.
legend_colour "black" Colour of legend entries text.
legend_column_spacing null Spacing between legend columns.
legend_columns 1 Number of columns in which to display entries.
legend_draggable true Makes the legend draggable with the mouse.
legend_entries NULL Array of entries for the legend.
legend_entries_callback null Allows modification of legend entries.
legend_entry_height 20 Height of legend entry box.
legend_entry_spacing null Spacing between legend entry text and shape.
legend_entry_width 20 Width of legend entry box.
legend_font "Arial" Font for legend entries.
legend_font_adjust 0.6 Ratio of font width to height.
legend_font_size 10 Font size for legend entries.
legend_font_weight "normal" Font weight for legend entries.
legend_line_spacing null Sets line spacing for legend entries.
legend_order "auto" Sets the order that entries appear in the legend.
legend_padding 5 Amount of spacing between entries in legend.
legend_padding_x null Sets padding at left and right sides of legend.
legend_padding_y null Sets padding at top and bottom of legend.
legend_position "top right" Position of the legend.
legend_round 0 Radius of rounded corners for legend border.
legend_shadow_opacity 0.3 Darkness of shadow.
legend_show_empty false Set to true to display legend entries for 0 or NULL values.
legend_spacing null Spacing between legend entries.
legend_stroke_colour "black" Colour of legend border.
legend_stroke_width 1 Thickness of legend border.
legend_text_side "right" Side on which to put entry text.
legend_title "" Title for legend.
legend_title_colour NULL Colour of legend title.
legend_title_font NULL Font for legend title.
legend_title_font_adjust NULL Ratio of font width to height.
legend_title_font_size NULL Font size for legend title.
legend_title_font_weight "bold" Font weight for legend title.
legend_title_line_spacing null Sets line spacing for legend titles.
legend_title_link null Sets a link for the legend title.
legend_title_spacing null Spacing between legend title and entries.
legend_type "all" Which data should have legend entries.
legend_unique_fields false Prevents duplicate legend entries.
link_base "" Prepended to all relative links.
link_target "_blank" The target attribute for every link.
magnify 0 Enables Javascript magnifier and sets magnification.
magnify_pan 3 Sets the magnification panning sensitivity.
marker_solid true Disables use of patterns and gradients in markers.
minify true Removes extra whitespace from SVG content.
minify_js NULL Minifies Javascript code.
namespace false When enabled, adds the svg: namespace prefix to all elements.
no_tspan false Outputs multiple <text> elements instead of <text> and <tspan> elements for multi-line text.
pad_bottom 10 Space at bottom of graph.
pad_left 10 Space to left of graph.
pad_right 10 Space to right of graph.
pad_top 10 Space at top of graph.
precision 5 Sets the precision of values output in the SVG content.
semantic_classes false Adds classes to various elements.
shadow_blur 3 Amount of blurring of graph shadow.
shadow_offset_x 5 Horizontal offset of graph shadow.
shadow_offset_y 5 Vertical offset of graph shadow.
shadow_opacity 0.5 Opacity of graph shadow.
shape NULL Adds custom shapes to the graph.
show_context_menu false Enables context menu.
show_data_labels false Displays labels for data items.
show_legend true Enables displaying the legend.
show_shadow false Enables shadow effect beneath graph.
show_tooltips true Enables display of tooltips over bars, pie slices, markers.
stroke_colour "rgb(0,0,0)" Colour of graph lines.
stroke_dash NULL Dash pattern for graph lines, or NULL to draw solid lines.
stroke_width 1 Thickness of graph lines, 0 to disable drawing the lines.
structure NULL Sets the structure for use with structured data.
structured_data false Enables structured data values support.
svg_class NULL Class name for root SVG element, NULL for none.
thousands "," Thousands separator for axis labels, etc.
title NULL The <title> content used for the SVG document.
tooltip_align null Tooltip text alignment.
tooltip_back_colour "#ffffcc" Tooltip rectangle background colour.
tooltip_callback NULL Callback function for formatting tooltip text.
tooltip_colour "black" Tooltip text/border colour.
tooltip_font "Arial" Font for tooltips.
tooltip_font_size 10 Tooltip font size.
tooltip_font_weight "normal" Tooltip font weight.
tooltip_line_spacing null Sets line spacing for tooltips.
tooltip_offset 10 Distance between cursor and tooltip.
tooltip_padding 3 Tooltip rectangle padding.
tooltip_round 0 Radius of rounded tooltip corner.
tooltip_shadow_opacity 0.3 Opacity of tooltip shadow.
tooltip_stroke_colour null Sets colour of border around tooltip.
tooltip_stroke_width 1 Tooltip border thickness.
units_before_label NULL String to display before value in data labels.
units_before_tooltip NULL Units shown before value on tooltip.
units_before_tooltip_key NULL Units shown before key (X value) on tooltip.
units_label NULL String to display after value in data labels.
units_tooltip NULL Units shown after value on tooltip.
units_tooltip_key NULL Units shown after key (X value) on tooltip.
use_iconv true Enables use of iconv extension for character set conversion.
use_mbstring true Enables use of mbstring extension for character set conversion.
Global 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 »

This site uses cookies - details here.