Published
Edited
Sep 28, 2020
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof dd3 = select({
title: "Pick players to compare",
options: ["Jadon Sancho (Dortmund)", "Thorgan Hazard (Dortmund)", "Rashford (Man United)", "Greenwood (Man United)", "Martial (Man United)", "Dan James (Man United)"],
multiple: true,
value: ["Jadon Sancho (Dortmund)", "Rashford (Man United)", "Martial (Man United)"],
})
Insert cell
data = {
var dataS = []
dd3.forEach(function(stat) {if (stat == "Jadon Sancho (Dortmund)") {dataS.push(Data4Sancho)}});
dd3.forEach(function(stat) {if (stat == "Thorgan Hazard (Dortmund)") {dataS.push(Data4THazard)}});
dd3.forEach(function(stat) {if (stat == "Rashford (Man United)") {dataS.push(Data4Rashford)}});
dd3.forEach(function(stat) {if (stat == "Greenwood (Man United)") {dataS.push(Data4Greenwood)}});
dd3.forEach(function(stat) {if (stat == "Martial (Man United)") {dataS.push(Data4Martial)}});
dd3.forEach(function(stat) {if (stat == "Dan James (Man United)") {dataS.push(Data4DanJames)}});
return dataS
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxValue = d3.max(_.flatten(val).map(d => d.value))
Insert cell
val = data.map(d => d.stats)
Insert cell
Insert cell
Insert cell
Insert cell
axesDomain = data[0].stats.map(d => d.axis)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Data4Bale19 = flatBale19.filter((row)=> dd2.includes(row.axis));
Insert cell
Insert cell
Insert cell
Insert cell
Data4THazard = d3.json("https://gist.githubusercontent.com/theojolliffe/7b47f0d5a8b1fccb9adaa2f069434704/raw/b429ee8e2c3a646458aa5485b4ef5a70fb7002a1/THazardStats20")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Martial = d3.json("https://gist.githubusercontent.com/theojolliffe/7a684b13f2a4ab4ea9a0afea400303e5/raw/169212c222050a4d6b225b5340192bd66b8b2b45/MartialStats20")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Greenwood = d3.json("https://gist.githubusercontent.com/theojolliffe/eb0227d8d8f52a981bcf1b0719c9e221/raw/ae613a925636f2fb01edbefeff352d48f1a2c173/GreenwoodStats20")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4DanJames = d3.json("https://gist.githubusercontent.com/theojolliffe/9c1c1b4db142fab0779ed2bb06289b69/raw/d496324c47efccf1a6976669ec00337939f4fc87/DanJamesStats20")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Sanchez = d3.json("https://gist.githubusercontent.com/theojolliffe/c6413ec3e7b955d7cbde8d10f245bfbf/raw/f356586d6f4d474f7ad45aaee27bb772a7c70359/SanchezStats")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Alderweireld = d3.json("https://gist.githubusercontent.com/theojolliffe/72547244b46fa13fdacddc7e8a7d5c3d/raw/25dc318b66990c665a932e7a2d0cc2f711943e43/AlderweireldStats")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Dier = d3.json("https://gist.githubusercontent.com/theojolliffe/c7f80a56823cc2cc537f819b743bb4cc/raw/2f46901a8456c9f6c495b9aa00e5c6bb9d5b9e96/DierStats")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Dias = d3.json("https://gist.githubusercontent.com/theojolliffe/e65675f6dd4201ebb03c948015ee3478/raw/9084b2f8bf949450853eb70e5959678a3a059e31/RubenDiasStats")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Data4Rashford = d3.json("https://gist.githubusercontent.com/theojolliffe/3bcc73bd393d5b486fd1de5df7bc7cd0/raw/e638b16f6c3672ed2963000576ad50e44b6ea039/RashfordStats20")
.then(
function success(allData) {
const data = allData.data.members[0].statistic_groups;
const name = allData.data.members[0].name;
const mins = allData.data.members[0].statistic_groups[0].statistics[1].value;
const flat = flatten(data);
const stats = flat.filter((row)=> dd2.includes(row.axis));
return {stats, name, mins}
},
function error(e) {
throw e;
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
flatRonaldo[1].value
Insert cell
flatSon[1]
Insert cell
flatBale[1]
Insert cell
Insert cell
Insert cell
Insert cell
axesLength = data[0].stats.length
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
height = 600
Insert cell
Insert cell
Insert cell
Insert cell
color = d3.scaleOrdinal()
.range(["#EDC951","#CC333F","#00A0B0", "green", "purple", "#FF1493"])
Insert cell
Insert cell
Insert cell
Insert cell
function radio(config = {}) {
let {
value: formValue,
title,
description,
submit,
options,
disabled
} = Array.isArray(config) ? { options: config } : config;
options = options.map(o =>
typeof o === "string" ? { value: o, label: o } : o
);
const form = input({
type: "radio",
title,
description,
submit,
getValue: input => {
if (input.checked) return input.value;
const checked = Array.prototype.find.call(input, radio => radio.checked);
return checked ? checked.value : undefined;
},
form: html`
<form>
${options.map(({ value, label }, i) => {
const input = html`<input type=radio name=input ${
value === formValue ? "checked" : ""
} style="vertical-align: top; ${
i === 0 ? `margin-left: 1px;` : ``
}" />`;
input.setAttribute("value", value);
if (disabled) input.setAttribute("value", disabled);
const tag = html`
<label style="display: inline-block; margin: 5px 10px 3px 0; font-size: 0.85em;">
${input}
${label}
</label>`;
return tag;
})}
</form>
`
});
form.output.remove();
return form;
}
Insert cell
d3format = require("d3-format@1")
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more