# @types/d3-chord

- Version 3.0.1
- Published
- 25.8 kB
- No dependencies
- MIT license

## Install

`npm i @types/d3-chord`

`yarn add @types/d3-chord`

`pnpm add @types/d3-chord`

## Overview

TypeScript definitions for D3JS d3-chord module

## Index

### Functions

### Interfaces

## Functions

### function chord

`chord: () => ChordLayout;`

Constructs a new chord diagram layout with the default settings.

### function chordDirected

`chordDirected: () => ChordLayout;`

A chord layout for directional flows. The chord from i to j is generated from the value in matrix[i][j] only.

### function chordTranspose

`chordTranspose: () => ChordLayout;`

A transposed chord layout. Useful to highlight outgoing (rather than incoming) flows.

### function ribbon

`ribbon: { (): RibbonGenerator<any, Ribbon, RibbonSubgroup>; <Datum, SubgroupDatum>(): RibbonGenerator<any, Datum, SubgroupDatum>; <This, Datum, SubgroupDatum>(): RibbonGenerator<This, Datum, SubgroupDatum>;};`

Creates a new ribbon generator with the default settings.

Creates a new ribbon generator with the default settings.

Accessor functions must be configured for the ribbon generator, should the datum types differ from the defaults.

The first generic corresponds to the datum type representing a chord for which the ribbon is to be generated. The default type is Chord.

The second generic corresponds to the datum type of the chord subgroup, i.e. source or target of the cord. The default type is ChordSubgroup.

Creates a new ribbon generator with the default settings.

Accessor functions must be configured for the ribbon generator, should the datum types differ from the defaults.

The first generic corresponds to the type of the "this" context within which the ribbon generator and its accessor functions will be invoked.

The second generic corresponds to the datum type representing a chord for which the ribbon is to be generated. The default type is Chord.

The third generic corresponds to the datum type of the chord subgroup, i.e. source or target of the cord. The default type is ChordSubgroup.

### function ribbonArrow

`ribbonArrow: { (): RibbonArrowGenerator<any, Ribbon, RibbonSubgroup>; <Datum, SubgroupDatum>(): RibbonArrowGenerator<any, Datum, SubgroupDatum>; <This, Datum, SubgroupDatum>(): RibbonArrowGenerator<This, Datum, SubgroupDatum>;};`

Creates a new arrow ribbon generator with the default settings.

Creates a new arrow ribbon generator with the default settings.

Accessor functions must be configured for the ribbon generator, should the datum types differ from the defaults.

The first generic corresponds to the datum type representing a chord for which the ribbon is to be generated. The default type is Chord.

The second generic corresponds to the datum type of the chord subgroup, i.e. source or target of the cord. The default type is ChordSubgroup.

Creates a new arrow ribbon generator with the default settings.

The first generic corresponds to the type of the "this" context within which the ribbon generator and its accessor functions will be invoked.

The second generic corresponds to the datum type representing a chord for which the ribbon is to be generated. The default type is Chord.

The third generic corresponds to the datum type of the chord subgroup, i.e. source or target of the cord. The default type is ChordSubgroup.

## Interfaces

### interface Chord

`interface Chord {}`

A chord represents the combined bidirectional flow between two nodes i and j (where i may be equal to j)

### interface ChordGroup

`interface ChordGroup {}`

A chord group for a given node i representing the combined outflow for node i, corresponding to the elements matrix[i][0 … n - 1].

### property endAngle

`endAngle: number;`

The end angle of the chord group in radians

### property index

`index: number;`

The node index i

### property startAngle

`startAngle: number;`

The start angle of the chord group in radians

### property value

`value: number;`

The total outgoing flow value for node i

### interface ChordLayout

`interface ChordLayout {}`

A D3 chord diagram Layout to visualize relationships or network flow with an aesthetically-pleasing circular layout.

The relationships are represented as a square matrix of size n×n, where the matrix represents the directed flow amongst a network (a complete digraph) of n nodes.

### method padAngle

`padAngle: { (): number; (angle: number): this };`

Returns the current pad angle in radians, which defaults to zero.

Sets the pad angle between adjacent groups to the specified number in radians and returns this chord layout.

The default is zero.

#### Parameter angle

Pad angle between adjacent groups in radians.

### method sortChords

`sortChords: { (): (a: number, b: number) => number; (compare: (a: number, b: number) => number): this;};`

Returns the current chord comparator, which defaults to null.

Sets the chord comparator to the specified function or null and returns this chord layout. If the chord comparator is non-null, it is used to sort the chords by their combined flow; this only affects the z-order of the chords. See also d3.ascending and d3.descending.

### method sortGroups

`sortGroups: { (): (a: number, b: number) => number; (compare: (a: number, b: number) => number): this;};`

Returns the current group comparator, which defaults to null.

