Question: D3 / html question/ data reshaping: Data.csv is in the form of: New York World Games Regionals X Competition Nationals Event Team 23 14 15
D3 / html question/ data reshaping:
Data.csv is in the form of:
| New York | World Games | Regionals | X Competition | Nationals | Event | Team |
| 23 | 14 | 15 | 45 | 46 | Event One | TeamOne |
| 34 | 56 | 56 | 56 | 56 | Event Two | TeamOne |
| 56 | 56 | 34 | 23 | 79 | Event Three | TeamOne |
| 26 | 47 | 75 | 52 | 24 | Event One | TeamTwo |
| 45 | 24 | 17 | 74 | 37 | Event Two | TeamTwo |
| 14 | 62 | 37 | 73 | 26 | Event Three | TeamTwo |
| 47 | 85 | 63 | 66 | 34 | Event One | TeamThree |
| 78 | 72 | 32 | 72 | 72 | Event Two | TeamThree |
| 97 | 17 | 60 | 63 | 28 | Event Three | TeamThree |
Using d3.v3 I have to make a heatmap where I will select a team to show and then show a heatmap with the event on the x axis and the competition on the x axis with the block colored by the corresponding value. How would I reshape the data to make this possible?
I would imagine it begins with
data = d3.csv("data.csv', function(error, data) {
data.forEach{function(d) {
d.ny = +d["New York"]; ....});
And the data would end up being similar to
data = [
{ Team: TeamOne, Event: {
Event One: {ny: 23, wg:14, r:15, x:25, n:46},
Event Two: {ny:34, wg:56, r:56, x:56, n:46},
Event Three: (ny: ....}}},
{Team: TeamTwo, Event: {
Event One: {ny: ...}.
Event Two: ...etc.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
