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

ng-apex-sankey

v0.1.2

Published

Angular library for creating customizable Sankey diagrams using ApexSankey.js

Downloads

33

Readme

Table of contents

Getting Started

ng-apex-sankey is an Angular library for creating Sankey diagrams with full customization options.

Latest Update

  • 2024.11.27: Version 0.1.2 release with dynamic data updates.
  • 2024.11.26: Initial release

Installation

Install the library via npm:

npm install ng-apex-sankey --save
npm install apexsankey --save

Usage

Standalone

Import SankeyChartComponent in your Angular component:

import { Component } from '@angular/core';
import { SankeyChartComponent, SankeyData, SankeyOptions } from 'ng-apex-sankey';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [SankeyChartComponent],
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public sankeyData: SankeyData = {
    nodes: [
      { id: 'Homepage', title: 'Homepage' },
      { id: 'ProductPage', title: 'Product Page' },
      { id: 'Cart', title: 'Cart' },
      { id: 'Checkout', title: 'Checkout' },
      { id: 'Exit', title: 'Exit' }
    ],
    edges: [
      { source: 'Homepage', target: 'ProductPage', value: 300 },
      { source: 'Homepage', target: 'Exit', value: 100 },
      { source: 'ProductPage', target: 'Cart', value: 200 },
      { source: 'ProductPage', target: 'Exit', value: 100 },
      { source: 'Cart', target: 'Checkout', value: 150 },
      { source: 'Cart', target: 'Exit', value: 50 },
      { source: 'Checkout', target: 'Exit', value: 150 }
    ]
  };

  public sankeyOptions: SankeyOptions = {
    graphOptions: {
      width: 800,
      height: 600,
      nodeWidth: 20,
      edgeOpacity: 0.5,
      enableTooltip: true,
    }
  };
}

API

The SankeyChartComponent accepts two main inputs: SankeyData for nodes and edges, and SankeyOptions for customization.

SankeyData Configuration

Nodes

  • id: Unique identifier for the node.
  • title: Title of the node, displayed in the diagram.

Edges

  • source: ID of the source node.
  • target: ID of the target node.
  • value: Value of the flow between nodes.
  • type (optional): Type of the link, useful for categorizing flows.

Options

  • order: (optional) A list of layers defining the order of nodes. It's a list of bands, each containing node IDs. Example:
    json

    {
      "order": [
        [["a", "b"]],
        [["c"]]
      ]
    }
  • alignLinkTypes: (optional) Boolean indicating whether to align link types across nodes. Default: false.

SankeyOptions Configuration

GraphOptions

  • width: (optional) Width of the graph container.
  • height: (optional) Height of the graph container.
  • canvasStyle: (optional) CSS styles for the canvas container.
  • spacing: (optional) Spacing from the top and left of the graph container.
  • nodeWidth: (optional) Width of the Sankey nodes.
  • nodeBorderWidth: (optional) Border width of the nodes.
  • nodeBorderColor: (optional) Border color of the nodes.
  • onNodeClick: (optional) Callback function executed when a node is clicked.
  • edgeOpacity: (optional) Opacity of the edges.
  • edgeGradientFill: (optional) Boolean to enable gradient fill on edges.
  • enableTooltip: (optional) Enables tooltip on hover over edges.
  • tooltipId: (optional) HTML element ID for the tooltip.
  • tooltipBorderColor: (optional) Border color of the tooltip.
  • tooltipBGColor: (optional) Background color of the tooltip.
  • tooltipTemplate: (optional) Function to customize the tooltip template. Accepts an object { source, target, value }.
  • fontSize: (optional) Font size for node labels.
  • fontFamily: (optional) Font family for node labels.
  • fontWeight: (optional) Font weight for node labels.
  • fontColor: (optional) Font color for node labels.

These options allow you to fully customize the Sankey diagram to fit your specific needs, providing detailed control over every aspect of the chart.

Demo

You can clone this repo and run the demo application to see the library in action:

npm install
ng serve 

The demo is available at: http://localhost:4200