Chart1.datasource =DtBstring[] Strcolor =Newstring[20]; strcolor[0] ="220, 224, 64, 10"; strcolor[1] ="220, 252, 180, 65"; strcolor[2] ="220, 159, 100, 100"; strcolor[3] ="220, 5, 100, 146"; strcolor[4] ="91,42,0"; strcolor[5] ="19,211,188"; strcolor[6] ="0,93,70"; strcolor[7] ="185,147,240"; strcolor[8] ="194,211,252"; strcolor[9] ="49,0,93"; strcolor[10] ="245,111,5"; strcolor[11] ="203,72,178"; strcolor[12] ="93,93,0"; strcolor[13] ="165,165,147"; strcolor[14] ="124,201,15"; strcolor[15] ="14,112,201"; strcolor[16] ="0,59,93"; strcolor[17] ="5,18,108"; strcolor[18] ="245,15,54"; strcolor[19] ="121,129,234"; Chart1.Series.Clear ();for (int i =0; i < dt. Rows.Count; i++{Chart1.Series.Add (i.ToString ());//Add chart1.series[i.tostring ()]. ChartType =Seriescharttype.stackedbar; Chart1.series[i.tostring ()]. Isxvalueindexed =True; Chart1.series[i.tostring ()]. Xvaluemember ="Customer"; Chart1.series[i.tostring ()]. Yvaluemembers ="Stickcarqutity"+ (i +1); Chart1.series[i.tostring ()]. LegendText = dt. rows[i]["Level"]. ToString (); Chart1.series[i.tostring ()]. BorderColor = Color.FromArgb (180,26,59,105); Chart1.series[i.tostring ()]. Isvalueshownaslabel =True;if (I <4) {string[] Number = Strcolor[i]. ToString (). Split (New char[] {‘,‘});int alpha =Int. Parse (number[0]. ToString ());int red =Int. Parse (number[1]. ToString ());int green =Int. Parse (number[2]. ToString ());int blue =Int. Parse (number[3]. ToString ()); Chart1.series[i.tostring ()]. Color =Color.FromArgb (alpha, red, green, blue);//Color Assignment}Else{If3<i&&i<20) {string[] Number = Strcolor[i]. ToString (). Split (new char["{ ' , '
Html
<Asp:chartId= "Chart1"Runat= "Server"DataMember= "DefaultView"Height= "700px"Width= "800px"><Legends><Asp:legendDocking= "Top"Name= "Default"BackColor= "Transparent"Font= "Trebuchet MS, 8pt, Style=bold"></Asp:legend></Legends><Series></Series><Chartareas><Asp:chartareaName= "CHARTAREA1"Issamefontsizeforallaxes= "True"><AxisXLabelautofitmaxfontsize= "8"Labelautofitminfontsize= "5"Isreversed= "True"><LabelStyleFont= "Microsoft Sans Serif, 8pt"Interval= "1"Intervaltype= "Auto"/><ScalebreakstyleCollapsiblespacethreshold= "10"LineColor= "Transparent"Breaklinestyle= "None"/><MinorgridInterval= "1"Intervaloffset= "1"Enabled= "False"/><MajorgridInterval= "Auto"Enabled= "False"/><MajorTickMarkInterval= "Auto"Enabled= "False"/><MinorTickMarkInterval= "1"Enabled= "False"/></AxisX><AxisyLabelautofitmaxfontsize= "8"Labelautofitminfontsize= "5"><LabelStyleInterval= "Auto"Intervaltype= "Auto"/></Axisy><AxisX2Labelautofitmaxfontsize= "8"Labelautofitminfontsize= "5"><MinorgridInterval= "1"Intervaloffset= "1"Enabled= "False"/><MajorgridInterval= "Auto"/><MajorTickMarkInterval= "Auto"/><MinorTickMarkInterval= "1"Enabled= "True"/><LabelStyleFont= "Microsoft Sans Serif, 8pt"/></AxisX2><AxisY2Labelautofitmaxfontsize= "8"Labelautofitminfontsize= "5"><labelstyle font< Span style= "color: #0000ff;" >= "Microsoft Sans Serif, 7pt" /> <majorgrid enabled= "False" /> </axisy2< Span style= "color: #0000ff;" >> </asp:chartarea > </chartareas< Span style= "color: #0000ff;" >> </asp:chart
Problem: C#chart control automatically adds series; Result: Graph Component Chart dynamic add series