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

sankeyjs

v1.2.2

Published

D3 Implementation for Sankey chart packaged with AngularJS v1 directive

Downloads

10

Readme

d3-sankey

D3 Implementation for Sankey chart packaged with AngularJS v1 directive

This Plugin is inspired from rCharts Examples with more features and more clean code.

picture alt picture alt

Options

  • chart: element selector, It's not needed in case of using Angularjs module.
  • width: chart width
  • height: chart height
  • margin: chart margins
  • nodeWidth: node width inside Sankey chart.
  • nodePadding: node padding inside Sankey chart.
  • dynamicLinkColor: set links background color dynamically according to link source.
  • staticLinkColor: set links background color statically, this value will not be used in case of using dynamicLinkColor options

JS Usage

<div id="sankeyChart">
    <canvas></canvas>
    <svg></svg>
</div>
var options = {
        chart: '#sankeyChart',
        width: 960,
        height: 500,
        nodeWidth: 15,
        nodePadding: 10,
        //DYNAMIC LINK COLOR WILL OVERWRITE STATIC COLOR IF EXISTS
        dynamicLinkColor: true,
        //staticLinkColor: 'rgb(230, 14, 14)',
        margin: {top: 1, right: 1, bottom: 6, left: 1}
    };
    var data = {
        nodes: [
            {'node': 0, 'name': 'Junior'},
            {'node': 1, 'name': 'Mid Senior'},
            {'node': 2, 'name': 'Senior'},
            {'node': 3, 'name': 'Tech Lead'},
            {'node': 4, 'name': 'CTO'},
            {'node': 5, 'name': 'COO'},
            {'node': 6, 'name': 'CEO'}
        ],
        links: [
            {'source': 0, 'target': 1, 'value': 1000},
            {'source': 0, 'target': 2, 'value': 200},
            {'source': 0, 'target': 5, 'value': 10},
            {'source': 1, 'target': 2, 'value': 500},
            {'source': 1, 'target': 5, 'value': 2},
            {'source': 2, 'target': 3, 'value': 200},
            {'source': 2, 'target': 5, 'value': 50},
            {'source': 3, 'target': 4, 'value': 100},
            {'source': 3, 'target': 5, 'value': 125},
            {'source': 4, 'target': 6, 'value': 100},
            {'source': 5, 'target': 6, 'value': 100}
        ]
    };

    let chart = new d3.sankeyChart(data, options);

AngularJS Usage

<ng-sankey id="sankeyChart" options="options" data="data"></ng-sankey>
    var app = angular.module('SankeyApp', ['ngSankey']);

    app.controller('MainController', ['$scope', function ($scope) {
        $scope.options = {
            width: 960,
            height: 500,
            nodeWidth: 15,
            nodePadding: 10,
            dynamicLinkColor: true,
            margin: {top: 1, right: 1, bottom: 6, left: 1}
        };
        $scope.data = {
            nodes: [
                {'node': 0, 'name': 'Junior'},
                {'node': 1, 'name': 'Mid Senior'},
                {'node': 2, 'name': 'Senior'},
                {'node': 3, 'name': 'Tech Lead'},
                {'node': 4, 'name': 'CTO'},
                {'node': 5, 'name': 'COO'},
                {'node': 6, 'name': 'CEO'}
            ],
            links: [
                {'source': 0, 'target': 1, 'value': 1000},
                {'source': 0, 'target': 2, 'value': 200},
                {'source': 0, 'target': 5, 'value': 10},
                {'source': 1, 'target': 2, 'value': 500},
                {'source': 1, 'target': 5, 'value': 2},
                {'source': 2, 'target': 3, 'value': 200},
                {'source': 2, 'target': 5, 'value': 50},
                {'source': 3, 'target': 4, 'value': 100},
                {'source': 3, 'target': 5, 'value': 125},
                {'source': 4, 'target': 6, 'value': 100},
                {'source': 5, 'target': 6, 'value': 100}
            ]
        };
    }]);

Installation

Bower

bower install sankeyjs

npm

npm install sankeyjs

MIT Licence

Copyright @2017

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.