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

geofluxus-circular-sankey

v2.0.9

Published

React d3 circular sankey component for data visualisations

Downloads

32

Readme

GeoFluxus Circular Sankey

How to use the CircularSankey component within your React (or other) projects

  • install the npm module:

npm i geofluxus-circular-sankey or yarn add geofluxus-circular-sankey

  • then in your React (or other) project:
import CircularSanky from 'geofluxus-circular-sankey'
  • Use the component:
const YourView = () => <CircularSankey data={yourCircularData} width={900} height={1000} />

Customise Circular Sankey

  • pass as props to the component:

| prop name | type | example | default | | ---------------- | ------ | -------------------------- | ------------------------- | | width | number | width={900} | 600 min | | height | number | height={700} | 600 min | | absolutePosition | object | absolutePosition={margins} | none | | data | object | data={yourCircularData} | (fall-back data provided) | | fontColor | string | fontColor={'#f9f9f9'} | black | | fontSize | number | fontSize={18} | 12 px | | unitString | string | unitString={'CO2 t'} | none |

Example Use of props for CircularSankey component:

const margins = {
    top: 50,
    left: 300,
    right: 50,
    bottom: 0
}

<CircularSankey
    data={yourCircularData}
    width={900}
    height={1000}
    absolutePosition={pageMargins}
    fontColor={'white'}
    fontSize={18}
    unitString={'CO2 (t)'}
/>

Your Circular Data Shape

  • This is very important: Circular Sankey diagram calculates unique node connections and links to them. Pass the object of your Nodes and Links with the value (represents weight/width):
// make sure to provide the names for nodes that are formatted -
// as they will appear on the legend and tooltip hover

const yourCircularData = {
  nodes: [
    { name: 'A' },
    { name: 'B' },
    { name: 'C' }
    ],
  links: [
    {
      source: 'A',
      target: 'B',
      value: 10
    },
    {
      source: 'B',
      target: 'C',
      value: 5
    },
    {
      source: 'B',
      target: 'A',
      value: 1
    },
    {
      source: 'C',
      target: 'A',
      value: 3
    },
  ]
}

See this link for how to translate React Component to Backbone.js class views

The Result

Should be a readable circular sankey with the ability to highlight key data nodes by clicking on the square nodes:

React instance / Hook called outside of fuction issue

currently the community is reporting potential issues with hooks being called outside of function or multiple react instances. In this case, add a resolver to your webpack.config.js :


module.exports = {
resolve: {
alias: {
react: path.resolve('./node_modules/react')
}
},
// other webpack configurations...
}