diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 21:57:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 21:57:37 +0300 |
| commit | 30df482b7dbacf434a4a2ba5c10a668166803f34 (patch) | |
| tree | 07d701c91f3e9a14dba2994a614ae8f350b8a41c | |
| parent | 9dc3512e030604ca0c63919e41c0e5a4987b117a (diff) | |
showcase: show project score in rank-history SVG tooltip
Add Score float64 to svgProjectData (serialised as JSON) so the JS tooltip
can display it. A 'score: X.X' line is inserted into the tooltip body just
below the project name title and above the weekly snapshot rows, rendered in
a dimmer grey (#888) to visually separate it from the rank-history data.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/showcase/rank_history_svg.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/showcase/rank_history_svg.go b/internal/showcase/rank_history_svg.go index 5022cd3..16b3a5f 100644 --- a/internal/showcase/rank_history_svg.go +++ b/internal/showcase/rank_history_svg.go @@ -47,6 +47,7 @@ type svgProjectData struct { Color string `json:"color"` Points []svgTimePoint `json:"points"` Inactive bool `json:"inactive"` + Score float64 `json:"score"` // project score for tooltip display } // projectColor returns a visually distinct CSS hex color for project index i. @@ -228,11 +229,17 @@ func GenerateRankHistorySVG(summaries []ProjectSummary) string { } } + score := 0.0 + if s.Metadata != nil { + score = s.Metadata.Score + } + allProjects = append(allProjects, svgProjectData{ Name: s.Name, Color: projectColor(colorIdx), Points: pts, Inactive: inactive, + Score: score, }) colorIdx++ } @@ -495,9 +502,18 @@ function onEnter(idx,evt){ // Clear old tooltip rows. while(ttbd.firstChild)ttbd.removeChild(ttbd.firstChild); + // Score row just below the title. + var scoreRow=document.createElementNS('http://www.w3.org/2000/svg','text'); + scoreRow.setAttribute('x','10'); + scoreRow.setAttribute('y','30'); + scoreRow.setAttribute('class','ttrow'); + scoreRow.setAttribute('fill','#888'); + scoreRow.textContent='score: '+p.score.toFixed(1); + ttbd.appendChild(scoreRow); + // Build one row per snapshot, newest first (points array is oldest-first). - // Start below the title (baseline y=18 + gap) so rows never overlap the title. - var y=32; + // Start below the score row; y=44 keeps clear of title (y=18) and score (y=30). + var y=44; for(var i=p.points.length-1;i>=0;i--){ var pt=p.points[i]; if(pt.spot<=0)continue; |
