关于ASP.Net C#图表控件的帮助
本文关键字:控件 帮助 ASP Net 关于 | 更新日期: 2023-09-27 18:00:16
Im使用以下代码显示柱状图
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");
但它似乎不起作用,有人能建议我如何做到这一点吗?
试试这个:
DataView dataView = new DataView(dt);
dataView.RowFilter = "NAME = 'John'";
Chart1.Series[0].Points.DataBindXY(dataView, "NAME", dataView, "perc");