ASP.net c#帮助进行图表控制

时间:2011-06-20 11:56:16

标签: c# asp.net charts

我有以下数据集

NAME | GP   | ORD_GP | EXP   | TOTAL GP | TARGET
a      206     48      -239     15         1600
b      0       27       0        27        1520

iv设法使用代码

在图表上显示TOTAL GP
    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("TotalGP")
    {
        ChartType = SeriesChartType.Column,
    });

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

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

    DataView dataView = new DataView(ds.Tables[0]);

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

请有人告诉我如何在同一张图表上绘制目标?

更新

我如何让图表显示每列的值?

2 个答案:

答案 0 :(得分:2)

您只需要将第二列数据绑定到某些源数据

Chart1.Series[1].Points.DataBindXY(dataView, "NAME", dataView, "TARGET");

答案 1 :(得分:1)