viewof lineChart = {
const HWlineChart = Plot.plot({
style: {
backgroundColor: "#000000",
color: "#e0f5ee",
fontSize: 20
},
marginTop: 50,
className: "hwclass",
marks: [
Plot.line(clickedSite, {
x: "date",
y: "sst",
stroke: colors.get("sst"),
curve: "step",
strokeWidth: 2
}),
Plot.line(clickedSite, {
x: "date",
y: "thresh",
stroke: colors.get("thresh"),
opacity: 0.7,
strokeWidth: 2
}),
Plot.line(clickedSite, {
x: "date",
y: "seas",
stroke: colors.get("seas"),
opacity: 0.7,
// curve: "step",
strokeWidth: 2
}),
Plot.areaY(clickedSite, {
x: "date",
y1: "thresh",
y2: "diff",
sort: "date",
curve: "step",
fill: colors.get("moderate")
}),
Plot.areaY(clickedSite, {
x: "date",
y1: "thresh",
y2: "diffStrong",
sort: "date",
curve: "step",
fill: colors.get("Strong")
}),
Plot.areaY(clickedSite, {
x: "date",
y1: "thresh",
y2: "diffExtreme",
sort: "date",
curve: "step",
fill: colors.get("Extreme")
}),
Plot.areaY(clickedSite, {
x: "date",
y1: "thresh",
y2: "diffSevere",
sort: "date",
curve: "step",
fill: colors.get("Severe")
}),
// rule at bottom of chart marking y=0;
Plot.ruleY([0]),
// vertical rule to mark date/time of event
Plot.ruleX([time1], {
stroke: "gray",
y1: 0,
y2: d3.max(clickedSite, (d) => d.sst)
}),
Plot.text(
[
{
x: dateForLabel,
y: yValueForLabel,
text: buoyClicked
}
],
{
x: "x",
y: "y",
text: "text",
fontSize: 24
}
)
],
color: {
domain: ["above", "below", "avg", "thresh"],
range: [
colors.get("above"),
colors.get("below"),
colors.get("actuals"),
colors.get("forecast")
]
// legend: true
},
y: {
label: "↑ (°C)"
},
marginLeft: 60,
width: 500,
height: 300
});
const SSTAlineChart = Plot.plot({
x: {
domain: [limitsDelayed[0], limitsDelayed[1]]
},
y: {
label: "↑ SST (°C)",
domain: [0, yMaxDomainToUse]
},
style: {
backgroundColor: "#000000",
color: "#e0f5ee",
// fontFamily: "system-ui",
fontSize: 20
// overflow: "visible"
},
height: 500,
marginTop: 50,
className: "hwclass",
// y: {
// nice: true
// },
// x: {
// nice: true
// },
marks: [
Plot.dot(clickedSite, {
x: "date",
y: "sst",
stroke: "ssta",
fill: "ssta"
}),
Plot.line(clickedSite, {
x: "date",
y: "sst",
stroke: "#ccc",
curve: "step",
strokeWidth: 0.5
}),
// vertical rule to mark date/time of event
Plot.ruleX([time1], {
stroke: "white",
y1: 0,
y2: d3.max(clickedSite, (d) => d.sst)
}),
Plot.text(
[
{
x: dateForLabel,
y: yValueForLabel,
text: buoyClicked
}
],
{
x: "x",
y: "y",
text: "text",
fontSize: 24
}
)
],
color: {
type: "diverging",
domain: [-4, 4],
pivot: 0,
reverse: true
// legend: true,
// label: "SSTA (°C) →"
},
width: 500,
height: 300
// marginBottom: 70,
// label: buoyClicked
// title: "some stie"
});
if (siteClicked !== null) {
return colorView === "Anomaly" ? SSTAlineChart : HWlineChart;
} else {
return md``;
}
}