# @types/d3-contour

- Version 3.0.2
- Published
- 13.8 kB
- 2 dependencies
- MIT license

## Install

`npm i @types/d3-contour`

`yarn add @types/d3-contour`

`pnpm add @types/d3-contour`

## Overview

TypeScript definitions for d3-contour

## Index

## Functions

### function contourDensity

`contourDensity: <Datum = [number, number]>() => ContourDensity<Datum>;`

Construct a new contour generator for density estimates.

The generic refers to the data type of an element in the data array used with the density contour generator. If omitted, the default setting assumes that, the elements of the data array used with the density contour generator are two-element arrays. The first element corresponds to the x-dimension, the second to the y-dimension.

Important: ensure that the x- and y-accessor functions are configured to match the data type used for the generic Datum.

### function contours

`contours: () => Contours;`

Construct a new contour generator with the default settings.

## Interfaces

### interface ContourDensity

`interface ContourDensity<Datum = [number, number]> {}`

A contour generator for density estimates.

The generic refers to the data type of an element in the data array used with the density contour generator. If omitted, the default setting assumes that, the elements of the data array used with the density contour generator are two-element arrays. The first element corresponds to the x-dimension, the second to the y-dimension.

### method bandwidth

`bandwidth: { (): number; (bandwidth: number): this };`

Returns the current bandwidth, which defaults to 20.4939….

Sets the bandwidth (the standard deviation) of the Gaussian kernel and returns the density contour estimator.

#### Parameter bandwidth

Bandwidth (the standard deviation) of the Gaussian kernel. The specified bandwidth is currently rounded to the nearest supported value by this implementation, and must be nonnegative.

### method cellSize

`cellSize: { (): number; (cellSize: number): this };`

Returns the current cell size, which defaults to 4.

Sets the size of individual cells in the underlying bin grid to the specified positive integer and returns the density contour estimator.

The cell size is rounded down to the nearest power of two. Smaller cells produce more detailed contour polygons, but are more expensive to compute.

#### Parameter cellSize

Cell size, a positive integer.

### method size

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

Returns the current size, which defaults to [960, 500].

Sets the size of the density estimator to the specified bounds and returns the density contour estimator.

#### Parameter size

The size is specified as an array [width, height], where width is the maximum x-value and height is the maximum y-value.

### method thresholds

`thresholds: { (): ThresholdCountGenerator<number> | ThresholdNumberArrayGenerator<number>; (thresholds: any): this;};`

Returns the current threshold generator, which by default generates about twenty nicely-rounded density thresholds.

Sets the threshold generator to the specified function or array and returns this contour generator. Thresholds are defined as an array of values [x0, x1, …]. The first generated density contour corresponds to the area where the estimated density is greater than or equal to x0; the second contour corresponds to the area where the estimated density is greater than or equal to x1, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as geometry.value. The first value x0 should typically be greater than zero. If a count is specified instead of an array of thresholds, then approximately count uniformly-spaced nicely-rounded thresholds will be generated; see d3.ticks.

### method weight

`weight: { (): (d: Datum) => number; (weight: (d: Datum) => number): this };`

Returns the current point weight accessor.

Sets the point weight accessor and returns the density contour estimator.

#### Parameter weight

A point weight accessor function.

### method x

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

Returns the current x-coordinate accessor. The default x-coordinate accessor is a functions which accepts as input a two-element array of numbers and returns the element at index 0.

Sets the x-coordinate accessor and returns the density contour estimator.

#### Parameter x

An x-coordinate accessor function, which accepts as input an element of the input data array and returns the x-coordinate.

### method y

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

Returns the current y-coordinate accessor. The default y-coordinate accessor is a functions which accepts as input a two-element array of numbers and returns the element at index 1.

Sets the y-coordinate accessor and returns the density contour estimator.

#### Parameter y

An y-coordinate accessor function, which accepts as input an element of the input data array and returns the y-coordinate.

### call signature

`(data: Datum[]): ContourMultiPolygon[];`

Estimates the density contours for the given array of data, returning an array of GeoJSON MultiPolygon geometry objects. Each geometry object represents the area where the estimated number of points per square pixel is greater than or equal to the corresponding threshold value; the threshold value for each geometry object is exposed as geometry.value. The returned geometry objects are typically passed to d3.geoPath to display, using null or d3.geoIdentity as the associated projection. See also d3.contours.

The x- and y-coordinate for each data point are computed using density.x and density.y. The generated contours are only accurate within the estimator’s defined size.

#### Parameter data

Array of input data.

### interface ContourMultiPolygon

`interface ContourMultiPolygon extends MultiPolygon {}`

An extended GeoJSON MultiPolygon representing a contour.

### property value

`value: number;`

Threshold value of the contour.

### interface Contours

`interface Contours {}`

A contour generator which computes contour polygons by applying marching squares to a rectangular array of numeric values.

For each threshold value, the contour generator constructs a GeoJSON MultiPolygon geometry object representing the area where the input values are greater than or equal to the threshold value. The geometry is in planar coordinates, where ⟨i + 0.5, j + 0.5⟩ corresponds to element i + jn in the input values array.

### method contour

`contour: (values: number[], threshold: number) => ContourMultiPolygon;`

Computes a single contour, returning a GeoJSON MultiPolygon geometry object. This geometry object represents the area where the input values are greater than or equal to the given threshold value; the threshold value for the geometry object is exposed as geometry.value.

#### Parameter values

Array of input values. The input values must be an array of length n×m where [n, m] is the contour generator’s size; furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩.

#### Parameter threshold

Threshold value.

### method size

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

Return the expected size of the input values grid, which defaults to [1,1].

Sets the expected size of the input values grid to the contour generator and returns the contour generator.

#### Parameter size

Size of the input values grid specified as an array [n, m] where n is the number of columns in the grid and m is the number of rows; n and m must be positive integers.

### method smooth

`smooth: { (): boolean; (smooth: boolean): this };`

Returns the current smoothing flag, which defaults to true.

Sets whether or not the generated contour polygons are smoothed using linear interpolation and returns the contour generator.

#### Parameter smooth

Flag to enable linear interpolation. The default is "true".

### method thresholds

`thresholds: { (): ThresholdCountGenerator<number> | ThresholdNumberArrayGenerator<number>; (thresholds: any): this;};`

Returns the current threshold generator, which by default implements Sturges’ formula.

Sets the threshold generator to the specified function or array and returns this contour generator. Thresholds are defined as an array of values [x0, x1, …]. The first generated contour corresponds to the area where the input values are greater than or equal to x0; the second contour corresponds to the area where the input values are greater than or equal to x1, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as geometry.value. If a count is specified instead of an array of thresholds, then the input values’ extent will be uniformly divided into approximately count bins; see d3.ticks.

### call signature

`(values: number[]): ContourMultiPolygon[];`

Computes the contours for the given array of values, returning an array of GeoJSON MultiPolygon geometry objects. Each geometry object represents the area where the input values are greater than or equal to the corresponding threshold value; the threshold value for each geometry object is exposed as geometry.value.

The returned geometry objects are typically passed to d3.geoPath to display, using null or d3.geoIdentity as the associated projection

#### Parameter values

Array of input values. The input values must be an array of length n×m where [n, m] is the contour generator’s size; furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩.

## Package Files (1)

## Dependencies (2)

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

.

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

- Updated .

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