diff --git a/app/components/standings/PointProgressionChart.stories.tsx b/app/components/standings/PointProgressionChart.stories.tsx index 17c821e..7d71142 100644 --- a/app/components/standings/PointProgressionChart.stories.tsx +++ b/app/components/standings/PointProgressionChart.stories.tsx @@ -9,7 +9,7 @@ const meta: Meta = { layout: "padded", docs: { description: { - component: "Multi-line chart showing team point progression over time. Features monotone curve rendering and interactive legend hover highlighting to isolate individual team lines.", + component: "Multi-line chart showing team point progression over time. Features monotone curve rendering, interactive legend hover highlighting to isolate individual team lines, and legend sorted by current ranking.", }, }, }, @@ -90,7 +90,7 @@ export const OverlappingPoints: Story = { parameters: { docs: { description: { - story: "Demonstrates interactive highlighting via the legend. Hover over a team name in the legend to isolate that team's line and dim the others.", + story: "Demonstrates interactive highlighting via the legend and legend sorted by current ranking. Hover over a team name in the legend to isolate that team's line and dim the others.", }, }, }, diff --git a/app/components/standings/PointProgressionChart.tsx b/app/components/standings/PointProgressionChart.tsx index 3bab221..e3a2d53 100644 --- a/app/components/standings/PointProgressionChart.tsx +++ b/app/components/standings/PointProgressionChart.tsx @@ -105,6 +105,13 @@ export function PointProgressionChart({ chartData, teams }: PointProgressionChar ); } + const latestData = chartData[chartData.length - 1]; + const teamsByRank = [...teams].toSorted((a, b) => { + const aPoints = (typeof latestData[a.name] === 'number' ? latestData[a.name] : 0) as number; + const bPoints = (typeof latestData[b.name] === 'number' ? latestData[b.name] : 0) as number; + return bPoints - aPoints; + }); + return ( @@ -148,7 +155,7 @@ export function PointProgressionChart({ chartData, teams }: PointProgressionChar ({ value: team.name, color: COLORS[index % COLORS.length] }))} + payload={teamsByRank.map((team) => ({ value: team.name, color: COLORS[teams.findIndex(t => t.id === team.id) % COLORS.length] }))} onHover={setHoveredLine} onLeave={() => setHoveredLine(null)} /> diff --git a/app/routes/leagues/$leagueId.standings.$seasonId.tsx b/app/routes/leagues/$leagueId.standings.$seasonId.tsx index 5fdd793..c8c2a18 100644 --- a/app/routes/leagues/$leagueId.standings.$seasonId.tsx +++ b/app/routes/leagues/$leagueId.standings.$seasonId.tsx @@ -146,6 +146,7 @@ export default function LeagueStandings() { points: s.totalPoints, rankChange: s.rankChange, pointChange: s.sevenDayPointChange, + href: `/leagues/${league.id}/standings/${season.id}/teams/${s.teamId}`, })); return (