开发者

MSChart X-axis always starting at -1?

开发者 https://www.devze.com 2023-02-13 06:44 出处:网络
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

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 h开发者_如何学Cave 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!


Try to set

YourChartArea.AxisX.IsStartedFromZero = true;


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


You can set your own minimum:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号