ChartDirector 5.1 (PHP Edition)

BaseChart.addLegend2


Usage

addLegend2(x, y, noOfCols [, font [, fontSize ]])

Description

Adds a legend box to the chart with grid layout.

In grid layout, the legend box will be divided into a table in which all cells are of of same width. The legend entries will fill the cells from left to right, top to bottom.

The number of columns can be specified using the noOfCols argument. If this argument is set to the special constant AutoGrid (= -2), the number of columns will be automatically determined based on the longest legend entry. If this argument is 0, the legend box will use a flow layout (from left to right and then top to bottom, in which the entries may not be vertically aligned).

In any case, the number of rows in the table is automatically determined so as to have enough cells for all legend entries.

Arguments

ArgumentDefaultDescription
x(Mandatory)The x coordinate of the reference point of the legend box. By default, the reference point is the top-left corner of the box, but can be configured by using TextBox.setAlignment.
y(Mandatory)The y coordinate of the reference point of the legend box. By default, the reference point is the top-left corner of the box, but can be configured by using TextBox.setAlignment.
noOfCols(Mandatory)The number of columns in the legend box. The special value AutoGrid (= -2) means the number of columns is automatically determined. If this argument is 0, the legend box will use a flow layout (from left to right and then top to bottom, in which the entries may not be vertically aligned).
font""The font name of the font for drawing the legend text. The default is "normal". See Font Specification for details on various font attributes.
fontSize10The font size of the legend text.

Return Value

A LegendBox object representing the legend box. You may use this object to fine-tune the appearance of the legend box.