SVGGraph options: shape

« Return to SVGGraph options page

Option name:
Default value:
Added in version:
Data type:
array [?]

The datatypes used in this documentation for specifying SVGGraph options are described below. All options can be a literal value of the data type described, a variable containing the data type, or an expression that will produce the data type when evaluated (and they must always be valid PHP expressions).

An array(), the number and data types of its members will depend on the option for which is it used.
A boolean TRUE or FALSE value, or any values that convert easily such as 1, "1", 0 and "".
A callable function, which can be either the name of a function or an anonymous function itself.
Any of the colour values supported by SVG inside a single or double quoted string. These include three and six digit hex codes, RGB and RGBA colours, and colour names. SVG uses "none" for no colour, which generally leaves things transparent.
A colour value or one of the gradients and patterns supported by SVGGraph. See the SVGGraph colours page for details.
A negative or positive whole number or 0.
Any number supported by PHP, for example 1 or -3.2 or 1.63e5 or M_PI.
Single or double quoted strings. Remember to double-quote your strings if you are inserting a line break: "Line 1\nLine 2".
no [?]

Per-dataset options allow specifying one option for all datasets or an array of options to be used for each dataset in turn. If there are more datasets than entries in the option array, the sequence will be repeated.


$settings['widget_taste'] = 'banana';
$settings['widget_colour'] = array('red', 'green', 'blue');

For this example, the widgets for all datasets will taste of banana. The graph will use red widgets for dataset 0, green widgets for dataset 1 and blue widgets for dataset 2. Dataset 3 repeats the sequence so its widgets will be red, dataset 4 will have green widgets and dataset 5 will have blue widgets.

Supported by:
Bar3DGraph BarAndLineGraph BarGraph BoxAndWhiskerGraph BubbleGraph CylinderGraph DonutGraph ExplodedPieGraph FloatingBarGraph GroupedBar3DGraph GroupedBarGraph GroupedCylinderGraph Histogram HorizontalBarGraph HorizontalFloatingBarGraph HorizontalGroupedBarGraph HorizontalStackedBarGraph LineGraph MultiLineGraph MultiRadarGraph MultiScatterGraph Pie3DGraph PieGraph PolarAreaGraph PopulationPyramid RadarGraph ScatterGraph SemiDonutGraph StackedBar3DGraph StackedBarGraph StackedCylinderGraph StackedGroupedBar3DGraph StackedGroupedBarGraph StackedGroupedCylinderGraph StackedLineGraph

Adds custom shapes to the graph.

This option allows you to add your own geometric shapes to the graph in any position.

The value of the option should be either an array containing the details of a single shape, or an array containing multiple shape details arrays.

The only option inside the details array that is common to all types of shape is the first entry which specifies the type of shape to be drawn. The available types and the extra data fields required to draw them are:

  • circle

    Draws a circle. The required fields are cx, cy and r, the centre coordinates and radius.

  • ellipse

    Draws an ellipse. The required fields are cx, cy, rx and ry. These are the centre coordinates and the X radius and Y radius.

  • rect

    Draws a rectangle. The required fields are x, y, width and height. Some useful optional fields are rx and ry, which specify the corner radius in the X and Y directions. For a rounded corner you only need to specify one of them.

  • line

    Draws a straight line. The required fields are x1, y1, x2 and y2, the coordinates of both ends of the line.

  • polyline and polygon

    Draw multiple joined line segments. polyline leaves the shape open, polygon closes the shape by drawing a line from the last point back to the first point.

    The only required field is points, which should be an array containing a list of X and Y coordinates of the points to draw.

All of these are SVG basic shapes, and any fields not mentioned above are passed straight through as attributes to the underlying SVG code with one slight modificiation - any fields with underscores will have them converted to hyphens, so "fill_opacity" will become "fill-opacity" automatically.

The shape option is described in depth on the shapes page.

See also:

« Back to top of page Main SVGGraph page »