# @types/d3-voronoi

- Version 1.1.12
- Published
- 14 kB
- No dependencies
- MIT license

## Install

`npm i @types/d3-voronoi`

`yarn add @types/d3-voronoi`

`pnpm add @types/d3-voronoi`

## Overview

TypeScript definitions for d3-voronoi

## Index

### Functions

### Interfaces

### Type Aliases

## Functions

### function voronoi

`voronoi: <T = [number, number]>() => VoronoiLayout<T>;`

Creates a new Voronoi layout with default x- and y- accessors and a null extent. x- and y-accessors may have to be set to correspond to the data type provided by the generic.

The generic refers to the type of the data for the corresponding element. Without specifying a generic the layout is assumed to be based on data represented by a two-dimensional coordinate

`[number, number]`

for x- and y-coordinate, respectively.

## Interfaces

### interface VoronoiCell

`interface VoronoiCell<T> {}`

A Voronoi Cell in the diagram is an object with the following properties: site and halfedges

The generic refers to the type of the data for the corresponding element.

### interface VoronoiDiagram

`interface VoronoiDiagram<T> {}`

Computed Voronoi diagram

The generic refers to the type of the data for the corresponding element.

### property cells

`cells: Array<VoronoiCell<T> | null>;`

Array of Voronoi Cells, one per input point; a cell may be null for a coincident point.

### property edges

`edges: Array<VoronoiEdge<T>>;`

Array of Voronoi Edges

### method find

`find: (x: number, y: number, radius?: number) => VoronoiSite<T> | null;`

Return the nearest Voronoi Site to point [x, y]. If radius is specified, only sites within radius distance are considered. If no Voronoi Site can be found (within the specified radius), null is returned.

#### Parameter x

x-coordinate

#### Parameter y

y-coordinate

#### Parameter radius

Optional parameter for search radius around [x, y]

### method links

`links: () => Array<VoronoiLink<T>>;`

Returns the Delaunay triangulation of the specified data array as an array of links, one for each edge in the mesh. Each link has the following attributes: - source (the source node, an element in data) - target (the target node, an element in data)

Since the triangulation is computed as the dual of the Voronoi diagram, and the Voronoi diagram is clipped by the extent, a subset of the Delaunay links is returned.

### method polygons

`polygons: () => Array<VoronoiPolygon<T>>;`

Return an array of polygons clipped to the extent, one for each cell in the diagram. Each polygon is represented as an array of points [x, y] where x and y are the point coordinates, and a data field that refers to the corresponding element in data. Polygons are open: they do not contain a closing point that duplicates the first point; a triangle, for example, is an array of three points. Polygons are also counterclockwise, assuming the origin ⟨0,0⟩ is in the top-left corner.

If the cell’s site is coincident with an earlier site, the associated polygon is null.

### method triangles

`triangles: () => Array<VoronoiTriangle<T>>;`

Returns the Delaunay triangulation of the specified data array as an array of triangles. Each triangle is a three-element array of elements from data. Since the triangulation is computed as the dual of the Voronoi diagram, and the Voronoi diagram is clipped by the extent, a subset of the Delaunay triangulation is returned.

### interface VoronoiEdge

`interface VoronoiEdge<T> extends VoronoiPointPair {}`

Voronoi Edge in the diagram is an array [[x0, y0], [x1, y1]] with two additional properties: left and right.

The generic refers to the type of the data for the corresponding element.

### interface VoronoiLayout

`interface VoronoiLayout<T> {}`

A Voronoi Layout.

The generic refers to the type of the data for the corresponding element.

### method extent

`extent: { (): [[number, number], [number, number]] | null; (extent: [[number, number], [number, number]]): this;};`

Returns the current clip extent which defaults to null.

The extent bounds are specified as an array [[x0, y0], [x1, y1]], where x0 is the left side of the extent, y0 is the top, x1 is the right and y1 is the bottom.

A clip extent is required when using voronoi.polygons.

Set the clip extent of the Voronoi layout to the specified bounds and return the layout.

A clip extent is required when using voronoi.polygons.

#### Parameter extent

The extent bounds are specified as an array [[x0, y0], [x1, y1]], where x0 is the left side of the extent, y0 is the top, x1 is the right and y1 is the bottom.

### method links

`links: (data: T[]) => Array<VoronoiLink<T>>;`

