Search code examples
vb.netwinformsvisual-studio-2013chartsmschart

How do I avoid the first(and last) column of a x-capped chart being truncated?


I've been fiddling with a chart... I set the X axis minimum value to zero. Then I used DataBindXY on the Chart.Series.First.Points to set the values passing two lists (first is a 0-based label list and other has the actual values).

Below is the result. As I highlighted by the red arrow the first column is truncated.

My chart

Microsoft made traversing the settings of a chart in the designer as simple as getting out of a maze, so I'm clueless about where to find some offset property to be set.


Edit: Mine could be a possible duplicate of this question, but its answer is not clear to me, so I asked a new one.


Solution

  • If you set the X axis minimum value to -0.5, that should solve it.

    GraphChart.ChartAreas[0].AxisX.Minimum = -0.5;
    

    or try something like:

    GraphChart.ChartAreas[0].AxisX.IntervalOffset = 0.5;
    

    The reason is that the columns width is approximately 0.8 depending on the chart configuration so in your case they might span from 0.4 to 1.4, with a center point in 1