* Filter a set of candidate tick values, ensuring that only tick values * that lie within the scale range are included. * @param {Scale} scale - The scale for which to generate tick values. * @param {Array<*>} ticks - The candidate tick values. * @param {*} count - The tick count or interval fun
(scale, ticks, count)
| 109957 | |
| 109958 | |
| 109959 | function validTicks(scale, ticks, count) { |
| 109960 | var range = scale.range(), |
| 109961 | lo = Math.floor(range[0]), |
| 109962 | hi = Math.ceil((0, _vegaUtil.peek)(range)); |
| 109963 | |
| 109964 | if (lo > hi) { |
| 109965 | range = hi; |
| 109966 | hi = lo; |
| 109967 | lo = range; |
| 109968 | } |
| 109969 | |
| 109970 | ticks = ticks.filter(function (v) { |
| 109971 | v = scale(v); |
| 109972 | return lo <= v && v <= hi; |
| 109973 | }); |
| 109974 | |
| 109975 | if (count > 0 && ticks.length > 1) { |
| 109976 | var endpoints = [ticks[0], (0, _vegaUtil.peek)(ticks)]; |
| 109977 | |
| 109978 | while (ticks.length > count && ticks.length >= 3) { |
| 109979 | ticks = ticks.filter(function (_, i) { |
| 109980 | return !(i % 2); |
| 109981 | }); |
| 109982 | } |
| 109983 | |
| 109984 | if (ticks.length < 3) { |
| 109985 | ticks = endpoints; |
| 109986 | } |
| 109987 | } |
| 109988 | |
| 109989 | return ticks; |
| 109990 | } |
| 109991 | /** |
| 109992 | * Generate tick values for the given scale and approximate tick count or |
| 109993 | * interval value. If the scale has a 'ticks' method, it will be used to |
no test coverage detected