Hello,
Not sure how 'axis could take integer values' but I assume it is about label's string format and magnitude of division. Here is brief guide on subject.
Disable auto-formatting and use set label's string in any way user likes. User can use normal formatting string here, same as you he/she use to ToString() method (default ‘0.0’). See for references
MSDN: Custom Numeric Format Strings and
MSDN: Standard Numeric Format Strings.
The simplest way:
Code: Select all
_chart.ViewXY.YAxes[0].AutoFormatLabels = false;
_chart.ViewXY.YAxes[0].LabelsNumberFormat = "0";
If user is planning to zoom-in (with LabelsNumberFormat = "0"), then it is good idea to disable other Axis' auto format properties.
In particular, user should set
Code: Select all
_chart.ViewXY.YAxes[0].AutoDivSpacing = false;
and use ONLY one of following properties to set division:
Code: Select all
_chart.ViewXY.YAxes[0].MajorDiv = 1;
_chart.ViewXY.YAxes[0].MajorDivCount = 5;
depending on which property he want to keep fixed, the following property should be set accordingly. E.g., to keep 'MajorDiv' as primary reference property:
Code: Select all
_chart.ViewXY.YAxes[0].KeepDivCountOnRangeChange = false;
Finally, if range changes several magnitudes, you may need further adjustment to those properties (if 'auto' formatting is not used). The easiest way to do that is to subscribe to Axis.RangeChanged event and modify all required properties in event handler.
Hope this helps.