Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation for the tree mark and the treeLink, treeNode transforms #1351

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Mar 17, 2023

For #1343

We could possibly add more information, like how dx defaults to +6 if the anchor is left, etc.

@Fil Fil requested a review from mbostock March 17, 2023 11:15
textStroke?: MarkOptions["stroke"];
}

/**
* Transforms a tabular dataset into a hierarchy according to the given **path** input channel, which is typically a slash-separated string; then executes a tree layout algorithm to compute **x** and **y** output channels; these channels can then be fed to other marks to construct a node-link diagram.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs wrapping. (I will fix.)

treeSort?: CompareFunction | {node: (node: any) => any} | string | null;
}

/**
* Based on the **tree** options (**path**, **delimiter**, **treeAnchor**,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation should have one space, not two. (I will fix.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don’t think we need to repeat the tree options here. They should be clear from autocomplete (or jumping to the TreeTransformOptions interface).

@@ -6,10 +6,32 @@ import type {TextOptions} from "./text.js";

// TODO tree channels, e.g., "node:name" | "node:path" | "node:internal"?
export interface TreeOptions extends DotOptions, LinkOptions, TextOptions, TreeTransformOptions {
/**
* Should the node be represented by a dot. Defaults to true unless a **marker** is specified.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can’t really explain why, but I think grammatically this should read as “whether to represent the node with a dot” instead of “should the node be represented by a dot”. “Should” can imply correctness or appropriateness, but we’re not really making a judgment about what is correct or appropriate here, just honoring the user’s intention. (I will fix.)

* * **treeSort** - a node comparator, or null to preserve input order
* * **treeSeparation** - a node separation function, or null for uniform separation
*
*/
export function tree(data?: Data, options?: TreeOptions): CompoundMark;

export function cluster(data?: Data, options?: TreeOptions): CompoundMark;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation. (I have fixed.)

delimiter?: string;
/**
* If the **treeAnchor** is *left*, the root of the tree will be aligned with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options could use a summary sentence prior to diving into the possible ways in which the options could be specified. For example:

  • treeAnchor - how to orient the tree
  • treeLayout - how to position nodes in the tree
  • treeSeparation - how much space to reserve between adjacent nodes
  • treeSort - how to order nodes prior to computing the layout

etc.

@mbostock mbostock merged commit 2ac08e2 into main Mar 20, 2023
@mbostock mbostock deleted the fil/ts-tree branch March 20, 2023 17:22
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
…observablehq#1351)

* documentation for the tree mark and the treeLink, treeNode transforms

* tweaks

* tweaks

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants