From 6c4c5409bf86ed2e719b64ac44f584766d6a42e9 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Wed, 31 Oct 2018 12:23:30 +0100 Subject: [PATCH] #30160 : density.weight in d3-contour --- types/d3-contour/d3-contour-tests.ts | 7 +++++++ types/d3-contour/index.d.ts | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/types/d3-contour/d3-contour-tests.ts b/types/d3-contour/d3-contour-tests.ts index 0184979be0..2d23017040 100644 --- a/types/d3-contour/d3-contour-tests.ts +++ b/types/d3-contour/d3-contour-tests.ts @@ -144,6 +144,13 @@ contDensCustom = contDensCustom.y((datum) => { // get const yAcc: (d: CustomDatum) => number = contDensCustom.y(); +// weight(...) ----------------------------------------------------------------- +contDensCustom = contDensCustom.weight((datum) => { + return 5; +}); + +// get +const weightAcc: (d: CustomDatum) => number = contDensCustom.weight(); // size(...) ------------------------------------------------------------------- // set with chainability diff --git a/types/d3-contour/index.d.ts b/types/d3-contour/index.d.ts index 8d42275ee2..4477c4bfa5 100644 --- a/types/d3-contour/index.d.ts +++ b/types/d3-contour/index.d.ts @@ -126,7 +126,7 @@ export function contours(): Contours; * 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 { +export interface ContourDensity { /** * 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 @@ -169,6 +169,18 @@ export interface ContourDensity { */ y(y: (d: Datum) => number): this; + /** + * Returns the current point weight accessor. + */ + weight(): (d: Datum) => number; + + /** + * Sets the point weight accessor and returns the density contour estimator. + * + * @param weight A point weight accessor function. + */ + weight(weight: (d: Datum) => number): this; + /** * Returns the current size, which defaults to [960, 500]. */ @@ -254,4 +266,4 @@ export interface ContourDensity { * Important: ensure that the x- and y-accessor functions are configured to * match the data type used for the generic Datum. */ -export function contourDensity(): ContourDensity; +export function contourDensity(): ContourDensity;