Code Monkey home page Code Monkey logo

d3-hiervis's Introduction

๐ŸŒต d3-hiervis - Hierarchical visualization with D3

"Many datasets are intrinsically hierarchical. Consider geographic entities, such as census blocks, census tracts, counties and states; the command structure of businesses and governments; file systems and software packages. And even non-hierarchical data may be arranged empirically into a hierarchy, as with k-means clustering or phylogenetic trees." d3-hierarchy README

This module is based on d3 hierarchy and makes it easier to use and switch between several popular techniques for visualizing hierarchical data, including sunburst, sankey and partition.

ezgif-5-4e1ea53a07

Demo at https://bl.ocks.org/fbreitwieser/31e4be931541c74732dd6807ccb98daf

Usage

<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://rawgit.com/fbreitwieser/d3-hiervis/master/src/hiervis.js"></script>
<script src="https://rawgit.com/fbreitwieser/d3-hiervis/master/src/TreeColors.js"></script>
<svg width="100%" height="400"> </svg>
<script>
d3.csv("https://raw.githubusercontent.com/fbreitwieser/d3-hiervis/master/data/d3.csv").then(function(data) {
    chart = hiervis(d3.select("svg"), data, {nameField: "path", pathSep: "/", valueField: "size", stat: "sum"});
    chart.draw("sankey")
  });
</script>

Installing

If you use NPM, npm install d3-hiervis. Otherwise, download the latest release.

API Reference

TODO

Options

Data import:

  • default: data is already in hierarchical form, i.e. data is an object representing the root node
  • if pathSep is specified: data is tabular, with nameField defining a path, delimited by pathField
  • else if parentFiled is specified: data is tabular, with parentField defining the parent of nameField

Partition and Icicle (vertical partition)

Based on Mike Bostock's Zoomable Icicle

Sunburst

Based on Vasco Asturiano's Zoomable Sunburst with Labels.

Sankey

based on timelyportfolio's interactive parttree.

# hiervis()

Planned features (contributions are highly welcome!)

  • Add a dropdown menu in the SVG to change visualizations
  • When changing visualizations, transform rather than replace the nodes

d3-hiervis's People

Contributors

fbreitwieser avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.