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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@markvl/react-sankey

v0.0.11

Published

React sankey diagramm

Downloads

11

Readme

react-sankey

Sankey diagramm.

screenshot

See more examples in storybook npm run storybook - http://localhost:9001/ .

TODO

  • Add lint

Installation

npm install react-sankey

Usage

import ReactSankey from 'react-sankey';
    
const createNode = (title, value, id) => ({ title, value, id });
const createLink = (sourceId, targetId) => ({ sourceId, targetId });
    
const nodes = {
  '0':  createNode('Brazil', 5091520, 0),
  '1':  createNode('Portugal', 3967612, 1),
  '2':  createNode('Spain', 3948389, 2),
  '3':  createNode('England', 1974194, 3),
  '4':  createNode('France', 1202, 4),
  '5':  createNode('Canada', 1974184, 5),
  '6':  createNode('Conversion', 348, 6),
  '7':  createNode('Mexico', 3936731, 7),
  '8':  createNode('USA', 1983806, 8),
  '9':  createNode('Angola', 661228, 9),
  '10': createNode('Senegal', 199236, 10),
  '11': createNode('Conversion', 348, 11),
  '12': createNode('Morocco', 1983082, 12),
  '13': createNode('South Africa', 1290205, 13),
  '14': createNode('Italy', 348123, 14),
  '15': createNode('Conversion', 123, 15),
  '16': createNode('Mali', 1201, 16),
  '17': createNode('Conversion', 1302, 17),
  '18': createNode('Conversion', 1403, 18),
  '19': createNode('Conversion', 1504, 19),
  '20': createNode('Conversion', 1605, 20),
};
    
const links = [
  createLink(0, 1),
  createLink(1, 2),
  createLink(1, 7),
  createLink(1, 8),
  createLink(2, 3),
  createLink(2, 5),
  createLink(2, 16),
  createLink(3, 4),
  createLink(3, 17),
  createLink(3, 18),
  createLink(3, 19),
  createLink(3, 20),
  createLink(5, 6),
  createLink(7, 12),
  createLink(8, 9),
  createLink(8, 10),
  createLink(9, 11),
  createLink(12, 13),
  createLink(12, 14),
  createLink(13, 15)
];
    
class App extends React.Component {
    
    render() {
        <ReactSankey
          rootID={0}
          nodes={nodes}
          links={links}
          hasArrows
        />
    }
    
}

Props/Options

  • nodes - object. Example:

    {
      0: {
        title: 'Node 1',
        value: 15,
        id: '0'
      },
      1: {
        title: 'Node 2',
        value: 5,
        id: '1'
      },
      2: {
        title: 'Node 3',
        value: 1,
        id: '2'
      }
    }
        
  • links - array. Describes links between nodes. Example:

    [
      { sourceId: 0, targetId: 1 },
      { sourceId: 1, targetId: 2 }
    ]
        
  • rootID - number | string. Id of root node of chart

  • hasArrows - boolean. Enable/disable arrows

  • arrowClass - string. Adds custom class for tag path of arrows

  • linkClass - string. Adds custom class for path between nodes

  • chartConfig - object. To configure chart margins, paddings, node sizes. Default value:

    const chartConfig = {
      padding: { top: 10, right: 0, bottom: 10, left: 0 },
      node: {
        width: 150,
        maxHeight: 150,
        minHeight: 55,
        rectMinHeight: 5,
        paddingBottom: 40
      },
      link: {
        width: 100
      }
    }
  • customNode - function. Returns custom component for node and has two arguments - chartConfig, node. Example:

    (chartConfig, node) => {
      return (
        <g key={node.id} transform={`translate(${node.x},${node.y})`}>
          <rect 
            height={node.height} 
            width={chartConfig.node.width} 
            style={{ stroke: '#ff5252', fill: 'url(#custom-linear-gradient)', strokeWidth: '1px' }} 
          />
          <text 
            x={chartConfig.node.width / 2} 
            y={node.height / 2} 
            style={{ fontSize: '20px', fill: '#b57272', textAnchor: 'middle', alignmentBaseline: 'central' }}
          >
            {`${node.title}`}
          </text>
        </g>
      )
    }
        

Contributing