Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

context

context: any

If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>
see

https://reactjs.org/docs/context.html

gInstanceRef

gInstanceRef: string = `rd3t-g-${uuidv4()}`

Readonly props

props: Readonly<TreeProps> & Readonly<{ children?: ReactNode }>

refs

refs: {}

Type declaration

  • [key: string]: ReactInstance

svgInstanceRef

svgInstanceRef: string = `rd3t-svg-${uuidv4()}`

Static Optional contextType

contextType: Context<any>

If set, this.context will be set at runtime to the current value of the given Context.

Usage:

type MyContext = number
const Ctx = React.createContext<MyContext>(0)

class Foo extends React.Component {
  static contextType = Ctx
  context!: React.ContextType<typeof Ctx>
  render () {
    return <>My context's value: {this.context}</>;
  }
}
see

https://reactjs.org/docs/context.html#classcontexttype

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<TreeProps>, nextContext: any): void

Optional UNSAFE_componentWillUpdate

  • UNSAFE_componentWillUpdate(nextProps: Readonly<TreeProps>, nextState: Readonly<TreeState>, nextContext: any): void

bindZoomListener

  • bindZoomListener - If props.zoomable, binds a listener for "zoom" events to the SVG and sets scaleExtent to min/max specified in props.scaleExtent.

    Parameters

    Returns void

centerNode

  • centerNode(hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>): void

collapseNeighborNodes

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

componentDidMount

  • componentDidMount(): void

componentDidUpdate

  • componentDidUpdate(prevProps: TreeProps): void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

  • componentWillReceiveProps(nextProps: Readonly<TreeProps>, nextContext: any): void

Optional componentWillUnmount

  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

Optional componentWillUpdate

  • componentWillUpdate(nextProps: Readonly<TreeProps>, nextState: Readonly<TreeState>, nextContext: any): void

findNodesAtDepth

  • Recursively walks the nested nodeSet until all nodes at depth have been found.

    Parameters

    • depth: number

      Target depth for which nodes should be returned

    • nodeSet: TreeNodeDatum[]

      Array of nested node objects

    • accumulator: TreeNodeDatum[]

      Accumulator for matches, passed between recursive calls

    Returns TreeNodeDatum[]

findNodesById

forceUpdate

  • forceUpdate(callback?: () => void): void
  • Parameters

    • Optional callback: () => void
        • (): void
        • Returns void

    Returns void

generateTree

  • Generates tree elements (nodes and links) by grabbing the rootNode from this.state.data[0]. Restricts tree depth to props.initialDepth if defined and if this is the initial render of the tree.

    Returns { links: HierarchyPointLink<TreeNodeDatum>[]; nodes: HierarchyPointNode<TreeNodeDatum>[] }

getNodeClassName

Optional getSnapshotBeforeUpdate

  • getSnapshotBeforeUpdate(prevProps: Readonly<TreeProps>, prevState: Readonly<TreeState>): any | null
  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns any | null

handleAddChildrenToNode

  • handleAddChildrenToNode(nodeId: string, childrenData: RawNodeDatum[]): void

handleNodeToggle

  • handleNodeToggle(nodeId: string): void
  • Finds the node matching nodeId and expands/collapses it, depending on the current state of its internal collapsed property. setState callback receives targetNode and handles props.onClick if defined.

    Parameters

    • nodeId: string

    Returns void

