Skip to main content
A newer version of this page is available. .
All docs
V21.2

LegendBase.CustomItems Property

Returns the custom legend item collection.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v21.2.dll

NuGet Package: DevExpress.Charts

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Elements)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public CustomLegendItemCollection CustomItems { get; }

Property Value

Type Description
CustomLegendItemCollection

A collection of CustomLegendItem objects.

Example

This example demonstrates how to add a custom item to the legend.

Chart custom legend item

The following code adds a custom legend item with an image and text.

private void Form1_Load(object sender, EventArgs e) {
    double total = CalculateTotal(chartControl.Series[0]);

    CustomLegendItem customLegendItem = new CustomLegendItem();
    customLegendItem.MarkerImage.Image = new Bitmap("..\\..\\Images\\sum-icon.png");
    customLegendItem.MarkerImageSizeMode = ChartImageSizeMode.Zoom;
    customLegendItem.Text = string.Format("Total: ${0}M", total);            
    chartControl.Legend.CustomItems.Add(customLegendItem);
    chartControl.Legend.ItemVisibilityMode = LegendItemVisibilityMode.AutoGeneratedAndCustom;
    chartControl.Legend.Direction = LegendDirection.TopToBottom;
}
public Double CalculateTotal (Series series) {
    double total = 0;
    foreach(SeriesPoint point in series.Points) {
        total += point.Values[0];
    }
    return total;
}
See Also