1.0.2 • Published 6 months ago

@mpalola/apex-sankey-react v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

apex-sankey-react

React component for displaying ApexSankey charts.

https://www.npmjs.com/package/@mpalola/apex-sankey-react

Installation

npm install react
npm install apexsankey@1.1.2
npm install @mpalola/apex-sankey-react

Development environment installation

Example code is on demo directory.

  1. copy package.json in root and two other files to src directory.

  2. Install dependencies:

npm install
  1. Start development server:
npm start

Development server starts at http://localhost:3000 and opens the browser automatically.

Example

import { SankeyChart } from 'apex-sankey-react';

const Example = () => {
  const data = {
    nodes: [
      { id: "a", name: "AAA" },
      { id: "b", name: "BBB" },
      { id: "c", name: "CCC" }
    ],
    links: [
      { source: "a", target: "c", value: 1 },
      { source: "b", target: "c", value: 2 }
    ]
  };

  const options = {
    width: 800,
    height: 600,
    nodeWidth: 20,
    nodePadding: 10,
    linkOpacity: 0.5,
    colors: ['#4CAF50', '#2196F3', '#FFC107', '#F44336']
  };

  return (
    <SankeyChart
      data={data}
      {...options}
    />
  );
};

Props

PropTypeDefaultDescription
dataobject-Sankey diagram data (nodes and links)
widthnumber800Chart width in pixels
heightnumber600Chart height in pixels
nodeWidthnumber20Width of nodes
nodePaddingnumber10Padding between nodes
linkOpacitynumber0.5Opacity of links
colorsstring[]'#4CAF50',...Color palette
enableTooltipbooleantrueShow tooltip
showValuesbooleantrueShow values
showLabelsbooleantrueShow labels
showLegendbooleantrueShow legend
legendPositionstring'bottom'Legend position
canvasStylestring''Canvas element styles

License

MIT

1.0.2

6 months ago

1.0.1

7 months ago

1.0.0

7 months ago