handleOnLinkClickCb

  • handleOnLinkClickCb(linkSource: HierarchyPointNode<TreeNodeDatum>, linkTarget: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void

handleOnLinkMouseOutCb

  • handleOnLinkMouseOutCb(linkSource: HierarchyPointNode<TreeNodeDatum>, linkTarget: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void

handleOnLinkMouseOverCb

  • handleOnLinkMouseOverCb(linkSource: HierarchyPointNode<TreeNodeDatum>, linkTarget: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void

handleOnNodeClickCb

  • handleOnNodeClickCb(hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void
  • Handles the user-defined onNodeClick function.

    Parameters

    • hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>
    • evt: SyntheticEvent<Element, Event>

    Returns void

handleOnNodeMouseOutCb

  • handleOnNodeMouseOutCb(hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void
  • Handles the user-defined onNodeMouseOut function.

    Parameters

    • hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>
    • evt: SyntheticEvent<Element, Event>

    Returns void

handleOnNodeMouseOverCb

  • handleOnNodeMouseOverCb(hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>, evt: SyntheticEvent<Element, Event>): void
  • Handles the user-defined onNodeMouseOver function.

    Parameters

    • hierarchyPointNode: HierarchyPointNode<TreeNodeDatum>
    • evt: SyntheticEvent<Element, Event>

    Returns void

render

  • render(): Element

setInitialTreeDepth

  • setInitialTreeDepth(nodeSet: HierarchyPointNode<TreeNodeDatum>[], initialDepth: number): void
  • Collapses all tree nodes with a depth larger than initialDepth.

    Parameters

    • nodeSet: HierarchyPointNode<TreeNodeDatum>[]

      Array of nodes generated by generateTree

    • initialDepth: number

      Maximum initial depth the tree should render

    Returns void

setState

Optional shouldComponentUpdate

  • shouldComponentUpdate(nextProps: Readonly<TreeProps>, nextState: Readonly<TreeState>, nextContext: any): boolean
  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Static assignInternalProperties

  • Assigns internal properties that are required for tree manipulation to each node in the data set and returns a new data array.

    static

    Parameters

    • data: RawNodeDatum[]
    • Default value currentDepth: number = 0

    Returns TreeNodeDatum[]

Static calculateD3Geometry

  • calculateD3Geometry(nextProps: TreeProps): { scale: any; translate: Point }
  • Set initial zoom and position. Also limit zoom level according to scaleExtent on initial display. This is necessary, because the first time we are setting it as an SVG property, instead of going through D3's scaling mechanism, which would have picked up both properties.

    static

    Parameters

    Returns { scale: any; translate: Point }

    • scale: any
    • translate: Point

Static collapseNode

  • Recursively sets the internal collapsed property of the passed TreeNodeDatum and its children to true.

    static

    Parameters

    Returns void

Static expandNode

Static getDerivedStateFromProps

Object literals

Private internalState

internalState: object

isTransitioning

isTransitioning: boolean = false

targetNode

targetNode: null = null

state

state: object

d3

d3: { scale: any; translate: Point } = Tree.calculateD3Geometry(this.props)

Type declaration

  • scale: any
  • translate: Point

data

data: TreeNodeDatum[] = Tree.assignInternalProperties(clone(this.props.data))

dataKey

dataKey: string = this.props.dataKey

dataRef

dataRef: RawNodeDatum | RawNodeDatum[] = this.props.data

isInitialRenderForDataset

isInitialRenderForDataset: true = true

isTransitioning

isTransitioning: false = false

Static defaultProps

defaultProps: object

branchNodeClassName

branchNodeClassName: string = ""

centeringTransitionDuration

centeringTransitionDuration: number = 800

collapsible

collapsible: true = true

dataKey

dataKey: undefined = undefined

depthFactor

depthFactor: undefined = undefined

dimensions

dimensions: undefined = undefined

draggable

draggable: true = true

enableLegacyTransitions

enableLegacyTransitions: false = false

hasInteractiveNodes

hasInteractiveNodes: false = false

initialDepth

initialDepth: undefined = undefined

leafNodeClassName

leafNodeClassName: string = ""

onLinkClick

onLinkClick: undefined = undefined

onLinkMouseOut

onLinkMouseOut: undefined = undefined

onLinkMouseOver

onLinkMouseOver: undefined = undefined

onNodeClick

onNodeClick: undefined = undefined

onNodeMouseOut

onNodeMouseOut: undefined = undefined

onNodeMouseOver

onNodeMouseOver: undefined = undefined

onUpdate

onUpdate: undefined = undefined

orientation

orientation: "horizontal" = "horizontal"

pathClassFunc

pathClassFunc: undefined = undefined

pathFunc

pathFunc: "diagonal" = "diagonal"

renderCustomNodeElement

renderCustomNodeElement: undefined = undefined

rootNodeClassName

rootNodeClassName: string = ""

shouldCollapseNeighborNodes

shouldCollapseNeighborNodes: false = false

svgClassName

svgClassName: string = ""

transitionDuration

transitionDuration: number = 500

zoom

zoom: number = 1

zoomable

zoomable: true = true

nodeSize

nodeSize: object

x

x: number = 140

y

y: number = 140

scaleExtent

scaleExtent: object

max

max: number = 1

min

min: number = 0.1

separation

separation: object

nonSiblings

nonSiblings: number = 2

siblings

siblings: number = 1

translate

translate: object

x

x: number = 0

y

y: number = 0

Generated using TypeDoc