Multiple legend boxes can be displayed, positioned at different locations and showing the titles of
distinct groups of series. For example, a chart displaying two vertical scales can
have one legend box to the left and another one to the right, showing the titles of series whose data points are
plotted against the left and vertical scales, respectively.
There is no limit on the number of legend boxes that can be added to the chart context. By default, only one legend box
is displayed, showing the titles of all series added to the chart context. The default legend box, referred to as the
primary legend box, is automatically created. Any additional legend box, referred to as a secondary legend box, has to
be explicitly created and added.
The only applets that support multiple legend boxes are GraphApplet and ScatterApplet.
PieApplet doesn't support.
Each legend box is assigned an index. The primary one has index 0 and secondary legend boxes are sequentially assigned
indexes in the order they are added to the chart context, starting with number 1. These indexes are used to get
references to respective legend boxes.
To create secondary legend boxes and add them to the chart context, use the parameter nroflegends to
specify the number of legend boxes to be created, as follow:
<param name="nroflegends" value="3">
Three secondary legend boxes are created, with indexes 1, 2 and 3.
To display the title of a series inside a secondary legend box, do as follow:
<param name="serie1_legendindex" value="2">
The title of a series with index 1 will be displayed inside a secondary legend box with
index 2.
By default, the orientation of a legend box is automatic. If it is placed at the bottom side, series titles are
displayed side by side(horizontal orientation), and if it is placed at the left or right sides, series titles are
stacked one above the other(vertical orientation).
To disable auto orientation and set orientation manually, use the parameters
legendx_autoorientationon and legendx_orientation. Set the former to no and
pass one of the values below to the latter:
The legend box is, by default, automatically centered at the bottom of the chart area.
Six values can be used to specify the position of the legend box, using the parameter
legendx_position:
To dynamically change the legend box position, double click it to toggle chart into a 'moving legend' state.
While in this mode, a red thick line surrounds the legend box and the chart does not answer to mouse events,
like dragging or resizing, until the legend box is dropped onto the desired position. After toggling chart state,
move mouse cursor to the position where the legend box will be moved to and do the following:
If auto orientation is disabled and position is set to 5 (anywhere), an outlined rectangle painted in red and with the same dimensions of the legend box follows the movement of the mouse cursor. Just click any coordinate within the chart area and the legend box is moved to the desired location.