{"id":16836941,"url":"https://github.com/fil/d3-tricontour","last_synced_at":"2025-03-17T04:32:54.617Z","repository":{"id":47451620,"uuid":"204290022","full_name":"Fil/d3-tricontour","owner":"Fil","description":"Create contours from non-gridded data with meandering triangles.","archived":false,"fork":false,"pushed_at":"2023-07-18T20:26:27.000Z","size":448,"stargazers_count":36,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-18T13:23:25.006Z","etag":null,"topics":["contours","d3","d3-module","delaunay","triangulation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-08-25T12:17:44.000Z","updated_at":"2024-02-22T10:33:24.000Z","dependencies_parsed_at":"2023-02-06T09:15:50.440Z","dependency_job_id":"d4cf66ac-6023-4273-9f11-8ffa674fce62","html_url":"https://github.com/Fil/d3-tricontour","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.05882352941176472,"last_synced_commit":"d3a73521563413a0ccbeff412d87e65a13f1dac6"},"previous_names":["fil/tricontours"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fd3-tricontour","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fd3-tricontour/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fd3-tricontour/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fil%2Fd3-tricontour/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fil","download_url":"https://codeload.github.com/Fil/d3-tricontour/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221672070,"owners_count":16861366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contours","d3","d3-module","delaunay","triangulation"],"created_at":"2024-10-13T12:15:28.893Z","updated_at":"2024-10-27T11:58:37.000Z","avatar_url":"https://github.com/Fil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# d3-tricontour\n\nThis library computes contour polygons by applying [meandering triangles](https://blog.bruce-hill.com/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](https://github.com/d3/d3-contour) instead. To compute contours on geographic data, see [d3.geoContour](https://github.com/Fil/d3-geo-voronoi/blob/main/README.md#contours).\n\nFor examples, see the [tricontours collection](https://observablehq.com/collection/@fil/tricontours) on Observable.\n\n## Installing\n\nIf you use npm, `npm install d3-tricontour`. You can also download the [latest release on GitHub](https://github.com/d3/d3-tricontour/releases/latest). For vanilla HTML in modern browsers, import d3-tricontour from Skypack:\n\n```html\n\u003cscript type=\"module\"\u003e\nimport {tricontour} from \"https://cdn.skypack.dev/d3-tricontour@1\";\n\u003c/script\u003e\n```\n\nFor legacy environments, you can load d3-tricontour’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/d3-scale@4\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/d3-delaunay@6\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/d3-tricontour@1\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\nconst tric = d3.tricontour();\nconst contours = tric([[0, 0, 1], [1, 1, 0], [2, 0, 1]]);\n\u003e Array(11) [ {type: \"MultiPolygon\", coordinates: Array(1), value: 0} … ]\n  \n\u003c/script\u003e\n```\n\n## API Reference\n\nThe API of tricontour is similar to that of [d3-contour](https://github.com/d3/d3-contour):\n\n\u003ca href=\"#tricontour\" name=\"tricontour\"\u003e#\u003c/a\u003e \u003cb\u003ed3.tricontour\u003c/b\u003e() · [Source](https://github.com/Fil/d3-tricontour/blob/main/src/tricontour.js), [Examples](https://observablehq.com/collection/@fil/tricontours)\n\nConstructs a new tricontour generator with the default settings.\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour.jpg\" alt=\"tricontours\" width=\"320\"\u003e](https://observablehq.com/@fil/tricontours)\n\n\n\u003ca href=\"#_tricontour\" name=\"_tricontour\"\u003e#\u003c/a\u003e _tricontour_(_data_) · [Examples](https://observablehq.com/@fil/tricontours)\n\nReturns 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.\n\nThe _data_ is passed as an array of points, by default with the format [x, y, value].\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour-flower.jpg\" alt=\"tricontours flower\" width=\"320\"\u003e](https://observablehq.com/@fil/tricontour-flower)\n\n\n\n\u003ca href=\"#contour\" name=\"contour\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003econtour\u003c/b\u003e(_data_[, _threshold_])\n\nReturns 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 \n\n\u003ca href=\"#contours\" name=\"contours\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003econtours\u003c/b\u003e(_data_)\n\nReturns an iterable over the contours.\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour-iterator.jpg\" alt=\"iterable\" width=\"320\"\u003e](https://observablehq.com/@fil/tricontour-iterator)\n\n\n\u003ca href=\"#isobands\" name=\"isobands\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003eisobands\u003c/b\u003e(_data_)\n\nReturns 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_.\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour-isobands.jpg\" alt=\"isobands\" width=\"320\"\u003e](https://observablehq.com/@fil/tricontour-isobands)\n\n\n\u003ca href=\"#x\" name=\"x\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003ex\u003c/b\u003e([_x_])\n\nSets the *x* accessor. Defaults to \\`d =\u003e d[0]\\`. If _x_ is not given, returns the current x accessor.\n\n\u003ca href=\"#y\" name=\"y\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003ey\u003c/b\u003e([_y_])\n\nSets the *y* accessor. Defaults to \\`d =\u003e d[1]\\`. If _y_ is not given, returns the current y accessor.\n\n\u003ca href=\"#value\" name=\"value\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003evalue\u003c/b\u003e([_value_])\n\nSets the *value* accessor. Defaults to \\`d =\u003e d[2]\\`. Values must be defined and finite. If _value_ is not given, returns the current value accessor.\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour-hexbin.jpg\" alt=\"hexbin heatmap\" width=\"320\"\u003e](https://observablehq.com/@fil/d3-hexbin-tricontours-heatmap)\n\n\n\u003ca href=\"#thresholds\" name=\"thresholds\"\u003e#\u003c/a\u003e  _tricontour_.\u003cb\u003ethresholds\u003c/b\u003e([_thresholds_])\n\nSets 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.\n\n\n_The following are experimental_\n\nThese methods are used in d3-geo-voronoi’s [geoContour](https://github.com/Fil/d3-geo-voronoi/blob/main/README.md#contours).\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/geocontour.jpg\" alt=\"geoContour\" width=\"320\"\u003e](https://observablehq.com/@fil/spherical-contours)\n\n\n\u003ca href=\"#triangulate\" name=\"triangulate\"\u003e#\u003c/a\u003e  _tricontour_.\u003cb\u003etriangulate\u003c/b\u003e([_triangulate_])\n\nSets the *triangulate* function. Defaults to d3.Delaunay.from. See [Reusing a  tricontour triangulation](https://observablehq.com/@fil/reusing-a-tricontour-triangulation) and [UK tricontour](https://observablehq.com/@fil/tricontours-with-a-personalized-triangulation) for detailed examples.\n\n[\u003cimg src=\"https://raw.githubusercontent.com/Fil/d3-tricontour/main/img/tricontour-triangulation.jpg\" alt=\"UK tricontour\" width=\"320\"\u003e](https://observablehq.com/@fil/tricontours-with-a-personalized-triangulation)\n\n\n\u003ca href=\"#pointInterpolate\" name=\"pointInterpolate\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003epointInterpolate\u003c/b\u003e(_[pointInterpolate]_)\n\nSets the *pointInterpolate* function. Arguments: *i*, *j*, *0≤a\u003c1*. Defaults to linear interpolation between the coordinates of points *i* and *j*.\n\n\u003ca href=\"#ringsort\" name=\"ringsort\"\u003e#\u003c/a\u003e _tricontour_.\u003cb\u003eringsort\u003c/b\u003e(_[ringsort]_)\n\nSets the *ringsort* function.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffil%2Fd3-tricontour","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffil%2Fd3-tricontour","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffil%2Fd3-tricontour/lists"}