Back to Devexpress

SeriesBase.ArgumentDataMember Property

corelibraries-devexpress-dot-xtracharts-dot-seriesbase-2ac70c0e.md

latest11.9 KB
Original Source

SeriesBase.ArgumentDataMember Property

Gets or sets the name of the data field that contains series point arguments.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Data)]
public string ArgumentDataMember { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Data)>
Public Property ArgumentDataMember As String

Property Value

TypeDescription
String

The name of the data field that contains series point arguments.

|

Remarks

Use the ArgumentDataMember and SeriesBase.ValueDataMembers properties to bind a series to data. For more information, refer to Specify Series Data Members.

Example

The following example demonstrates how to bind a chart to data at runtime via binding its individual series to a particular datasource. It uses the same approach as the design-time example, but another data table is generated in this code to simplify the example.

Note

Don’t forget to include all necessary assemblies to the References list of your project.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/winforms-charts-bind-individual-series-to-data

csharp
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

namespace BindIndividualSeriesRuntimeCS {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private DataTable CreateChartData(int rowCount) {
            // Create an empty table.
            DataTable table = new DataTable("Table1");

            // Add two columns to the table.
            table.Columns.Add("Argument", typeof(Int32));
            table.Columns.Add("Value", typeof(Int32));

            // Add data rows to the table.
            Random rnd = new Random();
            DataRow row = null;
            for (int i = 0; i < rowCount; i++) {
                row = table.NewRow();
                row["Argument"] = i;
                row["Value"] = rnd.Next(100);
                table.Rows.Add(row);
            }

            return table;
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create a chart.
            ChartControl chart = new ChartControl();

            // Create an empty Bar series and add it to the chart.
            Series series = new Series("Series1", ViewType.Bar);
            chart.Series.Add(series);

            // Generate a data table and bind the series to it.
            series.DataSource = CreateChartData(50);

            // Specify data members to bind the series.
            series.ArgumentScaleType = ScaleType.Numerical;
            series.ArgumentDataMember = "Argument";
            series.ValueScaleType = ScaleType.Numerical;
            series.ValueDataMembers.AddRange(new string[] { "Value" });

            // Set some properties to get a nice-looking chart.
            ((SideBySideBarSeriesView)series.View).ColorEach = true;
            ((XYDiagram)chart.Diagram).AxisY.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;

            // Dock the chart into its parent and add it to the current form.
            chart.Dock = DockStyle.Fill;
            this.Controls.Add(chart);
        }
    }
}
vb
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Namespace BindIndividualSeriesRuntimeCS
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Function CreateChartData(ByVal rowCount As Integer) As DataTable
            ' Create an empty table.
            Dim table As New DataTable("Table1")

            ' Add two columns to the table.
            table.Columns.Add("Argument", GetType(Int32))
            table.Columns.Add("Value", GetType(Int32))

            ' Add data rows to the table.
            Dim rnd As New Random()
            Dim row As DataRow = Nothing
            For i As Integer = 0 To rowCount - 1
                row = table.NewRow()
                row("Argument") = i
                row("Value") = rnd.Next(100)
                table.Rows.Add(row)
            Next i

            Return table
        End Function

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            ' Create a chart.
            Dim chart As New ChartControl()

            ' Create an empty Bar series and add it to the chart.
            Dim series As New Series("Series1", ViewType.Bar)
            chart.Series.Add(series)

            ' Generate a data table and bind the series to it.
            series.DataSource = CreateChartData(50)

            ' Specify data members to bind the series.
            series.ArgumentScaleType = ScaleType.Numerical
            series.ArgumentDataMember = "Argument"
            series.ValueScaleType = ScaleType.Numerical
            series.ValueDataMembers.AddRange(New String() { "Value" })

            ' Set some properties to get a nice-looking chart.
            CType(series.View, SideBySideBarSeriesView).ColorEach = True
            CType(chart.Diagram, XYDiagram).AxisY.Visibility = DevExpress.Utils.DefaultBoolean.False
            chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False

            ' Dock the chart into its parent and add it to the current form.
            chart.Dock = DockStyle.Fill
            Me.Controls.Add(chart)
        End Sub
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the ArgumentDataMember 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#L55

csharp
int drillDownLevel = Interactivity.GetCurrentDrillDownValues().Count;
    series.ArgumentDataMember = dashboardItem.Metadata.Arguments[drillDownLevel].UniqueId;
}

winforms-charts-plot-xy-series-with-histogram/CS/Form1.cs#L27

csharp
Series histogram = new Series("Histogram", ViewType.Bar);
histogram.ArgumentDataMember = "XValue";
chartControl1.Series.Add(histogram);

bi-dashboard-non-visual-custom-export/CS/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.cs#L35

csharp
if(dashboardItem.InteractivityOptions.IsDrillDownEnabled)
    series.ArgumentDataMember = arguments[drillDownLevel].UniqueId;
else

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.cs#L51

csharp
int drillDownLevel = Interactivity.GetCurrentDrillDownValues().Count;
    series.ArgumentDataMember = dashboardItem.Metadata.Arguments[drillDownLevel].UniqueId;
}

winforms-visualize-data-grid-rows-in-a-chart/CS/ControlRowSourceSample/MainForm.cs#L27

csharp
SeriesBase seriesTemplate = chartControl.SeriesTemplate;
seriesTemplate.ArgumentDataMember = "Category";
seriesTemplate.ValueDataMembers.AddRange("Revenue");

winforms-dashboard-custom-items/VB/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.vb#L56

vb
Dim drillDownLevel As Integer = Interactivity.GetCurrentDrillDownValues().Count
    series.ArgumentDataMember = dashboardItem.Metadata.Arguments(drillDownLevel).UniqueId
Else

winforms-charts-plot-xy-series-with-histogram/VB/Form1.vb#L55

vb
Dim histogram As Series = New Series("Histogram", ViewType.Bar)
histogram.ArgumentDataMember = "XValue"
chartControl1.Series.Add(histogram)

bi-dashboard-non-visual-custom-export/VB/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.vb#L35

vb
If dashboardItem.InteractivityOptions.IsDrillDownEnabled Then
    series.ArgumentDataMember = arguments(drillDownLevel).UniqueId
Else

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.vb#L57

vb
Dim drillDownLevel As Integer = Interactivity.GetCurrentDrillDownValues().Count
    series.ArgumentDataMember = dashboardItem.Metadata.Arguments(drillDownLevel).UniqueId
Else

winforms-visualize-data-grid-rows-in-a-chart/VB/ControlRowSourceSample/MainForm.vb#L25

vb
Dim seriesTemplate As SeriesBase = chartControl.SeriesTemplate
seriesTemplate.ArgumentDataMember = "Category"
seriesTemplate.ValueDataMembers.AddRange("Revenue")

See Also

ValueDataMembers

ChartControl.DataSource

Series.DataSource

SeriesBase Class

SeriesBase Members

DevExpress.XtraCharts Namespace