This message was deleted.
# help
s
This message was deleted.
c
OK, I have simplified the example at https://observablehq.com/d/8cdf5c4006b221da#cell-2252 (bottom of notebook). Is it possible to merge (1) and (2) below? Both manipulate the tree's node colors for each data point. Is this even possible? (1) Here nodeFill uses a d3 scale to determine what color the node is filled.
Copy code
Tree(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...
Copy code
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)
Copy code
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#Tree
So it does seem possible to do something like this
Copy code
nodeFill: (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"