Skip to content

Easier tree label positioning? #1589

Closed
@Fil

Description

@Fil

In https://observablehq.com/@observablehq/plot-tree-tidy if you want to vary the orientation of node labels (so that leaves point to the right and parent nodes to the left, as in https://observablehq.com/@d3/tree), you can do:

Plot.plot({
  axis: null,
  margin: 10,
  marginLeft: 40,
  marginRight: 160,
  width: 928,
  height: 1800,
  marks: [
    Plot.tree(flare, {
      path: "name",
      delimiter: ".",
      dx: -6,
      textAnchor: "end",
      fontSize: { node: (d) => (d.children ? 10 : NaN) }
    }),
    Plot.text(flare, Plot.treeNode({
      path: "name",
      delimiter: ".",
      dx: 6,
      text: "node:name",
      fontSize: { node: (d) => (d.children ? NaN : 10) }
    }))
  ]
})

This could be easier if dx and textAnchor were channels (#1528, #909), or maybe we need a specific option to Plot.tree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions