Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-tricontour

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-tricontour

Create contours from non-gridded data with meandering triangles.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

d3-tricontour

This library computes contour polygons by applying meandering triangles to an array of points with arbitrary 2D coordinates (x, y) holding numeric values z. To compute contours on gridded coordinates, see d3-contour instead.

For examples, see the tricontours collection on Observable.

flower

Installing

If you use NPM, npm install d3-tricontour. Otherwise, download the latest release. You can also load directly as a standalone library. ES modules, AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src="https://unpkg.com/d3-scale@3"></script>
<script src="https://unpkg.com/d3-delaunay@5"></script>
<script src="https://unpkg.com/d3-tricontour@0.0.6"></script>
<script>

const tric = d3.tricontour();
const contours = tric([[0, 0, 1], [1, 1, 0], [2, 0, 1]]);
> Array(11) [ {type: "MultiPolygon", coordinates: Array(1), value: 0} … ]
  
</script>

API Reference

The API of tricontour is similar to that of d3-contour:

# d3.tricontour() · Source, Examples

Constructs a new tricontour generator with the default settings.

# tricontour(data)

Returns an array of contours, one for each threshold. The contours are MultiPolygons in GeoJSON format, that contain all the points with a value larger than the threshold. The value is indicated as geometry.value.

The data is passed as an array of points, by default with the format [x,y,value].

# tricontour.contour(data[, value])

Returns a contour, as a MultiPolygon in GeoJSON format, containing all points with a value larger or equal to value. The value is indicated as geometry.value

# tricontour.contours(data)

Returns an iterable over the contours.

# tricontour.isobands(data)

Returns an iterable over the isobands: contours between pairs of consecutive threshold values v0 (inclusive) and v1 (exclusive). geometry.value is equal to v0, geometry.valueMax to v1.

# tricontour.x([x])

Sets the x accessor. Defaults to `d => d[0]`. If x is not given, returns the current x accessor.

# tricontour.y([y])

Sets the y accessor. Defaults to `d => d[1]`. If y is not given, returns the current y accessor.

# tricontour.value([value])

Sets the value accessor. Defaults to `d => d[2]`. Values must be defined and finite. If value is not given, returns the current value accessor.

# tricontour.thresholds([thresholds])

Sets the thresholds, either explicitly as an array of values, or as a count that will be passed to d3.ticks. If empty, returns the current thresholds.

The following are experimental

# tricontour.triangulate([triangulate])

Sets the triangulate function. Defaults to d3.Delaunay.from. See UK tricontours for a detailed example.

# tricontour.pointInterpolate([pointInterpolate])

Sets the pointInterpolate function. Arguments: i, j, 0≤a<1. Defaults to linear interpolation between the coordinates of points i and j. See Spherical tricontour for a detailed example.

# tricontour.ringsort([ringsort])

Sets the ringsort function. See Spherical tricontour for a detailed example.

Keywords

FAQs

Package last updated on 28 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc