Question

I'm plotting integer data series dynamically on a chart control. The range of the values of the series can vary a lot, f.e. y ranging from 0-100 and x ranging from 1-6000. I'm using chart1.ChartAreas[chartName].RecalculateAxesScale() and I do not get my y axis properly adjusted. For series with low y-values with f.e. y's between 0-3 the y-Axis is set to a numerical scale with interval [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5]. But I only want the interval to be [0,1,2,3]. When I set AxisY.Interval=1 then in the series with values ranging from 0-100 every y tick gets plotted.

How can I set my y-Axis to use auto interval adjustment, but with only integer ticks?

Was it helpful?

Solution

You could handle the Customize event of Chart control. Since you haven't posted any code showing what you have done, here is some pseudo code

private void chart1_Customize(object sender, EventArgs e)
{
    // if Y axis range is small =>  set Y axis interval 
    // else if Y axis range is ..... => set diff Y axis interval
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top