npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-tricontour

v1.0.2

Published

Create contours from non-gridded data with meandering triangles.

Downloads

182,567

Readme

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. To compute contours on geographic data, see d3.geoContour.

For examples, see the tricontours collection on Observable.

Installing

If you use npm, npm install d3-tricontour. You can also download the latest release on GitHub. For vanilla HTML in modern browsers, import d3-tricontour from Skypack:

<script type="module">
import {tricontour} from "https://cdn.skypack.dev/d3-tricontour@1";
</script>

For legacy environments, you can load d3-tricontour’s UMD bundle from an npm-based CDN such as jsDelivr; a d3 global is exported:

<script src="https://cdn.jsdelivr.net/npm/d3-scale@4"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-delaunay@6"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-tricontour@1"></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) · Examples

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[, threshold])

Returns a contour, as a MultiPolygon in GeoJSON format, containing all points with a value larger or equal to threshold. The threshold 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

These methods are used in d3-geo-voronoi’s geoContour.

# tricontour.triangulate([triangulate])

Sets the triangulate function. Defaults to d3.Delaunay.from. See Reusing a tricontour triangulation and UK tricontour for detailed examples.

# 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.

# tricontour.ringsort([ringsort])

Sets the ringsort function.