I have a data point with a y-value of 1 being plotted, the MS Chart control will use increments of 0.2 on the y-axis. How can I force it to not use a decimal, keeping in mind I will have values of >100 so I can't just force an increment of 1 on the y-axis?
In the code behind set the chart area's axis label style format:
chtArea.AxisX.LabelStyle.Format = "{#,###}";
chtArea.AxisY.LabelStyle.Format = "{#,###}";
Or in aspx
<ChartAreas>
<asp:ChartArea Name="MainChartArea">
<AxisY>
<LabelStyle Format="#,###" />
</AxisY>
<AxisX IsMarginVisible="false">
<LabelStyle Format="#,###" />
</AxisX>
You need to write some custom logic to make that happen. You can use chart1.ChartAreas[0].AxisY.RoundAxisValues(); but then it will display 0.00 at all the points. I would suggest if there is only 1 data point with value 1, set YAxis Maximum property to 2 and set interval to 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.