* @param {number} exampleTime * @return {number} * @private
(exampleTime)
| 608 | * @private |
| 609 | */ |
| 610 | _getLabelCapacity(exampleTime) { |
| 611 | const timeOpts = this.options.time; |
| 612 | const displayFormats = timeOpts.displayFormats; |
| 613 | |
| 614 | // pick the longest format (milliseconds) for guesstimation |
| 615 | const format = displayFormats[timeOpts.unit] || displayFormats.millisecond; |
| 616 | const exampleLabel = this._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(this, [exampleTime], this._majorUnit), format); |
| 617 | const size = this._getLabelSize(exampleLabel); |
| 618 | // subtract 1 - if offset then there's one less label than tick |
| 619 | // if not offset then one half label padding is added to each end leaving room for one less label |
| 620 | const capacity = Math.floor(this.isHorizontal() ? this.width / size.w : this.height / size.h) - 1; |
| 621 | return capacity > 0 ? capacity : 1; |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * @protected |
no test coverage detected