Imported from http://oxyplot.codeplex.com/workitem/8772
objo 2011-06-09 09:51
improve the algorithm that calculates tick intervals when the ratio between Maximum and Minimum is small.
Example: an axis from 13 to 18 could show major ticks at 13, 14, 15, 16, 17, 18.
major ticks: tick line + number
minor ticks: small tick line only
mwas 2011-06-23 14:05
To improve on the current situation how about?
double axisMin = Math.Pow(10.0, Math.Floor(Math.Log10(min)));
double axisMax = Math.Pow(10.0, Math.Ceiling(Math.Log10(max)));
This would allow at least one cycle if the minimum/maximu values were very close.
objo 2011-06-23 22:39
yes, I think this is how Excel does it in its 'Auto' mode. If you have two values 13 and 18, you will get a log axis from 1 to 100. Tick labels will be at 1, 10 and 100.
We could implement this code as an alternative to the Oxyplot default behaviour, but this will give a lot of empty area below and above the curve!
And this does still not solve the problem when the user has zoomed in around 13 to 18... What is mostly needed is an algorithm to find nice major tick values.
(ps. try setting min/max manually in Excel, and you will see Excel has the same problem - only the minimum value 13 will be shown on the axis!)
OxyPlot is currently using the actual min/max of the data values as limits for the axis (and possibly adding some 'padding'). That means that the actual min/max of the axis will be approx. 12.95 and 18.05 with padding 1%.
These min/max values could also be the case if you have zoomed/panned an axis!
I would like an algorithm that finds nice intervals for both major and minor ticks.
One idea is to use linear intervals if log intervals results in 0 or 1 major ticks.
Here are some more test cases (Base=10):
Min = 13, Max = 18 => Major ticks at 13, 14, 15, 16, 17, 18 (linear)
Min = 13.1, Max = 13.2 => Major ticks at 13.1, 13.12, 13.14, 13.16, 13.18, 13.2 (linear)
Min = 8, Max = 110 = > Major ticks at 8,9,10,20,30,40,50,60,70,80,90,100,110 ? (linear+linear)
Min = 8, Max = 310 = > Major ticks at 8,10,20,40,60,80,100,200,300 ? (linear+linear+linear)
Min = 3, Max = 30 => Major ticks at 3,4,5,6,7,8,9,10,20,30 ? (linear+linear)
objo 2011-06-24 20:39
I added the padding code in 68113! It can be controlled by the "PowerPadding" property (by default it is on) (suggestions for better name of the property is welcome!) This seems to work well as long as you not zoom/pan...
I also changed the tick interval algorithm - it will use the linear algorithm when less than two ticks are generated by the log algorithm. This is not the optimal solution, but at least you will always get at least two numbers on the axis.
I keep the issue open as I would like to see a better solution.