Return the Delaunay triangulation of the specified data array as an array of links. Each link has source and target attributes referring to elements in data.

#### Parameter data

Array of data points.

### method polygons

`polygons: (data: T[]) => Array<VoronoiPolygon<T>>;`

Return an array of polygons clipped to the extent, one for each input point in the specified data points, corresponding to the cells in the computed Voronoi diagram.

Each polygon is represented as an array of points [x, y] where x and y are the point coordinates, and a data field that refers to the corresponding element in data. Polygons are open: they do not contain a closing point that duplicates the first point; a triangle, for example, is an array of three points. Polygons are also counterclockwise, assuming the origin ⟨0,0⟩ is in the top-left corner.

If the cell’s site is coincident with an earlier site, the associated polygon is null.

Important: Using polygon requires the extent to be set for the layout.

#### Parameter data

Array of data points.

### method size

`size: { (): [number, number] | null; (size: [number, number]): this };`

Get the clip size of the Voronoi layout. Size is an alias for voronoi.extent where the minimum x and y of the extent are ⟨0,0⟩.

Set the clip size and return the layout.

Size is an alias for voronoi.extent where the minimum x and y of the extent are ⟨0,0⟩.

#### Parameter size

An array representing the x- and y-size of the clip extent, where the minimum x and y of the extent are ⟨0,0⟩.

### method triangles

`triangles: (data: T[]) => Array<VoronoiTriangle<T>>;`

Return the Delaunay triangulation of the specified data array as an array of triangles. Each triangle is a three-element array of elements from data.

#### Parameter data

Array of data points.

### method x

`x: { (): (d: T) => number; (x: (d: T) => number): this };`

Return the current x-coordinate accessor, which defaults to accessing the first element of an array (i.e. at index 0).

Set the x-coordinate accessor and return the layout.

#### Parameter x

An accessor function which takes a data element as input and return a numeric value for the x-coordinate.

### method y

`y: { (): (d: T) => number; (y: (d: T) => number): this };`

Return the current y-coordinate accessor, which defaults to accessing the second element of an array (i.e. at index 1).

Set the y-coordinate accessor and return the layout.

#### Parameter y

An accessor function which takes a data element as input and return a numeric value for the y-coordinate.

### call signature

`(data: T[]): VoronoiDiagram<T>;`

Computes the Voronoi diagram for the specified data points.

#### Parameter data

Array of data elements

### interface VoronoiLink

`interface VoronoiLink<T> {}`

Voronoi Link for an edge in the mesh created by the Delaunay triangulation of the specified data array. Each link has the following attributes: source and target.

The generic refers to the type of the data for the corresponding element.

### interface VoronoiPoint

`interface VoronoiPoint extends Array<number> {}`

The VoronoiPoint interface is defined as a cue that the array is strictly of type [number, number] with two elements for x and y coordinates. However, it is used as a base for interface definitions, and [number, number] cannot be extended.

### interface VoronoiPointPair

`interface VoronoiPointPair extends Array<[number, number]> {}`

The VoronoiPointPair interface is defined as a cue that the array is strictly of type [[number, number], [number, number]] with two elements, one for each point containing the respective x and y coordinates. However, it is used as a base for interface definitions, and [[number, number], [number, number]] cannot be extended.

### interface VoronoiPolygon

`interface VoronoiPolygon<T> extends Array<[number, number]> {}`

A Voronoi Polygon is represented as an array of points [x, y] where x and y are the point coordinates, and a data field that refers to the corresponding element in data. Polygons are open: they do not contain a closing point that duplicates the first point; a triangle, for example, is an array of three points. Polygons are also counterclockwise, assuming the origin ⟨0,0⟩ is in the top-left corner.

The generic refers to the type of the data for the corresponding element.

### property data

`data: T;`

The input data corresponding to this Voronoi polygon.

### interface VoronoiSite

`interface VoronoiSite<T> extends VoronoiPoint {}`

A Voronoi Site in the diagram is an array [x, y] with two additional properties: index and data.

The generic refers to the type of the data for the corresponding element.

## Type Aliases

### type VoronoiTriangle

`type VoronoiTriangle<T> = [T, T, T];`

Voronoi Triangle is a three-element array of elements from data.

The generic refers to the type of the data for the corresponding element.

## 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-voronoi`

.

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

- Updated .

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