ChartControl 传递多个ValueDataMembers

SeriesBase.ValueDataMembers Property

 

StackedBarSeriesView只允许传递一个ValueDataMembers

 

Gets a collection of the names of data fields that contain series point values.

Namespace:DevExpress.XtraCharts
Assembly:DevExpress.XtraCharts.v19.1.dll

Expanded Syntax

C#

VB

 
public ValueDataMemberCollection ValueDataMembers { get; }

Property value

Type: ValueDataMemberCollection 
The collection of the names of data fields that contain series point values. 

Expanded Remarks

 

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

Expanded 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/how-to-bind-individual-chart-series-to-data-e116

 

Form1.cs

Form1.vb

 
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);
        }
    }
}

 

 

Expanded See Also

SeriesBase Class
SeriesBase Members
DevExpress.XtraCharts Namespace
ArgumentDataMember 
ChartControl.DataSource 
Series.DataSource

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值