5

I have a bar chart made with the c# .net chart control that looks like the following: enter image description here

As you can see there is a space between each pair of red and blue bars on the chart. Is there a way to remove those spaces?

Thanks in advance!

EDIT:

Here are the lines from the designer

 chartArea1.Name = "ChartArea1";
            this.CHRT_DPS_HPS.ChartAreas.Add(chartArea1);
            legend1.Name = "Legend1";
            this.CHRT_DPS_HPS.Legends.Add(legend1);
            this.CHRT_DPS_HPS.Location = new System.Drawing.Point(3, 271);
            this.CHRT_DPS_HPS.Name = "CHRT_DPS_HPS";
            series1.ChartArea = "ChartArea1";
            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;
            series1.Color = System.Drawing.Color.Red;
            series1.Legend = "Legend1";
            series1.MarkerBorderWidth = 0;
            series1.Name = "DPS";
            series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.String;
            series1.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            series2.ChartArea = "ChartArea1";
            series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;
            series2.Legend = "Legend1";
            series2.MarkerBorderWidth = 0;
            series2.Name = "HPS";
            series2.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.String;
            series2.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            this.CHRT_DPS_HPS.Series.Add(series1);
            this.CHRT_DPS_HPS.Series.Add(series2);
            this.CHRT_DPS_HPS.Size = new System.Drawing.Size(1199, 300);
            this.CHRT_DPS_HPS.TabIndex = 1;
            this.CHRT_DPS_HPS.Text = "CHRT_DPS_HPS";
            title1.Name = "Title1";
            title1.Text = "DPS Chart";
            this.CHRT_DPS_HPS.Titles.Add(title1);
pquest
  • 3,151
  • 3
  • 27
  • 40

1 Answers1

11

You need to set a custom property for that chart type.

Use this for each series (my code specifies series zero):

chart1.Series[0]["PointWidth"] = "1";

Replace the zero with the name and or indices of your series.

By the way - as much as it does have its limitations here and there - Microsoft Charting is quite a capable charting library! You just have to read the documentation. In this case, this chart type has special custom properties you can utilize.

This worked in my test application. Let me know if it does not work with yours and I will perform further troubleshooting.

As I am new and trying to gain rep, please mark my response as the answer if it is correct. Thank you.

JHubbard80
  • 2,217
  • 1
  • 20
  • 24
  • This works on System.Web.UI.DataVisualization.Charting too. although it is just increasing size of border lines for each bar, but it works and I am happy enough. – AaA Sep 19 '13 at 07:41