Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net Column Chart is not aligning with the custom label and it does not display spaces between columns
    text
    copied!<p>I am trying to generate a chart to look this one <img src="https://i.stack.imgur.com/SvM8R.png" alt="enter image description here"></p> <p>I am almost there but there are couple of issue that i can't solve. The columns are being displayed with out a space separation between them! also the custom label that is at the very bottom is not aligning up with each column!</p> <p>this is the output the i get out of my existing code </p> <p><img src="https://i.stack.imgur.com/Vkqz8.jpg" alt="enter image description here"></p> <p>so 1) I need to spread the columns across the x axis 2) align the custom label to each column!</p> <p>I appreciate any help or feedback on this problem</p> <p>this is the code that generates the current image. Please keep in mind the my dataset "ds" have values like this</p> <p>Emerging 28.45646456 Dent 14.1456465 Audio 27.456456 Cosmetic 43.44564456 Vet 35.15465646645</p> <p>public void GenerateChart(){</p> <pre><code> //ds is generated and has values Chart2.Series.Clear(); Chart2.Legends.Clear(); Chart2.Titles.Clear(); //if (ConfigurationManager.AppSettings["RunOnLocalhost"] == "True") { if(HttpContext.Current.Request.Url.Host.ToLower() == "localhost"){ Chart2.ImageStorageMode = ImageStorageMode.UseImageLocation; } Chart2.Width = 1000; Chart2.Height = 700; Chart2.BorderlineDashStyle = ChartDashStyle.Solid; Chart2.Titles.Add("Usage Impact By Industry"); Chart2.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray; Chart2.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.LightGray; Chart2.ChartAreas[0].AxisX.Interval = 1; Chart2.ChartAreas[0].AxisY.Interval = 5; Chart2.ChartAreas[0].AxisX.LabelStyle.Angle = -45; Chart2.ChartAreas[0].AxisY.Title = "(%) Usage Lift"; Chart2.ChartAreas[0].AxisX.TitleFont = new Font("Arial", 16, FontStyle.Bold); Chart2.ChartAreas[0].AxisY.Minimum = -5; string tmp = ""; string sName = ""; double percentage = 0; int i = 1; int x = 1; double index = 0.1; foreach (DataRow Row in ds.Tables[0].Rows) { if (tmp != Row["Industry"].ToString()) { sName = Row["Industry"].ToString(); Chart2.Series.Add(sName); Chart2.Legends.Add(sName).DockedToChartArea = "ChartArea1"; i++; } if (Convert.ToDouble(Row["B4"]) &gt; 0) { percentage = (Convert.ToDouble(Row["After4"]) - Convert.ToDouble(Row["B4"])) / Convert.ToDouble(Row["B4"]) * 100; percentage = Math.Round(percentage, 0); } else { percentage = 0; } Chart2.Series[sName].Points.AddXY(Row["Industry"].ToString(), percentage); Chart2.Series[sName].ChartType = SeriesChartType.Column; Chart2.Series[sName]["PointWidth"] = ".5"; Chart2.Series[sName].IsValueShownAsLabel = true; Chart2.Series[sName].LabelFormat = percentage + "%"; CustomLabel label = new CustomLabel(); label.FromPosition = 0 + index; label.ToPosition = .01 + index; label.Text = Row["Industry"].ToString(); label.RowIndex = 0; Chart2.ChartAreas[0].AxisX.CustomLabels.Add(label); x++; index += 0.2; tmp = Row["Industry"].ToString(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload