Plot.plot({
projection: { type: "mercator", domain: caCounties },
r: {
legend: true
},
color: {
legend: true,
range: (domainColors) => {
console.log(domainColors);
const colorValues = ["blue", "orange", "red"];
const colorFiltered = [];
domainColors.forEach((c, i) => {
colorFiltered.push(
hazardRadio2 == "all" || hazardRadio2 == c
? colorValues[i]
: "lightgrey"
);
});
return colorFiltered;
},
domain: ["Low", "Significant", "High"]
},
marks: [
Plot.geo(caCounties, {
title: (d) => `${d.properties.name}`,
tip: true,
stroke: "lightgrey"
}),
Plot.dot(caDams, {
r: "SurfaceAreaAcres",
opacity: (d) => {
return d.YearCompleted >= completedInterval[0] &&
d.YearCompleted <= completedInterval[1]
? 0.8
: 0;
},
stroke: "HazardPotentialClassification",
fillOpacity: 0.2,
x: "Longitude",
y: "Latitude",
tip: {
format: {
StorageAcreFeet: true,
SurfaceAreaAcres: true,
DrainageAreaSqMiles: true,
HazardPotentialClassification: true,
YearCompleted: true,
name: true,
stroke: false,
x: false,
y: false,
r: false
}
},
channels: {
name: {
value: "DamName",
label: "Name"
},
storage: {
value: (d) => `${d3.format(",d")(d.StorageAcreFeet)} acre feet`,
label: "Storage"
},
surface: {
value: (d) => `${d3.format(",d")(d.SurfaceAreaAcres)} acres`,
label: "Surface"
},
drainage: {
value: (d) => `${d3.format(",d")(d.DrainageAreaSqMiles)} sq miles`,
label: "Drainage"
},
hazard: {
value: "HazardPotentialClassification",
label: "Hazard potential"
},
completed: {
value: (d) => d3.format("d")(d.YearCompleted),
label: "Completed"
}
}
})
]
})