Chart Legend

The LegendBox is a window that shows the data point labels set with the chart's Legend property or that AxisX Label property. Usually these labels are displayed in the categorical X-axis. However, sometimes these labels are long strings and they will not fit in the space allotted for them. Showing the Legend Box with this property can help increase the chart's readability.

The LegendBox is used to display legends associated with data points (not series). It is particularly useful when improving readability for charts like Pie, which have no axes but point labels are still needed.

The LegendBox is always shown docked to a margin (right margin by default). Additionally, the Alignment property can be used to align the LegendBox within the margin. The Chart class LegendBoxObj property is used to set position and style attributes directly to the legend box.

For example, the following code would be used to show a LegendBox for a Pie chart docked to the left margin and aligned in the bottom of the chart area


chart1.setLegendBox(true);
chart1.getLegendBoxObj().setDocked(Docked.LEFT);
chart1.getLegendBoxObj().setAlignment(ToolAlignment.FAR);
chart1.getLegend().setItem(0,"January");
chart1.getLegend().setItem(1,"February");
chart1.getLegend().setItem(2,"March");
chart1.getLegend().setItem(3,"April");
chart1.getLegend().setItem(4,"May");

And the chart will look like the following picture: