【发布时间】:2013-05-06 18:28:13
【问题描述】:
我想使用从绑定到图表的相同数据源获得的属性来自定义每个系列的点值。为了说明我的问题,我将使用与 DevExpress 在他们的 website 中用于图表数据绑定的相同示例:
public class Record {
int id, age;
string name;
public Record(int id, string name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
public int ID {
get { return id; }
set { id = value; }
}
public string Name {
get { return name; }
set { name = value; }
}
public int Age {
get { return age; }
set { age = value; }
}
}
为了填充图表,它使用以下代码块:
private void Form1_Load(object sender, EventArgs e) {
// Create a list.
ArrayList listDataSource = new ArrayList();
// Populate the list with records.
listDataSource.Add(new Record(1, "Jane", 19));
listDataSource.Add(new Record(2, "Joe", 30));
listDataSource.Add(new Record(3, "Bill", 15));
listDataSource.Add(new Record(4, "Michael", 42));
// Bind the chart to the list.
ChartControl myChart = chartControl1;
myChart.DataSource = listDataSource;
// Create a series, and add it to the chart.
Series series1 = new Series("My Series", ViewType.Bar);
myChart.Series.Add(series1);
// Adjust the series data members.
series1.ArgumentDataMember = "name";
series1.ValueDataMembers.AddRange(new string[] { "age" });
// Access the view-type-specific options of the series.
((BarSeriesView)series1.View).ColorEach = true;
series1.LegendPointOptions.Pattern = "{A}";
}
代码的结果图是:
我的问题是,我如何使用属性ID 为每个系列标签点添加额外信息? (例如 {ID + " - " + Age})在上图中,我们将获得这些标签数据点:“1 - 19”、“2 - 30”、“3 - 15”和“4 - 42”。
【问题讨论】:
标签: c# .net charts devexpress