corelibraries-devexpress-dot-xtracharts-dot-seriespoint-5b0eaa85.md
Gets or sets the object that contains data related to this series point.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
public object Tag { get; set; }
Public Property Tag As Object
| Type | Description |
|---|---|
| Object |
A Object that contains data about the series point.
|
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 ).
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.
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;
}
}
}
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Namespace CustomInfoInTooltips
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' This line of code loads data into the 'nwindDataSet.Products' table. You can move, or remove it, as needed.
Me.productsTableAdapter.Fill(Me.nwindDataSet.Products)
End Sub
Private Sub chartControl1_CustomDrawCrosshair(ByVal sender As Object, ByVal e As CustomDrawCrosshairEventArgs) Handles chartControl1.CustomDrawCrosshair
For Each group As CrosshairElementGroup In e.CrosshairElementGroups
For Each element As CrosshairElement In group.CrosshairElements
Dim currentPoint As SeriesPoint = element.SeriesPoint
If currentPoint.Tag.GetType() Is GetType(DataRowView) Then
Dim rowView As DataRowView = CType(currentPoint.Tag, DataRowView)
Dim s As String = "Unit price = " & rowView("UnitPrice").ToString() & Constants.vbCrLf & "Units in stock = " & rowView("UnitsInStock").ToString() & Constants.vbCrLf & "Quantity per unit = " & rowView("QuantityPerUnit").ToString()
element.LabelElement.Text = s
End If
Next element
Next group
End Sub
End Class
End Namespace
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.
winforms-dashboard-custom-items/CS/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.cs#L66
{
DashboardFlatDataSourceRow row = e.SeriesPoint.Tag as DashboardFlatDataSourceRow;
string formattedValue = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row);
void CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) {
DashboardFlatDataSourceRow row = e.SeriesPoint.Tag as DashboardFlatDataSourceRow;
string formattedValue = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row);
} else {
PivotChartDataSourceRowItem coordinates = point.Tag as PivotChartDataSourceRowItem;
winforms-charts-create-a-side-by-side-stacked-bars/CS/SideBySideStackedBarChart/Form1.cs#L48
if (series.Points.Count > 0) {
DataRowView row = series.Points[0].Tag as DataRowView;
((ISupportStackedGroup)series.View).StackedGroup = row["Group"];
winforms-dashboard-custom-items/VB/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.vb#L66
Private Sub CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs)
Dim row As DashboardFlatDataSourceRow = TryCast(e.SeriesPoint.Tag, DashboardFlatDataSourceRow)
Dim formattedValue As String = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row)
Private Sub CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs)
Dim row As DashboardFlatDataSourceRow = TryCast(e.SeriesPoint.Tag, DashboardFlatDataSourceRow)
Dim formattedValue As String = flatData.GetDisplayText(dashboardItem.Metadata.Value.UniqueId, row)
Else
Dim coordinates As PivotChartDataSourceRowItem = TryCast(point.Tag, PivotChartDataSourceRowItem)
InvalidateCell(pivotGridControl1, hotTrackPoint)
winforms-charts-create-a-side-by-side-stacked-bars/VB/SideBySideStackedBarChart/Form1.vb#L47
If series.Points.Count > 0 Then
Dim row As DataRowView = TryCast(series.Points(0).Tag, DataRowView)
CType(series.View, ISupportStackedGroup).StackedGroup = row("Group")
See Also