c# chart change max and min values on the x axis

Matthew The Terrible picture Matthew The Terrible · Mar 15, 2013 · Viewed 92.8k times · Source

Can someone tell me how to change the min and max values on the x axis on a C# chart? I want to go from 0 to 13, but it goes from -1 to 14 right now.

Answer

Dutts picture Dutts · Mar 15, 2013

If you are using System.Windows.Forms.DataVizualisation.Charting you can set the Axis range by manipulating the chart's ChartAreas property. So something like

myChart.ChartAreas[0].AxisX.Maximum = 13;
myChart.ChartAreas[0].AxisX.Minimum = 0;