-
Notifications
You must be signed in to change notification settings - Fork 187
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
A few suggestions for the tree layout #843
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
29358cc
tree
mbostock 7b61e3e
treeSort
mbostock 6efd442
treeSeparation
mbostock cc8c6d8
treeAnchor
mbostock d54ed06
update README
mbostock 3eb0843
treeLayout, cluster
mbostock 21aad85
Update README
mbostock 248eb28
flareCluster, flareIndent
mbostock 14204b5
tree marker; optional dot; sort links
mbostock 6cdb381
Update README
mbostock c04669c
transform composition
mbostock 31339a5
Update README
mbostock 28e4f83
fix marker default
mbostock f76ae77
fix defaults
mbostock e5bdfa9
Update README
mbostock 69f4ff2
facets, imputed nodes
mbostock f4401ef
named treeSort; document node columns
mbostock 106fd51
default title
mbostock 67e93d9
simpler indent
mbostock fbef2a5
ignore undefined
Fil 0918d3d
accept arrays
Fil 5861b64
default path: identity
Fil c59aec2
default options for shorthand Plot.tree().plot()
Fil e74e22a
example
Fil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {cluster as Cluster} from "d3"; | ||
import {isNoneish} from "../options.js"; | ||
import {marks} from "../plot.js"; | ||
import {maybeTreeAnchor, treeLink, treeNode} from "../transforms/tree.js"; | ||
import {dot} from "./dot.js"; | ||
import {link} from "./link.js"; | ||
import {text} from "./text.js"; | ||
|
||
export function tree(data, { | ||
fill, | ||
stroke, | ||
strokeWidth, | ||
strokeOpacity, | ||
strokeLinejoin, | ||
strokeLinecap, | ||
strokeMiterlimit, | ||
strokeDasharray, | ||
strokeDashoffset, | ||
marker, | ||
markerStart = marker, | ||
markerEnd = marker, | ||
dot: dotDot = isNoneish(markerStart) && isNoneish(markerEnd), | ||
text: textText = "node:name", | ||
textStroke = "white", | ||
title = "node:path", | ||
dx, | ||
dy, | ||
...options | ||
} = {}) { | ||
if (dx === undefined) dx = maybeTreeAnchor(options.treeAnchor).dx; | ||
const m = marks( | ||
link(data, treeLink({markerStart, markerEnd, stroke: stroke !== undefined ? stroke : fill === undefined ? "node:internal" : fill, strokeWidth, strokeOpacity, strokeLinejoin, strokeLinecap, strokeMiterlimit, strokeDasharray, strokeDashoffset, ...options})), | ||
dotDot ? dot(data, treeNode({fill: fill === undefined ? "node:internal" : fill, title, ...options})) : null, | ||
textText != null ? text(data, treeNode({text: textText, fill: fill === undefined ? "currentColor" : fill, stroke: textStroke, dx, dy, title, ...options})) : null | ||
); | ||
|
||
// default options for shorthand tree().plot() | ||
const plot = m.plot; | ||
// {insetLeft: 10, insetTop: 20, insetBottom: 20, insetRight: 120, x: {axis: null}, y: {axis: null}} | ||
m.plot = function({x = {axis: null}, y = {axis: null}, inset = undefined, insetLeft = inset != null ? inset : 10, insetTop = 20, insetBottom = 20, insetRight = 120, ...options} = {}) { | ||
return plot.call(this, {x, y, insetLeft, insetRight, insetTop, insetBottom, ...options}); | ||
}; | ||
return m; | ||
} | ||
|
||
export function cluster(data, options) { | ||
return tree(data, {...options, treeLayout: Cluster}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, too, but I don’t think the mark.plot shorthand should have different defaults from Plot.plot. If we want these hints we should figure out how to do them as channel hints.