大家好,我无法在我的代码上添加条形图。我需要做的是从饼图中为它所拥有的每一块制作一个条形图。不幸的是,我很难做到这一点。我想要做的主要目标是根据 GroupName 创建一个单独的详细条形图。这是我的 C# 代码:
void StartReport10()
{
Chart c = Chart11;
string str = ConfigurationManager.ConnectionStrings["SLRC_debug"].ConnectionString;
SqlConnection con = new SqlConnection(str);
SqlDataAdapter da = new SqlDataAdapter("sp_SLRC_GetReport_MajorAndMinorCauseCategories", con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.CommandTimeout = 60; //(1 minute)
da.SelectCommand.Parameters.Add(new SqlParameter("@rtype", SqlDbType.Int)).Value = Timeline10.RangeTypeIndex;
da.SelectCommand.Parameters.Add(new SqlParameter("@y1", SqlDbType.Int)).Value = Convert.ToInt32(Timeline10.FYFrom);
da.SelectCommand.Parameters.Add(new SqlParameter("@r1", SqlDbType.Int)).Value = Convert.ToInt32(Timeline10.RangeFrom);
da.SelectCommand.Parameters.Add(new SqlParameter("@y2", SqlDbType.Int)).Value = Convert.ToInt32(Timeline10.FYTo);
da.SelectCommand.Parameters.Add(new SqlParameter("@r2", SqlDbType.Int)).Value = Convert.ToInt32(Timeline10.RangeTo);
int top = Int32.Parse(tbTop1.Text);
da.SelectCommand.Parameters.Add(new SqlParameter("@top", SqlDbType.Int)).Value = top;
da.SelectCommand.Parameters.Add(new SqlParameter("@MROProjFilter", SqlDbType.VarChar)).Value = MROProjReport3.GetSelectedMROProjFilter;
da.SelectCommand.Parameters.Add(new SqlParameter("@TradeIntercoFilter", SqlDbType.VarChar)).Value = TradeInterco3.GetSelectedIntercoTradeFilter;
if (CustomerFilter2.IsEnabled && CustomerFilter2.IsValid)
{
string a = CustomerFilter2.GetStrSelection;
da.SelectCommand.Parameters.Add(new SqlParameter("@str", SqlDbType.VarChar)).Value = a;
}
DataSet ds = new DataSet();
da.Fill(ds);
ds.Tables["Table"].TableName = "Table_for_Major";
ds.Tables["Table1"].TableName = "Table_for_Detailed";
c.DataSource = ds.Tables["Table_for_Major"];
c.Series.Clear();
c.Series.Add("Default");
c.Series[0].ValueMemberX = "GroupName : %";
c.Series[0].ValueMembersY = "% of Total LineCount";
c.Series[0].Type = SeriesChartType.Pie;
c.Series[0]["PieLabelStyle"] = "Inside";
c.Series[0]["PieDrawingStyle"] = "SoftEdge";
c.Series[0].ShowInLegend = false;
c.DataBind();
//Chart Title
c.Palette = ChartColorPalette.Dundas;
c.Titles.Clear();
c.Titles.Add("PDSL Major & Minor Cause Categories");
c.Titles[0].Font = new Font("Arial", 14, FontStyle.Bold);
c.Titles.Add(Timeline10.FYRangeFrom + " - " + Timeline10.FYRangeTo);
c.Titles[1].Font = new Font("Arial", 8, FontStyle.Regular);
c.ChartAreas[0].Area3DStyle.Enable3D = true;
c.ChartAreas[0].Area3DStyle.XAngle = 5;