Xceed Chart for WinForms' integrated legend can operate in three modes: Disabled, Automatic, and Manual (for more details, see LegendMode Enumeration). In disabled mode the legend is not displayed. When you set the mode to Automatic, the legend data is supplied by the series of the charts associated with the legend. In this case, you control the displayed legend data items through the SeriesLegend object. For more information, consult the Legend topic in the Series Attributes book.
This topic describes how to feed data to a legend when you set the legend mode to Manual:
VB.NET | |
---|---|
legend.Mode = LegendMode.Manual |
C# | |
---|---|
legend.Mode = LegendMode.Manual; |
Each legend's data item is represented by a LegendDataItem. The following code adds a new data item:
VB.NET | |
---|---|
|
C# | |
---|---|
LegendDataItem item = new LegendDataItem(); |
The LegendDataItem object exposes several properties that allow you to configure the item's appearance. The mark style is controlled with the MarkShape property, which accepts values from the LegendMarkShape enumeration. The following table shows the possible mark shapes:
Rectangle | Circle | Diamond | Triangle |
Inverted Triangle | Cross | Diagonal Cross | Star |
The filling of the mark is controlled with the MarkFillEffect property, which returns a reference to a FillEffect object.
When you have line charts showing trends, you may want to use the mark item line properties and disable the shape. For instance:
VB.NET | |
---|---|
|
C# | |
---|---|
item = new LegendDataItem(); |
The last line of the example above instructs the legend that texts in the legend item should be 5 pixels away from the area reserved for the mark or line. The Text property controls the text displayed by the legend's data item. By default it is blank.
Some of the legend's mark properties cannot be configured individually. These are mark size, text properties (font, backplane, etc), text offset, and cell inflate. These properties are common for all data items and are controlled from the LegendData object:
VB.NET | |
---|---|
|
C# | |
---|---|
legend.Data.MarkSize = 10; |
Related Examples
Windows Forms: Legend\General
Web forms: Legend\General
See Also
Layout and Position | LegendData | LegendDataItem | FillEffect | ChartText