import {Plot} from "@mkfreeman/plot-tooltip"
result_data_ojs = transpose(result_data)
Plot.plot({
color: {
legend: false,
type: "pow",
//scheme: "oranges"
range: ["#fef3e4","#F6B352"]
},
y: {
grid: false,
label:"Home"
},
x: {
grid: false,
label:"Away",
axis: "top"
},
marks: [
Plot.cell(result_data_ojs, {
x: "GA",
y: "GH",
fill: "frac",
title: d => d.GH + " : " + d.GA + "\n\n" +d.frac?.toFixed(3) + "%"
}),
Plot.text(result_data_ojs, {
x: "GA",
y: "GH",
text: d => d.frac?.toFixed(3) + "%",
fill: d=> (d.frac>=5.5) ? "black" : "black"
})
],
style: {
background: "#383A3F",
fill: "#D3D3D3",
fontFamily: "Poppins",
fontSize: "20px"
},
tooltip: {
stroke: "white",
color: "#F68657"
},
height: 950,
width: 950,
marginLeft: 50,
marginRight: 50,
marginTop: 50,
marginBottom: 50,
insetTop: 0,
insetBottom: 0,
insetLeft: 0,
insetRight: 0
})
Result Statistics
Stats from more than 1 million matches played world-wide since 1890
Result Matrix
Average goals
goal_data_ojs = transpose(goal_data)
Plot.plot({
color: {
legend: true
},
y: {
grid: false,
domain: d3.extent(goal_data_ojs,d => d.avg_goals),
label:"↑ Avg. Goals",
ticks: 5
},
x: {
grid: false,
domain: d3.extent(goal_data_ojs,d => d.year),
label:"Year",
ticks: 5
},
marks: [
Plot.gridY({ticks:5, stroke: "#fff", strokeOpacity: 0.2}),
Plot.dot(goal_data_ojs, {x: "year", y: "avg_goals", fill: "continent",
title: (d) => `${d.avg_goals} (${d.continent})`
}),
Plot.line(goal_data_ojs, {x: "year", y: "avg_goals", z: "continent", stroke: "continent"
})
//Plot.text(goal_data_ojs, Plot.selectLast({x: "year", y: "avg_goals", z: "continent", text: "continent", textAnchor: "start", dx: 3}))
],
style: {
background: "#383A3F",
fill: "#D3D3D3",
fontFamily: "Poppins",
fontSize: "20px"
},
height: 600,
width: 950,
marginLeft: 50,
marginRight: 50,
marginTop: 50,
marginBottom: 50,
insetTop: 0,
insetBottom: 0,
insetLeft: 0,
insetRight: 0
})
Home field advantage
Home field advantage per year and continent
hfa_data_ojs = transpose(hfa_data)
Plot.plot({
color: {
legend: true
},
y: {
grid: false,
domain: d3.extent(hfa_data_ojs,d => d.hfa),
label:"↑ Fraction of home games won",
ticks: 5
},
x: {
grid: false,
domain: d3.extent(hfa_data_ojs,d => d.year),
label:"Year",
ticks: 5
},
marks: [
Plot.gridY({ticks:5, stroke: "#fff", strokeOpacity: 0.2}),
Plot.dot(hfa_data_ojs, {x: "year", y: "hfa", fill: "continent",
title: (d) => `${d.hfa} (${d.continent})`
}),
Plot.line(hfa_data_ojs, {x: "year", y: "hfa", z: "continent", stroke: "continent"
})
//Plot.text(goal_data_ojs, Plot.selectLast({x: "year", y: "avg_goals", z: "continent", text: "continent", textAnchor: "start", dx: 3}))
],
style: {
background: "#383A3F",
fill: "#D3D3D3",
fontFamily: "Poppins",
fontSize: "20px"
},
height: 600,
width: 950,
marginLeft: 50,
marginRight: 50,
marginTop: 50,
marginBottom: 50,
insetTop: 0,
insetBottom: 0,
insetLeft: 0,
insetRight: 0
})
Home field advantage per country
(all matches played since 2010)