| 184 |
184 |
assert.ok(ticks[i].x0 >= ticks[i - 1].x1, `collision between ${ticks[i - 1].text} and ${ticks[i].text}`) |
| 185 |
185 |
} |
| 186 |
186 |
const days = ticks.filter(t => t.strong) |
| 187 |
|
− assert.equal(days.length, 3) |
| 188 |
|
− assert.deepEqual(days.map(t => t.text), ['27', '28', '29']) |
|
187 |
+ // The first day label sits at x ≈ 0 and would be half hidden → dropped; the other two must be there. |
|
188 |
+ assert.deepEqual(days.map(t => t.text), ['28', '29']) |
| 189 |
189 |
// Higher levels win when space is scarce. |
| 190 |
190 |
const tight = timeTicks({ times, from: 0, to: times.length - 1, tf: '1min', xOf, width, measure: () => 120, gap: 14 }) |
| 191 |
191 |
assert.ok(tight.length <= 7) |
| 192 |
|
− assert.equal(tight.filter(t => t.level >= 4).length, 3, 'day changes always survive the thinning') |
|
192 |
+ assert.equal(tight.filter(t => t.level >= 4).length, 2, 'day changes always survive the thinning') |
|
193 |
+ // A label is never placed where it would need to be shifted inward. |
|
194 |
+ for (const t of [...ticks, ...tight]) assert.ok(t.x0 >= -7 && t.x1 <= width + 7) |
| 193 |
195 |
assert.ok(tight.every(t => t.level >= 2), 'only hour-level marks remain') |
| 194 |
196 |
}) |