New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nebula.js/sn-sankey-chart

Package Overview
Dependencies
Maintainers
14
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nebula.js/sn-sankey-chart

A flow diagram visually emphasizing major transfers or flows within defined system boundaries.

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8K
decreased by-3.52%
Maintainers
14
Weekly downloads
 
Created
Source

@nebula.js/sn-sankey-chart

The Sankey chart is a flow chart which visually emphasizes major transfers or flows within defined system boundaries. The width of the chart arrows is shown proportionally to the flow quantity.

  • A minimum of two dimensions and one measure is required. You can use up to five dimensions, but only one measure.
  • The dimensions do not need to be of equal size on each side of the diagram.
  • You can use the dimension values to set the color of the flows in the chart.
  • Link colors can be based on source or target anchor.

Requirements

Requires @nebula.js/stardust version 1.2.0 or later.

Installing

If you use npm: npm install @nebula.js/sn-sankey-chart. You can also load through the script tag directly from https://unpkg.com.

Usage

import { embed } from '@nebula.js/stardust';
import sankey from '@nebula.js/sn-sankey-chart';

// 'app' is an enigma app model
const nuked = embed(app, {
  types: [
    {
      // register sankey chart
      name: 'sankey',
      load: () => Promise.resolve(sankey),
    },
  ],
});

nuked.render({
  element,
  type: 'sankey',
  fields: ['Region', 'Product Group', 'Product Type', 'Product Line', '=Sum(Margin)'],
  // overrides default properties
  properties: {
    node: {
      padding: 0.2,
      width: 0.3,
    },
    link: {
      opacity: 0.5,
      shadow: false,
      color: 3,
      colorBy: 'custom',
    },
  },
});

More examples

You can change the node colors of each dimension value. The color should be a valid CSS color.

The colors of chart links are based on either the source or target anchors. To apply the source or target anchor color to chart links either use the string ='SOURCE' or ='TARGET'. You can also select a separate color by entering a color code string. The color should be a valid CSS color.

nuked.render({
  element: document.querySelector('.object'),
  type: 'sankeyChart',
  properties: {
    node: {
      padding: 0.1,
      width: 0.7,
    },
    qHyperCubeDef: {
      qDimensions: [
        {
          qDef: {
            qFieldDefs: ['Region'],
          },
          qAttributeExpressions: [
            {
              qExpression: "if(Sum(total<Region> Margin) > 4500000, '#53ac94', '#ac536b')",
            },
          ],
        },
        {
          qDef: {
            qFieldDefs: ['Product Group'],
          },
          qAttributeExpressions: [
            {
              qExpression: "'#28bad7'",
            },
          ],
        },
      ],
      qMeasures: [
        {
          qDef: {
            qDef: 'Sum(Margin)',
          },
          qAttributeExpressions: [
            {
              qExpression: "if(Sum(Margin) > 300000, '#53ac94', '#ac536b')",
            },
          ],
        },
      ],
      qInitialDataFetch: [
        {
          qLeft: 0,
          qTop: 0,
          qWidth: 6,
          qHeight: 1000,
        },
      ],
    },
  },
});
nuked.render({
  element: document.querySelector('.object'),
  type: 'sankeyChart',
  fields: ['Product Group', 'Product Type'],
  properties: {
    qHyperCubeDef: {
      qDimensions: [
        {
          qDef: {
            qFieldDefs: ['Region'],
          },
          qAttributeExpressions: [
            {
              qExpression: "if(Sum(total<Region> Margin) > 4500000, '#53ac94', '#ac536b')",
            },
          ],
        },
      ],
      qMeasures: [
        {
          qDef: {
            qDef: 'Sum(Margin)',
          },
          qAttributeExpressions: [
            {
              qExpression: "='SOURCE'",
            },
          ],
        },
      ],
      qInitialDataFetch: [
        {
          qLeft: 0,
          qTop: 0,
          qWidth: 6,
          qHeight: 1000,
        },
      ],
    },
  },
});

Keywords

FAQs

Package last updated on 07 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc