commit 4864fd7e6526d9d36d2cd9892218d06d0eb48862
parent 9b1fe1a24494f692811aced271eb6885d02144dc
Author: Damian Myrda <damian@prime8.dev>
Date: Fri, 23 Oct 2026 00:34:16 +0000
web: hand off timeline bars instead of overlapping
Diffstat:
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/internal/utils/period.go b/internal/utils/period.go
@@ -98,6 +98,10 @@ type Axis struct {
// EndLabel marks the right edge: "now" while a role is current, unless
// the last year tick sits too close to it to fit both labels.
EndLabel string
+ // starts holds every role's start month: a role that ends in the month
+ // the next one starts hands off at that month's start instead of
+ // running through it and overlapping.
+ starts map[int]bool
}
func NewAxis(spans []Span) Axis {
@@ -112,7 +116,10 @@ func NewAxis(spans []Span) Axis {
current = current || s.Current
}
first -= first % 12 // january
- a := Axis{first: first, months: max(last+1-first, 1)}
+ a := Axis{first: first, months: max(last+1-first, 1), starts: map[int]bool{}}
+ for _, s := range spans {
+ a.starts[monthIndex(s.Start)] = true
+ }
for m := first; m < first+a.months; m += 12 {
a.Ticks = append(a.Ticks, Tick{Label: fmt.Sprint(m / 12), At: a.at(m)})
}
@@ -131,7 +138,12 @@ func (a Axis) From(startDate time.Time) float64 {
return a.at(monthIndex(startDate))
}
-// To is where a role's bar ends: the end of its last month.
+// To is where a role's bar ends: the end of its last month, or its start
+// when another role begins that month.
func (a Axis) To(endDate *time.Time, current bool) float64 {
- return a.at(monthIndex(spanEnd(endDate, current)) + 1)
+ m := monthIndex(spanEnd(endDate, current))
+ if !current && a.starts[m] {
+ return a.at(m)
+ }
+ return a.at(m + 1)
}
diff --git a/internal/utils/period_test.go b/internal/utils/period_test.go
@@ -75,4 +75,8 @@ func TestAxis(t *testing.T) {
if from, to := a.From(month("2024-06")), a.To(monthPtr("2024-08"), false); from != 5.0/34 || to != 8.0/34 {
t.Errorf("amplifier spans %v..%v", from, to)
}
+ // mandolin ends the month hark starts: the bars meet, never overlap
+ if end, next := a.To(monthPtr("2026-02"), false), a.From(month("2026-02")); end != next {
+ t.Errorf("mandolin ends at %v, hark starts at %v", end, next)
+ }
}