SVGGraph options: shape
- 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
orFALSE
value, or any values that convert easily such as1
,"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
orfloat
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
or1.63e5
orM_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:
-
circle
Draws a circle. The required fields are
cx
,cy
andr
, the centre coordinates and radius. -
ellipse
Draws an ellipse. The required fields are
cx
,cy
,rx
andry
. These are the centre coordinates and the X radius and Y radius. -
rect
Draws a rectangle. The required fields are
x
,y
,width
andheight
. Some useful optional fields arerx
andry
, 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
andy2
, 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
andtype
, and the standard marker optionsmarker_size
andmarker_angle
are available as the fieldssize
andangle
. -
image
Draws an image. The required fields are
x
,y
andsrc
. The optional fieldswidth
andheight
can be used to override the image's natural size, and the boolean optionstretch
(defaultfalse
) can be set totrue
to enable stretching the shape of the image. -
figure
Draws a figure. The required fields are
x
,y
andname
, which should be the name that you gave to the figure. Figures are user-defined shapes created using thefigure
option, and they cannot be altered using the stroke, fill and other styling options. Theclip_to_grid
anddepth
options will work though. -
text
Draws a string of text. The required fields are
x
,y
andtext
, which should be the string to display. By default the text shape'sfill
is set to black, thefont
is set to "Arial" and thefont_size
is set to 14. Text shapes also support the optionstext_align
(left, centre or right) andline_spacing
(which defaults to the font size). - See also:
- label marker_type figure
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:
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.