Skip to main content
100%

D3 dndTree + Zoom + Pan + Misc Features

✓ Published0🌍 Public
TThanaporn-sk
Last edited Mar 10, 2017
Created on Mar 10, 2017

This interactive D3.js v3 visualization presents a hierarchical tree layout of the "flare" JSON dataset, enabling user-driven exploration of the data structure. The visualization supports drag-and-drop node repositioning, panning by dragging the background or near edges, and zooming via mouse-wheel or double-click. Nodes can be clicked to expand or collapse their children. The code uses `d3.layout.tree` for layout, `d3.behavior.zoom` for zoom interactions, and demonstrates custom event handling for pan and drag operations. The tree dynamically calculates horizontal and vertical dimensions to fit the viewport, and all interactions are rendered as SVG with animated transitions.

AI-generated description

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

Zooming is performed by either double clicking on an empty part of the SVG or by scrolling the mouse-wheel. To Zoom out hold shift when double-clicking.

Expanding and collapsing of nodes is achieved by clicking on the desired node.

The tree auto-calculates its sizes both horizontally and vertically so it can adapt between many nodes being present in the view to very few whilst making the view managable and pleasing on the eye.

For any help/queries, http://www.robschmuecker.com @robschmuecker or robert.schmuecker at gmail dot com

forked from <a href='http://bl.ocks.org/git-ashish/'>git-ashish</a>'s block: <a href='http://bl.ocks.org/git-ashish/99789bed329a96fa244c'>D3 dndTree + Zoom + Pan + Misc Features</a>

mit Licensed

Similar vizzes