I had my own work of the devil, which reproduced your situation. I wanted to help because I thought I could learn something, but I need your markup or, even better, the whole solution! I tried "Error executing child request for ChartImg.axd" when I tried a simple page with a chart. I found that I need to add a handler to the config. Then I fought for the inability to load the System.Web.DataVisualization assembly, because the handler element that I copied referred to the DataVisualization 3.5 assembly, so I changed it to 4.0 and finally saw a graph. What a job it was!
The reason your spacer series doesn't create a gap is because there are no values โโin this series. Notice the last two lines of code below, which add null values โโto the separation series. This creates the desired gap between the other series, but you will also find the spacer series indicated in the legend if you have one, which is at least ugly.
for (var c = start; c < start + 6; c++) { var color = colors[c % colors.Count]; var seriesName = "Series "+ c;//color.Name); Chart1.Series.Add(seriesName); Chart1.Series[seriesName].BorderColor = color; Chart1.Series[seriesName].BorderWidth = 1; Chart1.Series[seriesName].Color = Color.FromArgb((int)(255 * .7), color); Chart1.Series[seriesName].BackSecondaryColor = Color.FromArgb((int)(255 * .2), color); Chart1.Series[seriesName].BackGradientStyle = GradientStyle.TopBottom; for (var year = DateTime.Now.AddYears(-5).Year; year < DateTime.Now.Year; year++) Chart1.Series[seriesName].Points.Add(new DataPoint(year, rng.Next(0, 20))); Chart1.Series[seriesName]["PointWidth"] = (0.6).ToString(); seriesName = "Spacer:" + seriesName; Chart1.Series.Add(seriesName); Chart1.Series[seriesName]["PointWidth"] = (0.6).ToString(); for (var year = DateTime.Now.AddYears(-5).Year; year < DateTime.Now.Year; year++) Chart1.Series[seriesName].Points.Add(new DataPoint(year, 0)); }
You can set the legend text to a space (NB. The empty line is ignored, and the legend text is not set) as follows, but the legend will still display these dividing rows.
Chart1.Series[seriesName].LegendText = " ";
If you are lucky, you do not need to show the legend, or you can set the spacer colors with the same color as the legend background, and the legend text in spaces. This leads to a double interval in the Legend, which is likely to be acceptable.
Bernhard hofmann
source share