Skip to main content
A newer version of this page is available. .

SeriesPoint.Tag Property

Gets or sets the object that contains data related to this series point.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v21.2.dll

NuGet Package: DevExpress.Charts

Declaration

public object Tag { get; set; }

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.g. to the corresponding DataRowView object, if a chart is bound to a DataTable).

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.

  1. Start MS Visual Studio.
  2. Create a new Windows Forms Application, or open an existing one.
  3. Drop the ChartControl onto the form.
  4. 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).
  5. Set the series’ SeriesBase.ArgumentDataMember property to ProductName and its SeriesBase.ValueDataMembers.Value property to UnitPrice.
  6. 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;
                    }
                }
            }
        }
    }
}

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.

See Also