| 123 | }; |
| 124 | |
| 125 | const computeCategoryStep = (data: ReadonlyArray<OHLCDataPoint>): number => { |
| 126 | const timestamps: number[] = []; |
| 127 | for (let i = 0; i < data.length; i++) { |
| 128 | const { timestamp } = getOHLC(data[i]); |
| 129 | if (Number.isFinite(timestamp)) timestamps.push(timestamp); |
| 130 | } |
| 131 | |
| 132 | if (timestamps.length < 2) return 1; |
| 133 | timestamps.sort((a, b) => a - b); |
| 134 | |
| 135 | let minStep = Number.POSITIVE_INFINITY; |
| 136 | for (let i = 1; i < timestamps.length; i++) { |
| 137 | const d = timestamps[i] - timestamps[i - 1]; |
| 138 | if (d > 0 && d < minStep) minStep = d; |
| 139 | } |
| 140 | return Number.isFinite(minStep) && minStep > 0 ? minStep : 1; |
| 141 | }; |
| 142 | |
| 143 | const computeCategoryWidthClip = ( |
| 144 | xScale: LinearScale, |