Published
Edited
Feb 13, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{ // controller
if (conversion == 'C to F') {
viewof F['0'].labels[0].innerHTML = 'F 🔓'
viewof C['0'].labels[0].innerHTML = 'C'
viewof F['1'].max = Math.max(c_to_f(C), viewof F['1'].max);
viewof F['0'].min = Math.min(c_to_f(C), viewof F['0'].min); // lots of stuff which doens't fix bounds problem fully..
viewof F['0'].max = Math.max(c_to_f(C), viewof F['0'].max);
viewof F['0'].size = viewof F['0'].max - viewof F['0'].min;
viewof F['1'].min = Math.min(c_to_f(C), viewof F['1'].min);
viewof F['1'].max = Math.max(c_to_f(C), viewof F['1'].max);
//viewof F['1'].size = viewof F['1'].max - viewof F['1'].min;
viewof F.value = c_to_f(C);
viewof F.dispatchEvent(new CustomEvent("input"));

viewof C['0'].disabled = false;
viewof C['1'].disabled = false;
viewof F['0'].disabled = true;
viewof F['1'].disabled = true;
}
else {
viewof F['0'].labels[0].innerHTML = 'F'
viewof C['0'].labels[0].innerHTML = 'C 🔓'
viewof C.value = f_to_c(F);
viewof C['1'].min = Math.min(f_to_c(F), viewof C['1'].min);
viewof C['1'].max = Math.max(f_to_c(F), viewof C['1'].max);
viewof C.dispatchEvent(new CustomEvent("input"));

viewof F['0'].disabled = false;
viewof F['1'].disabled = false;
viewof C['0'].disabled = true;
viewof C['1'].disabled = true;
}
}
Insert cell
Insert cell
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