Skip to content

Commit 2fedb00

Browse files
Filmbostock
authored andcommitted
document centroid (observablehq#1362)
* document centroid * edits --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent 7601764 commit 2fedb00

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/transforms/centroid.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
import type {ChannelTransform, ChannelValue} from "../channel.js";
22
import type {Initialized} from "./basic.js";
33

4+
/** Options for the centroid and geoCentroid transforms. */
45
export interface CentroidOptions {
6+
/**
7+
* A channel supplying GeoJSON geometry; defaults to the identity transform,
8+
* assuming that the data is GeoJSON geometry.
9+
*/
510
geometry?: ChannelValue;
611
}
712

13+
/**
14+
* Given a **geometry** input channel of GeoJSON geometry, derives **x** and
15+
* **y** output channels representing the planar (projected) centroids of the
16+
* geometry. The centroids are computed in screen coordinates according to the
17+
* plot’s associated **projection** (or *x* and *y* scales), if any.
18+
*
19+
* For centroids of spherical geometry, see Plot.geoCentroid.
20+
*/
821
export function centroid<T>(options?: T & CentroidOptions): Initialized<T>;
922

23+
/**
24+
* Given a **geometry** input channel of spherical GeoJSON geometry, derives
25+
* **x** and **y** output channels representing the spherical centroids of the
26+
* geometry.
27+
*
28+
* For planar (projected) centroids, see Plot.centroid.
29+
*/
1030
export function geoCentroid<T>(options?: T & CentroidOptions): T & {x: ChannelTransform; y: ChannelTransform};

0 commit comments

Comments
 (0)