UNPKG

@ux-aspects/ux-aspects

Version:

Open source user interface framework for building modern, responsive, mobile big data applications

96 lines (95 loc) 3.47 kB
import { SankeyLink, SankeyLinkPlot } from './interfaces/link.interface'; import { SankeyNodeLink } from './interfaces/node-link.interface'; import { SankeyNode } from './interfaces/node.interface'; export declare class SankeyChart<T> { /** Define the nodes in the chart */ private _nodes; /** Define the links in the chart */ private _links; /** Store the node-links */ private _nodeLinks; /** Define the minimum width of the nodes */ private _minWidth; /** Define the maximum width of the nodes */ private _maxWidth; /** The minimum height of a node. */ private _minHeight; /** Define the width of the chart */ private _width; /** Define the height of the chart */ private _height; /** Define the vertical padding between nodes */ private _spacing; /** Define the minimum distance from the edge of the chart */ private readonly _padding; /** Define the spacing of the chart */ spacing(spacing: number): this; /** Define the width of the chart */ width(width: number): this; /** Define the height of the chart */ height(height: number): this; /** Define the nodes */ nodes(nodes: ReadonlyArray<SankeyNode<T>>): this; /** Define the links */ links(links: ReadonlyArray<SankeyLink>): this; /** Define the minimum and maximum size of the nodes */ size(minWidth: number, maxWidth: number, minHeight: number): this; /** Get the sizes of each column */ columns(): number[]; /** * Perform the various stages of the layout * in the correct order as some steps are dependant * on the previous layout stages. */ layout(): ReadonlyArray<SankeyNodeLink<T>>; /** The curve equation for links */ link(link: SankeyLink & SankeyLinkPlot): string; getFalloffPath(nodeLink: SankeyNodeLink<T>): string; /** * Get a `SankeyNodeLink` object from the id of a node */ getNodeLink(id: string | number): SankeyNodeLink<T>; /** Replace the node ids with actual references */ private getNodeLinks; /** Get the value for the node based on all its inputs and outputs */ private getNodeValues; /** * We need to determine which column the node should * be placed in. This is determined by taking the input * and adding one. */ private getNodeColumns; /** Get the width of each node */ private getNodeWidths; /** * Scale the nodes height based on the value the represent */ private getNodeHeights; /** * Recalculate node heights within height limits until they fit (if possible). * @throws If it is not possible to fit all nodes in the chart due to `minHeight`. */ private adjustNodeHeightsToFit; /** Set all nodes height to be the same as the naturalHeight. */ private setNodesToNaturalHeight; /** * Get all nodes grouped in their corresponding columns */ private getColumnGroups; /** * Get the number of columns */ private getColumnCount; /** * Position the nodes in their corresponding x and y positions */ private getNodePositions; private getColumnPadding; private getLinkPlots; /** Determine the position at which a column starts */ private getColumnPosition; /** Get the pixel width of a node */ private getNodeWidth; /** Get the column with the greatest height (along with its height) */ private getLargestColumn; }