Fix tick marks for large Y scale ranges
The tick placement logic used a double loop to look for appropriate tick spacing, assuming that a base unit around 10^50 would be sufficient to cover any Y range. Unfortunately this places 10^100 tick marks for Y values around 10^150, leading to excessive resource usage on typical client hardware.
This patch replaces the double loop with a single loop, finding the starting point by explicit calculation.
It also adds a regression test to catch the defective behavior.