Sets the group comparator to the specified function or null and returns this chord layout. If the group comparator is non-null, it is used to sort the groups by their total outflow. See also d3.ascending and d3.descending.

### method sortSubgroups

`sortSubgroups: { (): (a: number, b: number) => number; (compare: (a: number, b: number) => number): this;};`

Returns the current subgroup comparator, which defaults to null.

Sets the subgroup comparator to the specified function or null and returns this chord layout. If the subgroup comparator is non-null, it is used to sort the subgroups corresponding to matrix[i][0 … n - 1] for a given group i by their total outflow. See also d3.ascending and d3.descending.

### call signature

`(matrix: number[][]): Chords;`

Computes the chord layout for the specified square matrix of size n×n, where the matrix represents the directed flow amongst a network (a complete digraph) of n nodes.

#### Parameter matrix

An (n x n) matrix representing the directed flow amongst a network (a complete digraph) of n nodes.The given matrix must be an array of length n, where each element matrix[i] is an array of n numbers, where each matrix[i][j] represents the flow from the ith node in the network to the jth node. Each number matrix[i][j] must be nonnegative, though it can be zero if there is no flow from node i to node j.

### interface Chords

`interface Chords extends Array<Chord> {}`

An array of chords, where each chord represents the combined bidirectional flow between two nodes i and j (where i may be equal to j). The chords are based on a (n x n) matrix of flows between nodes.

The chords are typically passed to d3.ribbon to display the network relationships. The returned array includes only chord objects for which the value matrix[i][j] or matrix[j][i] is non-zero. Furthermore, the returned array only contains unique chords: a given chord ij represents the bidirectional flow from i to j and from j to i, and does not contain a duplicate chord ji; i and j are chosen such that the chord’s source always represents the larger of matrix[i][j] and matrix[j][i]. In other words, chord.source.index equals chord.target.subindex, chord.source.subindex equals chord.target.index, chord.source.value is greater than or equal to chord.target.value, and chord.source.value is always greater than zero.

### property groups

`groups: ChordGroup[];`

An array of length n, where each group represents the combined outflow for node i, corresponding to the elements matrix[i][0 … n - 1]

### interface ChordSubgroup

`interface ChordSubgroup {}`

A chord subgroup serving as source or target of a chord between two nodes i an j (where i may be equal to j).

### property endAngle

`endAngle: number;`

* End angle of the chord subgroup in radians

### property index

`index: number;`

The node index i

### property startAngle

`startAngle: number;`

Start angle of the chord subgroup in radians

### property value

`value: number;`

The flow value in matrix[i][j] from node i to node j

### interface Ribbon

`interface Ribbon {}`

A minimal interface to support the default source and target accessors used by RibbonGenerator. (Corresponds to Chord)

### interface RibbonArrowGenerator

`interface RibbonArrowGenerator<This, RibbonDatum, RibbonSubgroupDatum> extends RibbonGenerator<This, RibbonDatum, RibbonSubgroupDatum> {}`

### method headRadius

