(start, stop, count)
| 3 | e2 = Math.sqrt(2); |
| 4 | |
| 5 | function tickSpec(start, stop, count) { |
| 6 | const step = (stop - start) / Math.max(0, count), |
| 7 | power = Math.floor(Math.log10(step)), |
| 8 | error = step / Math.pow(10, power), |
| 9 | factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; |
| 10 | let i1, i2, inc; |
| 11 | if (power < 0) { |
| 12 | inc = Math.pow(10, -power) / factor; |
| 13 | i1 = Math.round(start * inc); |
| 14 | i2 = Math.round(stop * inc); |
| 15 | if (i1 / inc < start) ++i1; |
| 16 | if (i2 / inc > stop) --i2; |
| 17 | inc = -inc; |
| 18 | } else { |
| 19 | inc = Math.pow(10, power) * factor; |
| 20 | i1 = Math.round(start / inc); |
| 21 | i2 = Math.round(stop / inc); |
| 22 | if (i1 * inc < start) ++i1; |
| 23 | if (i2 * inc > stop) --i2; |
| 24 | } |
| 25 | if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); |
| 26 | return [i1, i2, inc]; |
| 27 | } |
| 28 | |
| 29 | export default function ticks(start, stop, count) { |
| 30 | stop = +stop, start = +start, count = +count; |
no outgoing calls
no test coverage detected
searching dependent graphs…