RMC_AddLegend function.
Add a legend to a region of an existing chart

Syntax
nResult (LONG) = RMC_AddLegend(
ByVal nCtrlId (LONG),
ByVal nRegion (LONG),
ByRef sLegendtext (ASCIIZ),
Optional ByVal nAlignment (LONG),
Optional ByVal nBackColor (LONG),
Optional ByVal nStyle (LONG),
Optional ByVal nTextColor (LONG),
Optional ByVal nFontsize (LONG),
Optional ByVal nFontbold (LONG)
)
Parameter
nCtrlId (LONG)
Unique ID of the chart control, to which the legend belongs.
nRegion (LONG)
Region to which the legend belongs.
sLegendtext (ASCIIZ)
String with the legend texts. The legend texts must be separated with an asterisk * ("Legend1*Legend2*Legend3"). The maximum length of each legend text can be 100 chars.
nAlignment (LONG)
Alignment of the legend within the region as a legend alignment constant.
If omitted or 0: RMC_LEGEND_BOTTOM. See Remarks
nBackColor (LONG)
BackColor of the legend as a Color... constant. If omitted or 0: ColorLightYellow
nStyle (LONG)
Style of the legend as a legend style constant. If omitted or 0: RMC_LEGENDRECT
nTextColor (LONG)
Textcolor of the legend text as a Color...constant. If omitted or 0: ColorBlack
nFontsize (LONG)
Fontsize of the legend text in points. If omitted or 0: 8 point
nFontbold (LONG)
If TRUE, font is bold. If omitted or 0: FALSE.
Return value
0
No error, function succeeded.
RMC_ERROR_CTRLID
Wrong control ID (0 or no chart with this control ID was found).
RMC_ERROR_MAXREGION
The region index exceeds the maximum possible numbers of regions (6) within a chart control.
RMC_ERROR_WRONGREGION
The region index is inexistent in the chart control.
RMC_ERROR_NODATA
The array with the legend text is empty.
RMC_ERROR_ALLOC
Error while allocating memory for the legend text.
Remarks
You can choose between 19 different positions for your legend. Basically there are two "classes" of legend alignments: Custom alignments (e.g. RMC_LEGEND_CUSTOM_TOP) and non-custom alignments (e.g. RMC_LEGEND_TOP). The non-custom alignments affect the size and position of the remaining chart: first takes place the calculation of the required width and height to draw the legend, then the legend is painted and then, in the remaining space, the rest of the chart.
The alignment RMC_LEGEND_ONVLABELS is only valid with non-grid based series (Pie/Donut/Pyramide). In this case the legend's text will be printed on the value label of each segment, with or without the values, dependend which style for the value labels you choose in RMC_AddGridlessSeries.