Xceed Chart for WinForms provides an integrated legend that can display various types of information about the chart. The flexible design of the integrated legend helps you to customize the displayed data with ease.
The Legend object encapsulates the legend functionality. Legends are contained in the LegendCollection, accessible through the Legends property of the chart control:
VB.NET | |
---|---|
Dim legendsCollection As LegendCollection = chartControl1.Legends |
C# | |
---|---|
LegendCollection legendsCollection = chartControl1.Legends; |
By default there is only one chart and one legend associated with this chart. This is why it is safe to request a Legend object from the collection at startup:
VB.NET | |
---|---|
|
C# | |
---|---|
LegendCollection legendsCollection = chartControl1.Legends; |
The legend in Xceed Chart consists of several components, as illustrated in the following diagram:
The following table shows the same legend rendered without a backplane and grid:
Original legend | Legend with Backplane Disabled | Legend with Grid Disabled |
Legend Header and Footer
The legend header and footer are represented by LegendText objects contained in Legend and accessible through the Header and Footer properties. Each LegendText object has a ChartText object controlling the header or footer font, size, etc. The Text property specifies the text displayed by the header or footer. The following code shows how to assign some text to legend header:
VB.NET | |
---|---|
|
C# | |
---|---|
Legend.Header.Text = "Some legend header"; |
The InflateHeight and InflateWidth properties of LegendText allow you to increase the header or footer size in pixels. By default the header and footer texts are blank and the legend displays them.
Legend Backplane
The legend backplane is an instance of the Backplane object described in detail in the Backplanes topic.
Legend Grid
The legend grid visually separates the data items horizontally and vertically. The legend grid's properties are exposed through the HorizontalLinesProps, VerticalLinesProps, OutlineHorizontalLinesProps, and OutlineVerticalLinesProps properties of the LegendData object containing the legend's data items. The following example changes the horizontal grid lines to red and disables all other grid lines:
VB.NET | |
---|---|
|
C# | |
---|---|
legend.Data.HorizontalLinesProps.Color = Color.Red; |
Related Examples
Windows Forms: Legend\General
Web forms: Legend\General
See Also
Legend | LegendText | ChartText | Feeding Custom Data | Layout and Position