|
|
|
@ -4,52 +4,6 @@ const goalsAgainst = {}; |
|
|
|
|
const Diagram = { |
|
|
|
|
clear: () => d3.select('svg').selectAll("*").remove(), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // json.tourneys[eventKey].teams.sort()
|
|
|
|
|
//
|
|
|
|
|
// sortKey = "goalsFor"
|
|
|
|
|
//
|
|
|
|
|
// switch (sortKey) {
|
|
|
|
|
// case 'goalsFor':
|
|
|
|
|
// // console.info(json.tourneys[eventKey].teams)/
|
|
|
|
|
// // return json.tourneys[eventKey].teams;
|
|
|
|
|
//
|
|
|
|
|
// const teams = json.tourneys[eventKey].teams
|
|
|
|
|
// .slice()
|
|
|
|
|
// .sort((a, b) => {
|
|
|
|
|
// const n1 = json.countries[json.teams[a]].n;
|
|
|
|
|
// const n2 = json.countries[json.teams[b]].n;
|
|
|
|
|
//
|
|
|
|
|
// if (n1 < n2) {
|
|
|
|
|
// return -1;
|
|
|
|
|
// }
|
|
|
|
|
// else if (n1 > n2) {
|
|
|
|
|
// return 1;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return 0;
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// console.warn(teams.map(v => {
|
|
|
|
|
// return json.countries[json.teams[v]].n
|
|
|
|
|
// }))
|
|
|
|
|
//
|
|
|
|
|
// // console.warn(teams.map(a => json.countries[json.teams[a]].n))
|
|
|
|
|
//
|
|
|
|
|
// return teams;
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'goalsAgainst':
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'countryName':
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// case 'countryPopulation':
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
swapGroupArcs: (chords, i, j) => { |
|
|
|
|
if (i < 0 || j < 0 || i === j) { |
|
|
|
|
return chords; |
|
|
|
@ -101,6 +55,11 @@ const Diagram = { |
|
|
|
|
return data.countries[countryId].n; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getPopulation: (data, eventIndex, n) => { |
|
|
|
|
const teamId = data.tourneys[eventIndex].teams[n]; |
|
|
|
|
return data.countries[data.teams[teamId]].p; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getGoalsFor: (data, eventIndex, n) => { |
|
|
|
|
const teamId = data.tourneys[eventIndex].teams[n]; |
|
|
|
|
|
|
|
|
@ -156,9 +115,10 @@ const Diagram = { |
|
|
|
|
.call(null, chordMatrix); |
|
|
|
|
|
|
|
|
|
const sortedChords = Sorter.sort(chords, 0, chords.groups.length - 1, |
|
|
|
|
Diagram.getCountryName.bind(null, data, eventIndex), |
|
|
|
|
// Diagram.getCountryName.bind(null, data, eventIndex),
|
|
|
|
|
// Diagram.getGoalsFor.bind(null, data, eventIndex),
|
|
|
|
|
// Diagram.getGoalsAgainst.bind(null, data, eventIndex),
|
|
|
|
|
Diagram.getPopulation.bind(null, data, eventIndex), |
|
|
|
|
Diagram.swapGroups.bind(null, data, eventIndex)); |
|
|
|
|
|
|
|
|
|
const arc = d3.arc() |
|
|
|
@ -234,15 +194,11 @@ const Diagram = { |
|
|
|
|
}) |
|
|
|
|
.style("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; }) |
|
|
|
|
.text(function(d) { |
|
|
|
|
// SORT BY GOALS SCORED
|
|
|
|
|
// SORT BY ALPHABETICAL
|
|
|
|
|
// SORT BY COUNTRY SIZE
|
|
|
|
|
// COLOR BY CONTINENT
|
|
|
|
|
// STRANGE EXTENDED TIME CHILE-BRAZIL - FIX BY HAND? IS BECAUE se1 IS SCORE __GOING INTO__ EXTENDED TIME
|
|
|
|
|
// console.info(metaMatrix[d.index])
|
|
|
|
|
|
|
|
|
|
const teamId = data.tourneys[eventIndex].teams[d.index]; |
|
|
|
|
return data.countries[data.teams[teamId]].n + ' ' + goalsAgainst[teamId]; |
|
|
|
|
const country = data.countries[data.teams[teamId]]; |
|
|
|
|
return data.countries[data.teams[teamId]].n + ' ' + country.p; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|