The Legend Entry Object

Figure 21-1 shows a chart legend with two legend entries. Legend entries are represented by LegendEntry objects. The LegendEntry objects for a legend are kept in the LegendEntries collection object for the Legend object. This collection is accessed using the LegendEntries property of the Chart object.

Each legend entry has two parts: the text of the legend entry is the name of the series associated with that entry and the entry key (also called an entry marker) is a small copy of the associated series and its formatting.

Note that the text of a legend entry cannot be changed. However, the LegendEntry object does have a Font property that can be used to change the font of the legend entry, as in:

ActiveChart.Legend.Font.Italic = True

In addition, LegendEntry objects can be deleted. However, after a legend entry has been deleted, the only way to restore it is to remove and recreate the entire legend by setting the HasLegend property for the chart first to False and then to True.

Also, no pattern formatting is allowed for legend entries, nor can a legend entry's position or size be changed.

Note finally that there is no direct way to return the series corresponding to a given legend entry.

+2 -2


Post a comment