Skip to content

Commit 19d560b

Browse files
committed
Break out salary by position
1 parent d82eb85 commit 19d560b

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/StatViz.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ toc: false
99
const stats = await FileAttachment("./data/stats.json").json();
1010
```
1111

12+
<h3>Goal Distribution</h3>
1213
${Plot.plot({
1314
y: {grid:true},
1415
x: {interval: 1},
@@ -18,6 +19,7 @@ ${Plot.plot({
1819
]
1920
})}
2021

22+
<h3>Assist Distribution</h3>
2123
${Plot.plot({
2224
y: {grid:true},
2325
x: {interval: 1},
@@ -27,6 +29,7 @@ ${Plot.plot({
2729
]
2830
})}
2931

32+
<h3>Toughness Distribution</h3>
3033
${Plot.plot({
3134
y: {grid:true},
3235
x: {interval: 1},
@@ -36,6 +39,7 @@ ${Plot.plot({
3639
]
3740
})}
3841

42+
<h3>DStat Distribution</h3>
3943
${Plot.plot({
4044
y: {grid:true},
4145
x: {interval: 1},
@@ -45,6 +49,7 @@ ${Plot.plot({
4549
]
4650
})}
4751

52+
<h3>GStat Distribution</h3>
4853
${Plot.plot({
4954
y: {grid:true, interval: 1},
5055
x: {interval: 1},
@@ -54,8 +59,21 @@ ${Plot.plot({
5459
]
5560
})}
5661

62+
<h3>Forwards Salary vs Rating</h3>
63+
${Plot.dot(
64+
stats.contractRanking.filter(s => s.Position === "F"),
65+
{ x: "Salary", y: "Rating"}).plot({grid:true})
66+
}
67+
68+
<h3>Defencemen Salary vs Rating</h3>
69+
${Plot.dot(
70+
stats.contractRanking.filter(s => s.Position === "D"),
71+
{ x: "Salary", y: "Rating"}).plot({grid:true})
72+
}
5773

74+
<h3>Goalies Salary vs Rating</h3>
5875
${Plot.dot(
59-
stats.contractRanking,
76+
stats.contractRanking.filter(s => s.Position === "G"),
6077
{ x: "Salary", y: "Rating"}).plot({grid:true})
6178
}
79+

src/data/stats.json.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { readCsvFile, getOverallStats, latestStatsFile } from "../components/loadfiles.js";
1+
import { readCsvFile, getOverallStats, latestStatsFile, mapPosition } from "../components/loadfiles.js";
22

33
const contracts = await readCsvFile("src/data/contracts.csv");
44

55
const contractRanking = contracts.map(info => {
66

77
const stats = latestStatsFile.find(s => s.hockeyRef === info.ID) || {};
8-
const position = stats.pos || 'F'; // Default to Forward if position not found
8+
const position = mapPosition(stats.pos);
99
const playerStats = getOverallStats(position, stats);
1010
return {
11+
Position: position,
1112
Salary: info.Salary || 0,
1213
Rating: playerStats.games_played ? playerStats.rating : 0,
1314
};

0 commit comments

Comments
 (0)