`headRadius: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (radius: number): this; ( radius: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

### interface RibbonGenerator

`interface RibbonGenerator<This, RibbonDatum, RibbonSubgroupDatum> {}`

A ribbon generator to support rendering of chords in a chord diagram.

The first generic corresponds to the type of the "this" context within which the ribbon generator and its accessor functions will be invoked.

The second generic corresponds to the datum type representing a chord for which the ribbon is to be generated. The default type is Ribbon.

The third generic corresponds to the datum type of the chord subgroup, i.e. source or target of the cord. The default type is RibbonSubgroup.

### method context

`context: { (): CanvasRenderingContext2D | null; (context: CanvasRenderingContext2D): this;};`

Returns the current rendering context, which defaults to null.

Sets the context and returns this ribbon generator. If the context is not null, then the generated ribbon is rendered to this context as a sequence of path method calls. Otherwise, a path data string representing the generated ribbon is returned. See also d3-path.

### method endAngle

`endAngle: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (angle: number): this; ( angle: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current end angle accessor, which defaults to a function returning the "endAngle" property (assumed to be a number in radians) of the source or target object returned by the source or target accessor, respectively.

Sets the end angle to a fixed number in radians and returns this ribbon generator.

#### Parameter angle

A fixed numeric value for the end angle in radians.

Sets the end angle accessor to the specified function and returns this ribbon generator.

#### Parameter angle

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the end angle in radians.

### method padAngle

`padAngle: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (angle: number): this; ( angle: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current pad angle accessor, which defaults to a function returning 0.

Sets the pad angle to a fixed number in radians and returns this ribbon generator.

#### Parameter angle

A fixed numeric value for the pad angle in radians.

Sets the pad angle accessor to the specified function and returns this ribbon generator.

#### Parameter angle

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the pad angle in radians.

### method radius

`radius: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (radius: number): this; ( radius: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current radius accessor, which defaults to a function returning the "radius" property (assumed to be a number) of the source or target object returned by the source or target accessor, respectively.

Sets the radius to a fixed number and returns this ribbon generator.

#### Parameter radius

A fixed numeric value for the radius.

Sets the radius accessor to the specified function and returns this ribbon generator.

#### Parameter radius

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the radius value.

### method source

`source: { (): (this: This, d: RibbonDatum, ...args: any[]) => RibbonSubgroupDatum; ( source: ( this: This, d: RibbonDatum, ...args: any[] ) => RibbonSubgroupDatum ): this;};`

Returns the current source accessor, which defaults to a function returning the "source" property of the first argument passed into the accessor.

Sets the source accessor to the specified function and returns this ribbon generator.

#### Parameter source

An accessor function returning the source datum of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the ribbon generator.

### method sourceRadius

`sourceRadius: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (radius: number): this; ( radius: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current source radius accessor, which defaults to a function returning the "radius" property (assumed to be a number) of the source or target object returned by the source or target accessor, respectively.

Sets the source radius to a fixed number and returns this ribbon generator.

#### Parameter radius

A fixed numeric value for the source radius.

Sets the source radius accessor to the specified function and returns this ribbon generator.

#### Parameter radius

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the source radius value.

### method startAngle

`startAngle: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (angle: number): this; ( angle: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current start angle accessor, which defaults to a function returning the "startAngle" property (assumed to be a number in radians) of the source or target object returned by the source or target accessor, respectively.

Sets the start angle to a fixed number in radians and returns this ribbon generator.

#### Parameter angle

A fixed numeric value for the start angle in radians.

Sets the start angle accessor to the specified function and returns this ribbon generator.

#### Parameter angle

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the start angle in radians.

### method target

`target: { (): (this: This, d: RibbonDatum, ...args: any[]) => RibbonSubgroupDatum; ( target: ( this: This, d: RibbonDatum, ...args: any[] ) => RibbonSubgroupDatum ): this;};`

Returns the current target accessor, which defaults to a function returning the "target" property of the first argument passed into the accessor.

Sets the target accessor to the specified function and returns this ribbon generator.

#### Parameter target

An accessor function returning the target datum of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives the same arguments that were passed into the ribbon generator.

### method targetRadius

`targetRadius: { (): (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number; (radius: number): this; ( radius: (this: This, d: RibbonSubgroupDatum, ...args: any[]) => number ): this;};`

Returns the current target radius accessor, which defaults to a function returning the "radius" property (assumed to be a number) of the source or target object returned by the source or target accessor, respectively.

Sets the target radius to a fixed number and returns this ribbon generator.

#### Parameter radius

A fixed numeric value for the target radius.

Sets the target radius accessor to the specified function and returns this ribbon generator.

#### Parameter radius

An accessor function which is invoked for the source and target of the chord. The accessor function is invoked in the same "this" context as the generator was invoked in and receives as the first argument the source or target object returned by the respective source or target accessor function of the generator. It is also passed any additional arguments that were passed into the generator, with the exception of the first element representing the chord datum itself. The function returns the target radius value.

### call signature

`(this: This, d: RibbonDatum, ...args: any[]): void;`

Generates a ribbon for the given arguments.

IMPORTANT: If the ribbon generator has been configured with a rendering context, then the ribbon is rendered to this context as a sequence of path method calls and this function returns void.

The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

#### Parameter d

The datum representing the chord for which the ribbon is to be generated.

### call signature

`(this: This, d: RibbonDatum, ...args: any[]): string | null;`

Generates a ribbon for the given arguments.

IMPORTANT: If the rendering context of the ribbon generator is null, then the ribbon is returned as a path data string.

The "this" context within which this function is invoked, will be the context within which the accessor methods of the generator are invoked. All arguments passed into this function, will be passed to the accessor functions of the generator.

#### Parameter d

The datum representing the chord for which the ribbon is to be generated.

### interface RibbonSubgroup

`interface RibbonSubgroup {}`

A minimal interface to support the default accessors used by RibbonGenerator for properties of source and target objects of a Ribbon.

(Corresponds to ChordSubgroup)

### property endAngle

`endAngle: number;`

End angle of the ribbon subgroup in radians

### property radius

`radius: number;`

Radius of the ribbon subgroup

### property startAngle

`startAngle: number;`

Start angle of the ribbon subgroup in radians

## Package Files (1)

## Dependencies (0)

No dependencies.

## Dev Dependencies (0)

No dev dependencies.

## Peer Dependencies (0)

No peer dependencies.

## Badge

To add a badge like this oneto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to `https://www.jsdocs.io/package/@types/d3-chord`

.

- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-chord)
- HTML<a href="https://www.jsdocs.io/package/@types/d3-chord"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>

- Updated .

Package analyzed in 6038 ms. - Missing or incorrect documentation? Open an issue for this package.