帮助ASP.Net C#图表控件

时间:2011-06-22 08:53:36

标签: c# asp.net charts

我使用以下代码显示柱形图

Chart1.BackColor = Color.Gray;
Chart1.BackSecondaryColor = Color.WhiteSmoke;
Chart1.BackGradientStyle = GradientStyle.DiagonalRight;

Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderlineColor = Color.Gray;
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;

// format the chart area
Chart1.ChartAreas[0].BackColor = Color.Wheat;
// add and format the title
Chart1.Titles.Add("TOTAL GP Against TARGET  ");
Chart1.Titles[0].Font = new Font("Utopia", 16);

Chart1.Series.Add(new Series("total")
  {
  ChartType = SeriesChartType.Column,
  });

Chart1.Series.Add(new Series("perc")
  {
   ChartType = SeriesChartType.Column,
   });

 Chart1.Series[0].ChartType = SeriesChartType.Column;

 // clear the chart series and bind to the table
 DataView dataView = new DataView(dt);

 Chart1.Series[0].Points.DataBindXY(dataView, "NAME", dataView, "total");
 Chart1.Series[1].Points.DataBindXY(dataView, "NAME", dataView, "perc");

这很好用,但我想创建另一个图表,只显示行上的数据,我做的事情就像

Chart2.Series[0].Points.DataBindXY(dataView.RowFilter = "NAME = 'John' ", "NAME", dataView, "perc");

但它似乎不起作用,任何人都可以建议我如何能够做到这一点吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

DataView dataView = new DataView(dt);
dataView.RowFilter = "NAME = 'John'";

Chart1.Series[0].Points.DataBindXY(dataView, "NAME", dataView, "perc");