SVGGraph options: shape

« Return to previous page

Option name:
shape
Default value:
NULL
Added in version:
2.20
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).

array
An array, the number and data types of its members will depend on the option for which is it used.
boolean
A boolean TRUE or FALSE value, or any values that convert easily such as 1, "1", 0 and "".
callback
A callable function, which can be either the name of a function or an anonymous function itself.
colour
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.
fill
A colour value or one of the gradients and patterns supported by SVGGraph. See the SVGGraph colours page for details.
integer
A negative or positive whole number or 0.
measurement
An integer or float value, or a string containing a number followed by one of these CSS units: px, in, cm, mm, pt, pc.
number
Any number supported by PHP, for example 1 or -3.2 or 1.63e5 or M_PI.
string
Single or double quoted strings. Remember to double-quote your strings if you are inserting a line break:
"Line 1\nLine 2".
Per-dataset:
no
Supported by:
ArrayGraph Bar3DGraph BarAndLineGraph BarGraph BoxAndWhiskerGraph BubbleGraph CandlestickGraph CylinderGraph Donut3DGraph DonutGraph EmptyGraph ExplodedDonut3DGraph ExplodedDonutGraph ExplodedPie3DGraph ExplodedPieGraph ExplodedSemiDonut3DGraph ExplodedSemiDonutGraph FloatingBarGraph GanttChart GroupedBar3DGraph GroupedBarGraph GroupedCylinderGraph Histogram HorizontalBar3DGraph HorizontalBarGraph HorizontalFloatingBarGraph HorizontalGroupedBar3DGraph HorizontalGroupedBarGraph HorizontalStackedBar3DGraph HorizontalStackedBarGraph LineGraph MultiLineGraph MultiRadarGraph MultiScatterGraph MultiSteppedLineGraph Pie3DGraph PieGraph PolarArea3DGraph PolarAreaGraph PopulationPyramid RadarGraph ScatterGraph SemiDonut3DGraph SemiDonutGraph StackedBar3DGraph StackedBarAndLineGraph StackedBarGraph StackedCylinderGraph StackedGroupedBar3DGraph StackedGroupedBarGraph StackedGroupedCylinderGraph StackedLineGraph SteppedLineGraph
Tags:
global marker shape figure text

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 first entry in the shape array is the type of shape to draw. Each shape has its own list of required fields for drawing that particular shape, and optional fields can be added to set the colour, line thickness, etc. 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.

  • marker

    Draws one of the predefined SVGGraph markers. The required fields are x, y and type, and the standard marker options marker_size and marker_angle are available as the fields size and angle.

  • image

    Draws an image. The required fields are x, y and src. The optional fields width and height can be used to override the image's natural size, and the boolean option stretch (default false) can be set to true to enable stretching the shape of the image.

  • figure

    Draws a figure. The required fields are x, y and name, which should be the name that you gave to the figure. Figures are user-defined shapes created using the figure option, and they cannot be altered using the stroke, fill and other styling options. The clip_to_grid and depth options will work though.

  • text

    Draws a string of text. The required fields are x, y and text, which should be the string to display. By default the text shape's fill is set to black, the font is set to "Arial" and the font_size is set to 14. Text shapes also support the options text_align (left, centre or right) and line_spacing (which defaults to the font size).

All of these (apart from marker and figure) 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:
label marker_type figure

« Back to top of page Main SVGGraph page »

This site uses cookies - details here.