Public
Edited
May 7, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
arcAreasLayer = d3.select(svgContainer).select("#layer1");
Insert cell
UTCIArcs = {
let arcs = arcAreasLayer.select("#utci").selectAll(".UTCIArc")
.data(orlando4)
.join("path")
.classed("UTCIArc",true)
.attr("d", d => arcPath(scaleUTCI(calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd)), calcstartangle(d), calcendangle(d)));
return arcs;
}
Insert cell
tempLines = arcAreasLayer.select("#components").selectAll(".tempLines")
.data(orlando4)
.join("line")
.attr("x1", d => polarXY(scaleRadius(innerRadiusTemp(d)), (d.month-1)*30 + 6).x)
.attr("y1", d => polarXY(scaleRadius(innerRadiusTemp(d)), (d.month-1)*30 + 6).y)
.attr("x2", d => polarXY(scaleRadius(outerRadiusTemp(d)), (d.month-1)*30 + 6).x)
.attr("y2", d => polarXY(scaleRadius(outerRadiusTemp(d)),(d.month-1)*30 + 6).y)
.classed("tempLines",true);
Insert cell
innerRadiusTemp = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) - (d.TairAd/2));
Insert cell
outerRadiusTemp = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) + (d.TairAd/2));
Insert cell
MRTLines = arcAreasLayer.select("#components").selectAll(".MRTLines")
.data(orlando4)
.join("line")
.attr("x1", d => polarXY(scaleRadius(innerRadiusMRT(d)), (d.month-1)*30 + 12).x)
.attr("y1", d => polarXY(scaleRadius(innerRadiusMRT(d)), (d.month-1)*30 + 12).y)
.attr("x2", d => polarXY(scaleRadius(outerRadiusMRT(d)), (d.month-1)*30 + 12).x)
.attr("y2", d => polarXY(scaleRadius(outerRadiusMRT(d)), (d.month-1)*30 + 12).y)
.classed("MRTLines",true);
Insert cell
innerRadiusMRT = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) - (d.MRTAd/2));
Insert cell
outerRadiusMRT = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) + (d.MRTAd/2));
Insert cell
VaLines = arcAreasLayer.select("#components").selectAll(".VaLines")
.data(orlando4)
.join("line")
.attr("x1", d => polarXY(scaleRadius(innerRadiusVa(d)), (d.month-1)*30 + 18).x)
.attr("y1", d => polarXY(scaleRadius(innerRadiusVa(d)), (d.month-1)*30 + 18).y)
.attr("x2", d => polarXY(scaleRadius(outerRadiusVa(d)), (d.month-1)*30 + 18).x)
.attr("y2", d => polarXY(scaleRadius(outerRadiusVa(d)), (d.month-1)*30 + 18).y)
.classed("VaLines",true);
Insert cell
innerRadiusVa = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) - (d.VaAd/2));
Insert cell
outerRadiusVa = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) + (d.VaAd/2));
Insert cell
RHLines = arcAreasLayer.select("#components").selectAll(".RHLines")
.data(orlando4)
.join("line")
.attr("x1", d => polarXY(scaleRadius(innerRadiusRH(d)), (d.month-1)*30 + 24).x)
.attr("y1", d => polarXY(scaleRadius(innerRadiusRH(d)), (d.month-1)*30 + 24).y)
.attr("x2", d => polarXY(scaleRadius(outerRadiusRH(d)), (d.month-1)*30 + 24).x)
.attr("y2", d => polarXY(scaleRadius(outerRadiusRH(d)), (d.month-1)*30 + 24).y)
.classed("RHLines",true);
Insert cell
innerRadiusRH = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) - (d.RHAd/2));
Insert cell
outerRadiusRH = (d) => (calcUTCI(d.TairAd, d.MRTAd, d.VaAd, d.RHAd) + (d.RHAd/2));
Insert cell
calcstartangle = d=> (d.month-1) * 30
Insert cell
calcendangle = d=> (d.month) * 30
Insert cell
scaleUTCI = d3.scaleLinear().domain([-50,50]).range([78,250])
Insert cell
scaleRadius = d3.scaleLinear().domain([-50,50]).range([78,250])
Insert cell
Insert cell
//scaleUTCI = d3.scaleLinear().domain([-50,50]).range([0,500])
Insert cell
lineslayer = d3.select(svgContainer).select("#layer1");
Insert cell
arcPoint = (radius,angle) => {return polarXY(radius,90-angle)} // example shows starting at 90deg going clockwise (90-angle)
Insert cell
arcPath = (inR,startAng,endAng) => {
let largeArcFlag = (startAngle,endAngle) => {if (endAngle - startAngle > 180) {return 1} else {return 0}} // largearc calc
let pathString =
"M " + arcPoint(inR,startAng).x + " " + arcPoint(inR,startAng).y + // move to start point
" A " + inR + " " + inR + // draw Arc with x and y radii
" 0" + // rotation of the whole thing, assuming 0
" " + largeArcFlag(startAng,endAng) + // calculate Large Arc Flag (> 180 deg)
" 1 " + // clockwise drawing for the arc (0 or 1)
arcPoint(inR,endAng).x + " " + arcPoint(inR,endAng).y // finish at the end point x,y
// close the polygon back to start (line to start)
return pathString;
}
Insert cell
function AdjustData(adjust){
orlando4.Tair = orlando4.Tair + adjust
}
Insert cell
Insert cell
Insert cell
polarXY = (magnitude,angle) => {
magnitude = Number(magnitude);
angle = Number(angle);
let x = magnitude * Math.cos(radiansFromDeg(angle));
let y = -magnitude * Math.sin(radiansFromDeg(angle)); // negative because 0 is at the top
return {"x":x, "y":y};
}
Insert cell
radiansFromDeg = (deg) => {
deg = Number(deg);
return deg * Math.PI / 180;
}
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