Skip to content

Commit

Permalink
Don't stretch win% plot to 0% and 100% unless necessary, because thos…
Browse files Browse the repository at this point in the history
…e extremes are rarely reached
  • Loading branch information
dumbmatter committed Oct 25, 2024
1 parent 31aacb9 commit 17e34a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Don't allow play if versions in tabs don't match
- close worker?
- newPhasePreseason being called twice in two different tabs and somehow updating the database twice?

on trade graphs, don't use 0% and 100% as limits for wins graph https://discord.com/channels/290013534023057409/331882115119448065/1295991083637149829

wOBA, wrc, wrc+

option to hide jersey numbers on team history page https://discord.com/channels/290013534023057409/331882115119448065/1295583496084914277
Expand Down
13 changes: 11 additions & 2 deletions src/ui/views/TradeSummary/Charts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,31 @@ const Charts = ({
View<"tradeSummary">,
"phase" | "season" | "seasonsToPlot" | "stat" | "teams" | "usePts"
>) => {
const pctKey = usePts ? "ptsPct" : "winp";

const allStats: number[] = [];
const allPcts: number[] = [];
const seasons: number[] = [];

for (const row of seasonsToPlot) {
for (const team of row.teams) {
if (team.stat !== undefined) {
allStats.push(team.stat);

const pct = team[pctKey];
if (pct !== undefined) {
allPcts.push(pct);
}
}
}
seasons.push(row.season);
}

const xDomain = [seasons[0], seasons.at(-1)] as [number, number];

const yDomainPct = [Math.min(0.25, ...allPcts), Math.max(0.75, ...allPcts)];
const yScale = scaleLinear({
domain: [0, 1],
domain: yDomainPct,
range: [HEIGHT, 0],
});

Expand All @@ -284,7 +293,7 @@ const Charts = ({
usePts ? "point" : "winning"
} percentages before and after the
trade`}
valueKey={usePts ? "ptsPct" : "winp"}
valueKey={pctKey}
xDomain={xDomain}
yScale={yScale}
yTickFormat={helpers.roundWinp}
Expand Down

0 comments on commit 17e34a3

Please sign in to comment.