2011-06-20 167 views
1

我有以下數據集ASP.net C#幫助

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

IV設法在圖表上顯示的總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"); 

請可有人告訴我如何我可以在同一張圖上繪製目標圖嗎?

UPDATE

還怎麼做我得到的圖表顯示每一列的值?

回答

2

你只需要在第二列數據綁定到一些源數據

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