CustomLegendItem.Text Property
Gets or sets the text the custom legend item displays.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v20.2.dll
NuGet Packages: DevExpress.Charts, DevExpress.WindowsDesktop.Charts
Declaration
Property Value
Type | Description |
---|---|
String | A String that specifies the legend item text. |
Example
This example demonstrates how to add a custom item to the legend.
- Create a CustomLegendItem object and add it to the Legend.CustomItems collection.
- Use the MarkerImage and
Text
properties to specify the custom item’s content. - The Legend.ItemVisibilityMode property allows you to define whether to show custom items and auto-generated items together.
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;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Text property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.