【问题标题】:How to disable MS chart series grouping in C#?如何在 C# 中禁用 MS 图表系列分组?
【发布时间】:2013-11-07 13:40:41
【问题描述】:

我的图表系列非常接近,这是一个问题。我不知道它们为什么要分组,它们看起来像:http://i39.tinypic.com/wks007.pnghttp://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DataBindingMSChartcontrol_10712/image_2.png,但必须分开:(

我想让每个酒吧都有自己的名字而不分组。 就像在第二张图片上一样,安德鲁有 5 列彼此靠近,有一个标题:“安德鲁”,但我想分别拥有它们)

我该怎么做?

我用的是 MS 图表库

附:请原谅我的英语:)

我的代码示例:

var table = new DataTable();
s = chart1.Series.Add("Ser1");
s.XValueMember = "Col1";
s.YValueMembers = "Col1_Count";

s = chart1.Series.Add("Ser2");
s.XValueMember = "Col2";
s.YValueMembers = "Col2_Count";

s = chart1.Series.Add("Ser3");
s.XValueMember = "Col3";
s.YValueMembers = "Col3_Count";

table.Columns.Add("Col1", typeof(string));
table.Columns.Add("Col1_Count", typeof(int));
table.Columns.Add("Col2", typeof(string));
table.Columns.Add("Col2_Count", typeof(int));
table.Columns.Add("Col3", typeof(string));
table.Columns.Add("Col3_Count", typeof(int));

然后我执行 SqlCommand SELECT 并将行添加到表中,然后 chart1.DataBind();

【问题讨论】:

  • 能否请您发布用于填充图表的代码?

标签: c# charts series


【解决方案1】:

首先,确保将 Charttype 作为 Column 放入图表控件中,例如 ChartType="Column", 那么,XValueMember 应该是同一列,并且 Bindpoints to series 与单独的数据视图,如

 DataView sDt1 = table .DefaultView.ToTable(true, new[] { "Column_Identifier", "RecordCount" }).DefaultView;
 Series[0].Points.DataBindXY(sDt1, "Column_Identifier", sDt1, "RecordCount");

【讨论】:

  • 类似数据: 名称 产品数量 Andrew Product A 35 Andrew Product B 36 Andrew Product C 37 Andrew Product D 38 Andrew Other 39 David Product A 35 David Product B 36 David Product C 37 David Product D 38 David其他 39 布赖恩产品 A 35 布赖恩产品 B 36 布赖恩产品 C 37 布赖恩产品 D 38 布赖恩其他 39
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多