Wilson212
Wilson212

Reputation: 563

Winforms Linechart - Remove padding

I am currently working on some software and need to generate a Line graph. I've managed to get a linegraph setup just the way I like it, but I cannot seem to find anywhere on how to remove the padding on the left and right of the inner graph. Below is a picture of my graph to help explain what it is I am asking:

My Line Graph

As you can see, the first point starts on the second line. What I want to happen is the blue parts of the graph touch both ends (left and right) of the entire chart area. Here is how I plotted my points in C# code:

            chart2.Series[0].Points.Clear();
            int i = 0;
            foreach (var rank in sim.Elements.OrderBy(x => x.Key))
            {
                chart2.Series[0].Points.AddY((double)rank.Value.TotalPersonel);
                chart2.Series[0].Points[i].AxisLabel = Rank.EnlistedRanks[rank.Key];
                chart2.Series[0].Points[i].LegendText = Rank.EnlistedRanks[rank.Key];
                chart2.Series[0].Points[i].Label = rank.Value.TotalPersonel.ToString();
                i++;
            }

As you can see in the code snippet, I am clearing any and all points, and starting at an index of 0. I don't understand why the graph starts on the second plot. Does anyone know how to do this? Any help will be much appreciated.

Upvotes: 0

Views: 296

Answers (1)

user6052446
user6052446

Reputation:

In the chart properties look for ChartAreas collection, select the first and the only item, Axis property's collection, X axis IsMarginVisible = false.

Upvotes: 2

Related Questions