Skip to content

Commit d82eb85

Browse files
committed
Added salary vs rating chart
1 parent f4e30fc commit d82eb85

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/StatViz.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ ${Plot.plot({
5353
Plot.barY(stats.gstatRanges, {x: "gstat", y: "playerCount"})
5454
]
5555
})}
56+
57+
58+
${Plot.dot(
59+
stats.contractRanking,
60+
{ x: "Salary", y: "Rating"}).plot({grid:true})
61+
}

src/data/allplayers.json.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ const contracts = await readCsvFile("src/data/contracts.csv");
66

77
const teams = ["All",...teamInfo.map(team=>team.ABBR).sort(), "FA"];
88

9-
const lastPeriodNum = availablePeriods.length-1;
10-
119
const playerData = playerInfo.map(info => {
1210

1311
const roster = latestRosterFile.find(player => player.ID === info.ID);

src/data/stats.json.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
import { readStatsFile, latestStatsFile } from "../components/loadfiles.js";
1+
import { readCsvFile, getOverallStats, latestStatsFile } from "../components/loadfiles.js";
2+
3+
const contracts = await readCsvFile("src/data/contracts.csv");
4+
5+
const contractRanking = contracts.map(info => {
6+
7+
const stats = latestStatsFile.find(s => s.hockeyRef === info.ID) || {};
8+
const position = stats.pos || 'F'; // Default to Forward if position not found
9+
const playerStats = getOverallStats(position, stats);
10+
return {
11+
Salary: info.Salary || 0,
12+
Rating: playerStats.games_played ? playerStats.rating : 0,
13+
};
14+
});
15+
216

317
// Extract goal distribution - count players by goal totals
418
const goalDistribution = {};
@@ -109,4 +123,4 @@ const gstatRanges = Object.keys(gstatDistribution)
109123
}))
110124
.sort((a, b) => a.gstat - b.gstat);
111125

112-
process.stdout.write(JSON.stringify({ goalRanges, assistRanges, toughnessRanges, dstatRanges, gstatRanges }));
126+
process.stdout.write(JSON.stringify({ goalRanges, assistRanges, toughnessRanges, dstatRanges, gstatRanges, contractRanking }));

0 commit comments

Comments
 (0)