Published
Edited
Jun 2, 2019
Fork of Radar chart
3 forks
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof dataSelect1 = select({
title: "Team 1",
options: Object.keys(team),
value: "iphone"
})
Insert cell
viewof dataSelect2 = select({
title: "Team 2",
options: Object.keys(team),
value: "Atalanta"
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
radarLine = d3.lineRadial()
.curve(d3[curveSelect])
.radius((d, i) => rScale[i](d))
.angle((d, i) => i * angleSlice)
Insert cell
Insert cell
colors = ["#2c3e50","#85c1e9","#717d7e", "#1b4f72", "#922b21","#ca6f1e"]
Insert cell
rScale = maxValues.map(el => d3.scaleLinear().domain([0, el]).range([0, radius]))

Insert cell
Insert cell
maxValues = {
let new_vals = [];
for(var i=0; i<data[0].length; i++){
new_vals.push(d3.max(data.map(d => d[i].value)));
}
return new_vals;
}
Insert cell
rScale[0]
Insert cell
Insert cell
datagroup = [
[//Juventus
{axis:"Shots",value:443},
{axis:"Shots on target",value:227},
{axis:"Corners",value:244},
{axis:"Goals",value:70},
{axis:"Keeper Score",value:0.78},
],[//Napoli
{axis:"Shots",value:550},
{axis:"Shots on target",value:290},
{axis:"Corners",value:255},
{axis:"Goals",value:74},
{axis:"Keeper Score",value:0.78},
],[//Atalanta
{axis:"Shots",value:475},
{axis:"Shots on target",value:254},
{axis:"Corners",value:242},
{axis:"Goals",value:77},
{axis:"Keeper Score",value:0.72},
],[//Inter
{axis:"Shots",value:459},
{axis:"Shots on target",value:238},
{axis:"Corners",value:302},
{axis:"Goals",value:57},
{axis:"Keeper Score",value:0.79},
],[//Milan
{axis:"Shots",value:423},
{axis:"Shots on target",value:231},
{axis:"Corners",value:230},
{axis:"Goals",value:55},
{axis:"Keeper Score",value:0.79},
],[//Roma
{axis:"Shots",value:459},
{axis:"Shots on target",value:257},
{axis:"Corners",value:227},
{axis:"Goals",value:66},
{axis:"Keeper Score",value:0.75},
],
];
Insert cell
data = {
let index1 = team[dataSelect1];
let index2 = team[dataSelect2];
return [datagroup[index1], datagroup[index2]];
}

Insert cell
data_teams = {
let index1 = team[dataSelect1];
let index2 = team[dataSelect2];
return [dataSelect1, dataSelect2];
}

Insert cell
color = {
let index1 = team[dataSelect1];
let index2 = team[dataSelect2];
return d3.scaleOrdinal().range([colors[index1], colors[index2]]);
}
Insert cell
team = ({"Juventus":0, "Napoli":1, "Atalanta":2, "Inter":3, "Milan":4, "Roma":5})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md`# Credits

- Thanks to [Ben Welsh](https://observablehq.com/@palewire) for the great insipration.
- Thanks to the amazing [Nadieh Bremer](https://observablehq.com/@nbremer) for creating the d3 radar chart.
`

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more