Skip to content

Instantly share code, notes, and snippets.

@trinary
Created February 22, 2013 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinary/5010161 to your computer and use it in GitHub Desktop.
Save trinary/5010161 to your computer and use it in GitHub Desktop.
Start to some basic docs for d3.js d3.geom.polygon.

Wiki ▸ [[API Reference]] ▸ [[Geometry]] Polygon

A Polygon is a set of line segments that form a closed path, such that the end of the last line segment is the beginning of the first. Polygons require 3 or more points in order to have an area or centroid.

# d3.geom.polygon([vertices])

Returns a polygon with points at the specified vertices.

# polygon.area()

Returns the area of the polygon.

# polygon.centroid()

Returns the centroid of the polygon. The centroid as calculated by D3 is the average coordinate value of the points of the polygon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment