SeriesPoint.Tag Property
Gets or sets the object that contains data related to this series point.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.2.dll
NuGet Package: DevExpress.Charts
#Declaration
#Property Value
Type | Description |
---|---|
Object | A Object that contains data about the series point. |
#Remarks
Any type derived from the Object class can be assigned to this property. Use it to store data associated with a particular series point.
Note
If a chart is bound to data, the Tag property is automatically assigned to the underlying object used to create this series point (e.
#Example
This example demonstrates how to display custom information from the underlying data source in a crosshair cursor tooltip for every series point.
For this example to work correctly, do the following.
- Start MS Visual Studio.
- Create a new Windows Forms Application, or open an existing one.
- Drop the ChartControl onto the form.
- Add a single Bar Series to the chart, then bind it to the Products table from the nwind.mdb database (see Lesson 3 - Bind Chart Series to Data to learn how to do this).
- Set the series’ SeriesBase.ArgumentDataMember property to ProductName and its SeriesBase.ValueDataMembers.Value property to UnitPrice.
- Then handle the ChartControl.CustomDrawCrosshair event, as shown in the code below.
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraCharts;
namespace CustomInfoInTooltips {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// This line of code loads data into the 'nwindDataSet.Products' table. You can move, or remove it, as needed.
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
}
private void chartControl1_CustomDrawCrosshair(object sender, CustomDrawCrosshairEventArgs e) {
foreach (CrosshairElementGroup group in e.CrosshairElementGroups) {
foreach (CrosshairElement element in group.CrosshairElements) {
SeriesPoint currentPoint = element.SeriesPoint;
if (currentPoint.Tag.GetType() == typeof(DataRowView)) {
DataRowView rowView = (DataRowView)currentPoint.Tag;
string s = "Unit price = " + rowView["UnitPrice"].ToString() +
"\r\nUnits in stock = " + rowView["UnitsInStock"].ToString() +
"\r\nQuantity per unit = " + rowView["QuantityPerUnit"].ToString();
element.LabelElement.Text = s;
}
}
}
}
}
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Tag 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.