0.8.0 • Published 10 years ago

quadtreetree v0.8.0

Weekly downloads
1
License
ISC
Repository
github
Last release
10 years ago

quadtreetree

This is a browser module that renders a D3 quadtree's nodes in a tree layout.

Requirements

It depends on D3 and Underscore or Lo-Dash.

Installation

npm install quadtreetree

Usage

HTML:

<svg id="quadtreetree" width="98%" height="75%">
  <g id="treeroot"></g>
</svg>

JavaScript:

var quadtreetree = createQuadtreetree({
  rootSelector: '#treeroot',
  vertical: true
});

// Call this whenever the quadtree is updated and you want to update
// quadtreetree's rendering of it.
quadtreetree.update(quadtree);

Events

quadtreetree dispatches a couple of events if you want to listen for them.

quadtreetree-nodeSelected

This event is dispatched when the user selects a node. The event's detail object will be the selected tree layout node (not the quadtree node). However, it will contain the quadtree node in a property called sourceNode. Example:

document.addEventListener('quadtreetree-nodeSelected', logSelectedNode);

function logSelectedNode(e) {
  console.log(e.detail.sourceNode);
}

quadtreetree-dotsEntered

This event is dispatched when new nodes are rendered as dots in the tree layout. The event's detail object will be a D3 selection of the newly added layout tree nodes.

Example

See example/index.html. There's a live version of it here.

License

MIT.

0.8.0

10 years ago

0.7.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago