Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# chart control remove spaces between bars in bar chart

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);
like image 921
pquest Avatar asked Jul 26 '11 22:07

pquest


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr. Stroustroupe.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

Is C programming hard?

C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.


1 Answers

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.

like image 78
JHubbard80 Avatar answered Oct 26 '22 00:10

JHubbard80