* @param {TimeScale} scale * @param {number[]} values * @param {Unit|undefined} [majorUnit] * @return {object[]}
(scale, values, majorUnit)
| 175 | * @return {object[]} |
| 176 | */ |
| 177 | function ticksFromTimestamps(scale, values, majorUnit) { |
| 178 | const ticks = []; |
| 179 | /** @type {Object<number,object>} */ |
| 180 | const map = {}; |
| 181 | const ilen = values.length; |
| 182 | let i, value; |
| 183 | |
| 184 | for (i = 0; i < ilen; ++i) { |
| 185 | value = values[i]; |
| 186 | map[value] = i; |
| 187 | |
| 188 | ticks.push({ |
| 189 | value, |
| 190 | major: false |
| 191 | }); |
| 192 | } |
| 193 | |
| 194 | // We set the major ticks separately from the above loop because calling startOf for every tick |
| 195 | // is expensive when there is a large number of ticks |
| 196 | return (ilen === 0 || !majorUnit) ? ticks : setMajorTicks(scale, ticks, map, majorUnit); |
| 197 | } |
| 198 | |
| 199 | export default class TimeScale extends Scale { |
| 200 |
no test coverage detected