Slackbot
04/11/2023, 3:03 PMChristopher Rucinski
04/12/2023, 1:15 PMTree(find("XBB.1"), {
width: width,
label: (d) => d.data.lineage.pango,
nodeRadius: 8, // Only for display purposes
nodeFill: (d) => divergingScale(weeksSince(d.data.lineage.designation_date))
})
And here is the related code for the simplified diverging scale...
divergingScale = d3
.scaleDiverging()
.domain([1, 3, 72]) // weeks
.range(["#D52322", "lightgray", "lightgray"])
This will color the nodes red that have a designation_date that is at most 3 weeks old. Those nodes older will be colored light gray. See attachment (and 2nd to last tree in link)
(2) Here nodeFill uses a predicate (array.includes(...)
) to determine what color the node is filled; either black or light gray. See attachment (and last tree in link)
Tree(find("XBB.1"), {
width: width,
label: (d) => d.data.lineage.pango,
nodeRadius: 8, // Only for display purposes
nodeFill: (d) => available_nextclade_lineages.includes(d.data.lineage.pango) ? "black" : "lightgray"
})
Note: Tree
is located at https://observablehq.com/@ciscorucinski/hierarchical-tree#TreeChristopher Rucinski
04/13/2023, 1:14 PMnodeFill: (d) =>
available_nextclade_lineages.includes(d.data.lineage.pango)
? "black"
: divergingScale(weeksSince(d.data.lineage.designation_date))
Now that I know there is a possibility, I can experiment around. This has the predicate ultimately determining what will happen when there are "collisions"