1
votes

I have an MSChart control on my windows form and each time I run this with my data, the X-axis always shows -1,0,1,2,etc

My data nor its index should have caused this, its as though its a setting somewhere in the charts properties. Could anyone please tell me which setting could cause this?

Thanks in advance!

3

3 Answers

0
votes

Try to set

YourChartArea.AxisX.IsStartedFromZero = true;
0
votes

I had a similar issue a few days ago with a simple bar chart that reported the number of work orders closed for the past 7 days. The X-Axis was always starting at 0 and ending at 8 no matter what settings I chose. I finally discovered a way to get the X-Axis to only show 1 through 7 which is what I desired. My solution is below:

1) Open the ChartArea collection 2) Click on the applicable ChartArea 3) Click on the Axes collection 4) Click on the X axis member 5) If your X axis properties are categorized, browse to your LabelStyle properties 6) Change isEndLabelVisible to false

0
votes

You can set your own minimum:

chart1.ChartAreas[0].AxisX.Minimum = 0;