mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
Merge pull request #24271 from tomwanzek/d3-contour-default-generics
refactor(d3-contour): use generic parameter defaults
This commit is contained in:
@@ -113,7 +113,11 @@ interface CustomDatum {
|
||||
|
||||
// Get contour generator -------------------------------------------------------
|
||||
|
||||
const contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity();
|
||||
// test generic parameter defaults for ContourDensity and contourDensity
|
||||
const contDensDefault: d3Contour.ContourDensity = d3Contour.contourDensity();
|
||||
// tslint:disable-next-line: use-default-type-parameter
|
||||
const contDensDefaultCopy: d3Contour.ContourDensity<[number, number]> = contDensDefault;
|
||||
// test with explicit generic parameter
|
||||
let contDensCustom: d3Contour.ContourDensity<CustomDatum> = d3Contour.contourDensity<CustomDatum>();
|
||||
|
||||
// Configure contour generator =================================================
|
||||
|
||||
Vendored
+10
-11
@@ -120,8 +120,13 @@ export function contours(): Contours;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export interface ContourDensity<Datum> {
|
||||
export interface ContourDensity<Datum = [number, number]> {
|
||||
/**
|
||||
* 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
|
||||
@@ -238,21 +243,15 @@ export interface ContourDensity<Datum> {
|
||||
bandwidth(bandwidth: number): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new contour generator for density estimates with the default settings.
|
||||
*
|
||||
* The default settings assume 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.
|
||||
*/
|
||||
export function contourDensity(): ContourDensity<[number, number]>;
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
export function contourDensity<Datum>(): ContourDensity<Datum>;
|
||||
export function contourDensity<Datum = [number, number]>(): ContourDensity<Datum>;
|
||||
|
||||
Reference in New Issue
Block a user