Public
Edited
May 7, 2024
1 star
Insert cell
Insert cell
Insert cell
mutable log = ""
Insert cell
putText = (evt,d) => {
if (d.Gender === "M") {
return d3.select(svg2).select("#person").text(d.Name + " - " + Math.round(d["DOTS MEN"]));;
} else {
return d3.select(svg2).select("#person").text(d.Name + " - " + Math.round(d["DOTS WOMEN"]));;
}
}
Insert cell
scaleDOTS = d3.scaleLinear().domain([0,1000]).range([439,79])
Insert cell
DOTScircles = d3.select(svg2).select("#DOTScircles").selectAll("circle")
.data(data)
.join("circle")
.attr("cx", 360)
.attr("r", 5)
.style("fill", "#F20505")
.attr("cy", d => {
if (d.Gender === "M") {
return scaleDOTS(d["DOTS MEN"]);
} else {
return scaleDOTS(d["DOTS WOMEN"]);
}
})
.attr("transform", d => "rotate(" + (-90 + Math.random() * 180) + " 360,439)")
.on("mouseover", putText);
Insert cell
{
d3.select(svg2).select("#launch_button").on("click", () => addPerson2());
}
Insert cell
addPerson2 = () => {
let bodyweight = d3.select(svg2).select("#bodyweight").property("value");
let benchpress = d3.select(svg2).select("#benchpress").property("value");
let squat = d3.select(svg2).select("#squat").property("value");
let deadlift = d3.select(svg2).select("#deadlift").property("value");
let selectedGender = document.querySelector('input[name="gender"]:checked').value;
let bodyweightkg = bodyweight/2.2046
let benchpresskg = benchpress/2.2046
let squatkg = squat/2.2046
let deadliftkg = deadlift/2.2046

let Calcdots;

if (selectedGender === "male") {
// Formula for males
Calcdots = (benchpresskg + squatkg + deadliftkg) * (500 / (-307.75076 + 24.0900756 * bodyweightkg - 0.1918759221 * Math.pow(bodyweightkg, 2) + 0.0007391293 * Math.pow(bodyweightkg, 3) - 0.000001093 * Math.pow(bodyweightkg, 4)));
} else {
// Formula for females
Calcdots = (benchpresskg + squatkg + deadliftkg) * (500 / (-57.96288 + 13.6175032 * bodyweightkg - 0.1126655495 * Math.pow(bodyweightkg, 2) + 0.0005158568 * Math.pow(bodyweightkg, 3) - 0.0000010706 * Math.pow(bodyweightkg, 4)));;
}

// mutable log = selectedGender;
mutable log = Calcdots;
d3.select(svg2).select("#DOTScircles2")
.append("circle")
.attr("cx", 360)
.attr("cy", 439)
.attr("r", 5)
.style("fill", "#50BF61")
.attr("transform", "rotate(0 360,439)")
.transition().duration(1000)
.attr("cy", scaleDOTS(Calcdots))
.transition().duration(1000)
.attr("transform", "rotate(" + (-90 + Math.random()*180) + " 360,439)");
}
Insert cell
data = FileAttachment("FAMOUS LIFTERS.csv").csv()
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