Hi
any idea what formula is used by NumericYAxis to calculate auto interval?
Regards,
Hello Mudassir,
I’ve been looking into the algorithm which calculates the auto interval for the NumericYAxis, and found out that there are several steps in order to measure the auto interval. I’ll walk you through all of them, so you can understand each one.
1. The first step is to determine the minimum and maximum values of the data. Let’s say that those values are 100 and 1480.
2. Then, the difference from those values (1480 – 100 = 1380) is used in the following formula:
A = x / 10 ^ Log10(x),
where “x” is equal to the difference between the maximum and minimum values. In the case where x = 1380, the value A = 1.38.
3. The next step is to calculate the factor which will determine the calculated interval. That factor is based on the value “A” and it will always be produced as an integer value. In the case where A = 1.38, the factor will be 2.
4. After we calculated the factor we can calculate the actual interval’s value:
Interval = Factor * 10 ^ Log10(x)
In the case where the factor is equal to 2, the interval = 200.
5. At step 4, we already have the interval calculated. There is still one more step to do. That’s to determine the lower and upper limit of the chart’s plot area. The formulas for those values are:
Lower value = biggest integer value of smaller than (minimum value / interval) * Interval
Upper value = smallest integer value of bigger than (maximum value / interval) * Interval
Thank you for your post, and if you have some more questions about this, don’t hesitate to ask.
Factor * 10 ^ Log10(x) where x = max - min
will not result in interval value of 200 please check.
Hi Mudassir,
I've rechecked the algorithm and it seems you are right about this. Good catch! It's my mistake typing it that way.
What actually happens in the algorithm, is this:
Factor * 10 ^ (Lowest integer value bigger than (Log10(x))
I've missed that and this is the thing that makes the interval in a nice rounded number (like 200).
Thanks,
Martin Stoev
Log10(x) = 3.13987 considering x = 1380 ( as per your original assumption)
lowest interger value bigger than Log10(x) is now 4
factor you calculated is 2 so
interval will 2* 10^ 4 it 2* 10*10*10*10 which cannot be 200 .
Hi,
You are right, again. I'm making these mistakes, since I'm trying to translate the algorithm as shortly and accurately as I can. Apparently I wasn't that accurate.
So the correct formula at the end is:
Factor * 10 ^ (Biggest integer value lower than ((Log10(x) - 1))
I was missing the " - 1" after that log. When the log result in 3.139, we take the biggest integer value lower than that, which is 3. Adding the " - 1" will result in 2, so at the you will have 2 * 10 ^ 2. This should be case.
Thanks for the correction,
Well even this is not the accurate solution.
change series and the results will be exploded.
anyhow thanks for the efforts you made.
I've provided you with the basic idea of the algorithm. If you wish to see the exact implementation, I'll gladly navigate you through the source code of the control. In order to get the source code you can read this topic. You can find what you need to do in order to get it. After that, I can guide you where exactly is the implementation of that logic.
Hi again!
i guess you didn't answer the question yet, you give the hint but didn't tell the exact interval calculation
i am still struggling to calculate interval.
Hello again Mudassir,
If you have any other questions about this matter, please don't hesitate to ask.
Yes, there might be some cases in my explanation, where it will be different from the actual algorithm. The reason is because I can provide you with the basic idea.
Thank you for your understanding,