SVGGraph custom labels

There are options for labelling the axes, bars, pie slices and other data
objects, but sometimes you just want a label saying what you want and where you
want it. This is where custom labels come in handy.

Using custom labels

The example line graph below shows several custom labels, not labelling
anything in particular.

Custom labels

The four labels in the centre of the graph are all labelling the grid point
(40, 100). The yellow bubble label is labelling the absolute SVG pixel
location (200, 100). The blue label points to a location just to
right of the yellow label, with an offset position moving it down and to the
right. The six white labels in the bottom left corner show how the labels are
drawn in the order they appear in the array, with later labels drawn over the
top of previous labels.

This example creates a label for the coordinates (200, 150),
containing the text “Label at 200, 150”. The angle
option rotates the text 90° and the position option places the
label below the given coordinates.

Note - the coordinates are the position of whatever is being labelled, not
where the label itself will appear. The actual position of the label is
controlled by the position and space options.

The coordinates can be simple numbers for use on any type of graph, or you
can use relative positioning coordinates, as described on the
shapes page.

Label options

Custom labels support most of the same options as the data labels, but with
some minor differences. Since these options only appear as part of the
label option, their names are shortened to type,
space and so on, instead of data_label_type or
data_label_space.

Since the custom labels are not labelling anything clearly defined, the
interactive Javascript fading, click to hide/show and pop to front options
supported by data labels are not available.

One final option that is not listed here but does affect custom labels is the
data_label_max_count option, which limits the number of labels in
a dataset that are shown. All the custom labels exist in a single virtual
dataset, so you need to make sure that the number of custom labels is smaller
than the data_label_max_count value or some of them will be hidden.

The defaults listed here are actually the default values for the underlying
data_label_* options. Custom labels will inherit the values from
any related data_label_* options that you set.