Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
In-development TypeScript def for d3-sankey 0.4.1
// Type definitions for D3JS d3-sankey module v0.4.1
// Project: https://github.com/d3/d3-sankey/
// Definitions by: Ændrew Rininsland <https://github.com/aendrew>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// I plan to submit this to DefinitelyTyped; if you find this online, please check there first.
interface Sankey {
/**
* If _width_ is specified, sets the node width to the specified function or number and returns
* this sankey generator. If width is not specified, returns the current node width accessor,
* which defaults to:
* ```
* function nodeWidth() {
* return 24;
* }
* ```
*
* @param {number} width Nodal width
* @return {Sankey} Sankey layout generator
*/
nodeWidth(width: number): this;
/**
* If _padding_ is specified, sets the node padding to the specified function or number and
* returns this sankey generator. If _padding_ is not specified, returns the current node padding
* accessor, which defaults to:
* ```
* function nodePadding() {
* return 8;
* }
* ```
* Here padding refers to the vertical space between nodes that occupy the same horizontal space.
*
* @param {number} padding Nodal padding
* @return {Sankey} Sankey layout generator
*/
nodePadding(padding: number): this;
/**
* If _nodes_ is specified, sets the list of nodes to the specified function or array and returns
* this sankey generator. If _nodes_ is not specified, returns the current accessor to the list
* of nodes, which defaults to:
* ```
* function nodes() {
* return [];
* }
* ```
*
* @return {nodeAccessor} [description]
*/
nodes(): () => Array<any>;
nodes(nodeAccessor): this;
/**
* If _links_ is specified, sets the list of links to the specified function or array and returns
* this sankey generator. If _links_ is not specified, returns the current accessor to the list
* of links, which defaults to:
* ```
* function links() {
* return [];
* }
* ```
*
* @param {Function<Array>} linkAccessor Link accessor function
* @return {Sankey} Sankey layout generator
*/
links(): () => Array<any>;
links(linkAccessor): this;
/**
* Returns the current accessor to the SVG layout object. Here _iterations_ is the number of
* times the converging function *computeNodeDepths* is run.
*
* @param {number} iterations Number of times converging function is run.
* @return {Sankey} Sankey layout generator
*/
layout(iterations: number): this;
/**
* Similar to *layout* but only recalculates the depth of links.
* Primarily used when a node is moved vertically.
*
* @return {Sankey} Sankey layout generator
*/
relayout(): this;
}
declare module "d3-sankey" {
/**
* Constructs a new sankey generator with the default settings.
* @return {Sankey} Sankey generator with the default settings
*/
function sankey(): Sankey;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.