Public
Edited
May 7, 2024
1 fork
1 star
Insert cell
Insert cell
Insert cell
mutable log = ""
Insert cell
putText = (evt,d) => {
d3.select(svg2).select("#person").text(d.Name + " - " + Math.round(d["DOTS MEN"]));
}
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("cy", 439)
.attr("r", 5)
.style("fill", "#F20505")
.attr("cy", d => scaleDOTS(d["DOTS MEN"]))
.attr("transform", d => "rotate(" + (-90 + Math.random()*180) + " 360,439)")
.on("mouseover", putText);
Insert cell
// Newdots = [(BenchPressKG+SquatKG+DeadliftKG)*(500/(-307.75076+(24.0900756*WeightKG)+(-0.1918759221*(WeightKG^2))+(0.0007391293*(WeightKG^3))+(-0.000001093*(WeightKG^4))))]
Insert cell
// DOTScircles2 = d3.select(svg2).select("#DOTScircles2")
// .append("circle")
// .attr("cx", 360)
// .attr("cy", 439)
// .attr("r", 5)
// .style("fill", "orange")
// .attr("transform", "rotate(0 360,439)")
// .transition().duration(1000)
// .attr("cy", scaleDOTS(Newdots))
// .transition().duration(1000)
// .attr("transform", "rotate(" + (-90 + Math.random()*180) + " 360,439)");
Insert cell
{
d3.select(svg2).select("#launch_button").on("click", () => addPerson2());
}
Insert cell
{
d3.select(svg2).select("#launch_button").on("click", () => Checker());
}
Insert cell
Checker = () => {

}
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*(bodyweightkg^2))+(0.0007391293*(bodyweightkg^3))+(-0.000001093*(bodyweightkg^4))))];
} else {
// Formula for females (you can replace this with the actual formula)
Calcdots = [(benchpresskg+squatkg+deadliftkg)*(500/(-57.96288+(13.6175032*bodyweightkg)+(-0.1126655495*(bodyweightkg^2))+(0.0005158568*(bodyweightkg^3))+(-0.0000010706*(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)")
.on("mouseover", putText);
}
Insert cell
// addPerson = () => {
// let user_name = d3.select(svg2).select("#user_name").property("value");
// let gender = d3.select(svg2).select("#gender").property("value");
// 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");

// mutable log = user_name;
// if (gender == "male") {
// let Newdots = [(benchpress+squat+deadlift)*(500/(-307.75076+(24.0900756*bodyweight)+(-0.1918759221*(bodyweight^2))+(0.0007391293*(bodyweight^3))+(-0.000001093*(bodyweight^4))))];
// } else {
// let Newdots = [(benchpress+squat+deadlift)*(500/(-57.96288+(13.6175032*bodyweight)+(-0.1126655495*(bodyweight^2))+(0.0005158568*(bodyweight^3))+(-0.0000010706*(bodyweight^4))))];
// }
// //mutable log = Newdots;
// d3.select(svg2).select("#DOTScircles2")
// .append("circle")
// .attr("cx", 360)
// .attr("cy", 439)
// .attr("r", 5)
// .style("fill", "Red")
// .attr("transform", "rotate(0 360,439)")
// .transition().duration(1000)
// .attr("cy", scaleDOTS(Newdots))
// .transition().duration(1000)
// .attr("transform", "rotate(" + (-90 + Math.random()*180) + " 360,439)");
// }
Insert cell
// Checkbox = d3.select(svg2).select("#Checkbox")
// .append("input")
// // viewof checkboxed = Inputs.checkbox(["Male", "Female"])
// .attr("type", "checkbox")
// .attr("value", "male", "female")
Insert cell
// DOTS=("Bench Press KG"+"Squat KG"+"Squat KG")*(500/(-307.75076+(24.0900756*"Weight KG")+(-0.1918759221*("Weight KG"^2))+(0.0007391293*("Weight KG"^3))+(-0.000001093*("Weight KG"^4))))
// ^^ MENS DOTS FORMULA
// DOTS=("Bench Press KG"+"Squat KG"+"Squat KG")*(500/(-57.96288+(13.6175032*"Weight KG")+(-0.1126655495*("Weight KG"^2))+(0.0005158568*("Weight KG"^3))+(-0.0000010706*("Weight KG"^4))))
// ^^ WOMENS DOTS FORMULA
// viewof checkboxed = Inputs.checkbox(["Male", "Female"])
// <foreignObject x = "320"
// y="500" width = "100"
// height ="40">
// <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
// <label for="vehicle1" fontcolor = "white"> Male</label><br>

Insert cell
data = FileAttachment("FAMOUS LIFTERS@4.csv").csv()
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

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