Skip to content

Commit ab6a2ea

Browse files
committed
moved d3 back from archived branch
1 parent 2ad0236 commit ab6a2ea

4 files changed

+62
-0
lines changed

.DS_Store

8 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//part 1
2+
winsMetascores = _.map(data, d => {
3+
let wins = d.Awards.match(/(\d+) win/);
4+
wins = wins ? wins[1] : 0;
5+
console.log(wins);
6+
return {
7+
wins: +wins,
8+
score: +d.Metascore
9+
};
10+
});
11+
12+
//part 2
13+
vegalite({
14+
data: { values: winsMetascores },
15+
mark: "point",
16+
encoding: {
17+
x: { type: "quantitative", field: "score" },
18+
y: { type: "quantitative", field: "wins" }
19+
}
20+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//part 1
2+
yearScoreGenre = _.map(data, d => {
3+
let wins = d.Awards.match(/(\d+) win/);
4+
wins = wins ? wins[1] : 0;
5+
console.log(wins);
6+
return {
7+
date: new Date(d.Released),
8+
score: +d.Metascore,
9+
genre: d.Genre.split(", ")[0]
10+
};
11+
});
12+
13+
//part 2
14+
vegalite({
15+
width: 600,
16+
data: { values: yearScoreGenre },
17+
mark: "line",
18+
encoding: {
19+
x: { type: "temporal", field: "date" },
20+
y: { type: "quantitative", field: "score" },
21+
color: { type: "nominal", field: "genre" }
22+
}
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//part 1
2+
monthGenrePopularity = _.map(data, d => {
3+
return {
4+
date: new Date(d.Released),
5+
genre: d.Genre.split(", ")[0],
6+
votes: +d.imdbVotes.replace(/\,/g, "")
7+
};
8+
});
9+
10+
//part 2
11+
vegalite({
12+
data: { values: monthGenrePopularity },
13+
mark: "rect",
14+
encoding: {
15+
x: { field: "date", type: "ordinal", timeUnit: "month" },
16+
y: { field: "genre", type: "nominal" },
17+
color: { type: "quantitative", aggregate: "count", field: "*" }
18+
}
19+
});

0 commit comments

Comments
 (0)