npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-lineage

v2.0.0

Published

D3.js lineage chart to display a tree of provenance

Downloads

4

Readme

D3 Lineage - 1.0.11

D3.js lineage chart to display a tree of provenance
This is based on the Pedigree chart by Mike Bostock: https://bl.ocks.org/mbostock/2966094

The tree is drawn horizontally from right to left starting at the root node. Height and Width of the renderTo element are automatically updated to fit the nodes. This may look better wrapped in an element with style overflow:auto.

This chart depends on d3.js (v3), jQuery and font-awesome for a spinner icon.

Usage

Create a new chart and supply a css selector or jquery object as renderTo

  var chart = d3.lineageChart({
    renderTo: '#chart'
  });

Supply a URL that will return JSON formatted data

  chart.load(url);

For bootstrap tabs, redraw the chart when the tab is activated

  $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    chart.redraw();
  });

Data Format

This graph expects a nested node structure in json format. Each node has the following attributes:

  • type: Top Text for Node
  • name: node link text
  • link: node link url,
  • color: the color used to render edge between nodes
  • child: name of child node or nil,
  • edges: array of edge(s) between child and node
    • each edge is an object with name and link for the edge.
    • edge names are displayed below the node
  • parents: array with one node for each parent.

For example:

{
  "type": "Experiment",
  "link": "/experiment/designs/13182",
  "name": "Test experiment",
  "child": null,
  "edges": null,
  "parents": [
    {
      "type": "Pretreated Feedstock",
      "color": "teal",
      "link": "/pretreatment/batches/10898",
      "name": "Corn Stover 2012 AFEX (36H56) Batch 906",
      "child": "Nick's Test experiment",
      "edges": [
        {
          "name": "FSMSU000000000957",
          "link": "/pretreatment/items/14798"
        }
      ],
      "parents": [

      ]
    },
    {
      "type": "Hydrolysate",
      "color": "skyblue",
      "link": "/hydrolysate/biomass_batches/10095",
      "name": "MiSynBio 7% Glucan Hydrolysate SG UW12 AFEX Batch 837",
      "child": "Nick's Test experiment",
      "edges": [
        {
          "name": "FHUWM000000000837",
          "link": "/hydrolysate/items/16181"
        }
      ],
      "parents": [
        {
          "type": "Pretreated Feedstock",
          "color": "teal",
          "link": "/pretreatment/batches/10248",
          "name": "Switchgrass 2012 AFEX 822-91",
          "child": "MiSynBio 7% Glucan Hydrolysate SG UW12 AFEX Batch 837",
          "edges": [
            {
              "name": "FSMSU000000000667",
              "link": "/pretreatment/items/15352"
            }
          ],
          "parents": [
            {
              "type": "Untreated Feedstock",
              "link": "/feedstock/batches/10050",
              "color": "green",
              "name": "GLBRC Switchgrass UW 2012",
              "child": "Switchgrass 2012 AFEX 822-91",
              "edges": [
                {
                  "name": "FSUWM000000022633",
                  "link": "/feedstock/items/12666"
                }
              ],
              "parents": [

              ]
            }
          ]
        }
      ]
    }
  ]
}