* Returns the start and end offsets from edges in the form of {start, end} * where each value is a relative width to the scale and ranges between 0 and 1. * They add extra margins on the both sides by scaling down the original scale. * Offsets are added when the `offset` option is true. * @p
(timestamps = [])
| 415 | * @protected |
| 416 | */ |
| 417 | initOffsets(timestamps = []) { |
| 418 | let start = 0; |
| 419 | let end = 0; |
| 420 | let first, last; |
| 421 | |
| 422 | if (this.options.offset && timestamps.length) { |
| 423 | first = this.getDecimalForValue(timestamps[0]); |
| 424 | if (timestamps.length === 1) { |
| 425 | start = 1 - first; |
| 426 | } else { |
| 427 | start = (this.getDecimalForValue(timestamps[1]) - first) / 2; |
| 428 | } |
| 429 | last = this.getDecimalForValue(timestamps[timestamps.length - 1]); |
| 430 | if (timestamps.length === 1) { |
| 431 | end = last; |
| 432 | } else { |
| 433 | end = (last - this.getDecimalForValue(timestamps[timestamps.length - 2])) / 2; |
| 434 | } |
| 435 | } |
| 436 | const limit = timestamps.length < 3 ? 0.5 : 0.25; |
| 437 | start = _limitValue(start, 0, limit); |
| 438 | end = _limitValue(end, 0, limit); |
| 439 | |
| 440 | this._offsets = {start, end, factor: 1 / (start + 1 + end)}; |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Generates a maximum of `capacity` timestamps between min and max, rounded to the |
no test coverage detected