pax_global_header 0000666 0000000 0000000 00000000064 13340073622 0014512 g ustar 00root root 0000000 0000000 52 comment=02f04614482e90efc47ff23271f50cca2a02d140
d3-contour-1.3.2/ 0000775 0000000 0000000 00000000000 13340073622 0013512 5 ustar 00root root 0000000 0000000 d3-contour-1.3.2/.eslintrc.json 0000664 0000000 0000000 00000000404 13340073622 0016304 0 ustar 00root root 0000000 0000000 {
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"rules": {
"no-cond-assign": 0,
"no-unexpected-multiline": 0
}
}
d3-contour-1.3.2/.gitignore 0000664 0000000 0000000 00000000077 13340073622 0015506 0 ustar 00root root 0000000 0000000 *.sublime-workspace
.DS_Store
dist/
node_modules
npm-debug.log
d3-contour-1.3.2/.npmignore 0000664 0000000 0000000 00000000042 13340073622 0015505 0 ustar 00root root 0000000 0000000 *.sublime-*
dist/*.zip
img/
test/
d3-contour-1.3.2/LICENSE 0000664 0000000 0000000 00000002703 13340073622 0014521 0 ustar 00root root 0000000 0000000 Copyright 2012-2017 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-contour-1.3.2/README.md 0000664 0000000 0000000 00000036640 13340073622 0015002 0 ustar 00root root 0000000 0000000 # d3-contour
This library computes contour polygons by applying [marching squares](https://en.wikipedia.org/wiki/Marching_squares) to a rectangular array of numeric values. For example, here is Maungawhau’s topology (the classic `volcano` dataset and `terrain.colors` from R):
[
](https://bl.ocks.org/mbostock/4241134)
For each [threshold value](#contours_thresholds), the [contour generator](#_contours) constructs a GeoJSON MultiPolygon geometry object representing the area where the input values are greater than or equal to the threshold value. The geometry is in planar coordinates, where ⟨i + 0.5, j + 0.5⟩ corresponds to element i + jn in the input values array. Here is an example that loads a GeoTIFF of surface temperatures, and another that blurs a noisy monochrome PNG to produce smooth contours of cloud fraction:
[
](https://bl.ocks.org/mbostock/4886c227038510f1c103ce305bef6fcc)
[
](https://bl.ocks.org/mbostock/818053c76d79d4841790c332656bf9da)
Since the contour polygons are GeoJSON, you can transform and display them using standard tools; see [d3.geoPath](https://github.com/d3/d3-geo/blob/master/README.md#geoPath), [d3.geoProject](https://github.com/d3/d3-geo-projection/blob/master/README.md#geoProject) and [d3.geoStitch](https://github.com/d3/d3-geo-projection/blob/master/README.md#geoStitch), for example. Here the above contours of surface temperature are displayed in the Natural Earth projection:
[
](https://bl.ocks.org/mbostock/83c0be21dba7602ee14982b020b12f51)
Contour plots can also visualize continuous functions by sampling. Here is the Goldstein–Price function (a test function for global optimization) and a trippy animation of *sin*(*x* + *y*)*sin*(*x* - *y*):
[
](https://bl.ocks.org/mbostock/f48ff9c1af4d637c9a518727f5fdfef5)
[
](https://bl.ocks.org/mbostock/bf2f5f02b62b5b3bb92ae1b59b53da36)
Contours can also show the [estimated density](#density-estimation) of point clouds, which is especially useful to avoid overplotting in large datasets. This library implements fast two-dimensional kernel density estimation; see [d3.contourDensity](#contourDensity). Here is a scatterplot showing the relationship between the idle duration and eruption duration for Old Faithful:
[
](https://bl.ocks.org/mbostock/e3f4376d54e02d5d43ae32a7cf0e6aa9)
And here is a density contour plot showing the relationship between the weight and price of 53,940 diamonds:
[
](https://bl.ocks.org/mbostock/7f5f22524bd1d824dd53c535eda0187f)
## Installing
If you use NPM, `npm install d3-contour`. Otherwise, download the [latest release](https://github.com/d3/d3-contour/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-contour.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
```
[Try d3-contour in your browser.](https://tonicdev.com/npm/d3-contour)
## API Reference
# d3.contours() [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
Constructs a new contour generator with the default settings.
# contours(values) [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
Computes the contours for the given array of *values*, returning an array of [GeoJSON](http://geojson.org/geojson-spec.html) [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon) [geometry objects](http://geojson.org/geojson-spec.html#geometry-objects). Each geometry object represents the area where the input values are greater than or equal to the corresponding [threshold value](#contours_thresholds); the threshold value for each geometry object is exposed as geometry.value.
The input *values* must be an array of length n×m where [n, m] is the contour generator’s [size](#contours_size); furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩. For example, to construct a 256×256 grid for the [Goldstein–Price function](https://en.wikipedia.org/wiki/Test_functions_for_optimization) where -2 ≤ x ≤ 2 and -2 ≤ y ≤ 1:
```js
var n = 256, m = 256, values = new Array(n * m);
for (var j = 0.5, k = 0; j < m; ++j) {
for (var i = 0.5; i < n; ++i, ++k) {
values[k] = goldsteinPrice(i / n * 4 - 2, 1 - j / m * 3);
}
}
function goldsteinPrice(x, y) {
return (1 + Math.pow(x + y + 1, 2) * (19 - 14 * x + 3 * x * x - 14 * y + 6 * x * x + 3 * y * y))
* (30 + Math.pow(2 * x - 3 * y, 2) * (18 - 32 * x + 12 * x * x + 48 * y - 36 * x * y + 27 * y * y));
}
```
The returned geometry objects are typically passed to [d3.geoPath](https://github.com/d3/d3-geo/blob/master/README.md#geoPath) to display, using null or [d3.geoIdentity](https://github.com/d3/d3-geo/blob/master/README.md#geoIdentity) as the associated projection.
# contours.contour(values, threshold) [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
Computes a single contour, returning a [GeoJSON](http://geojson.org/geojson-spec.html) [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon) [geometry object](http://geojson.org/geojson-spec.html#geometry-objects) representing the area where the input values are greater than or equal to the given [*threshold* value](#contours_thresholds); the threshold value for each geometry object is exposed as geometry.value.
The input *values* must be an array of length n×m where [n, m] is the contour generator’s [size](#contours_size); furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩. See [*contours*](#_contours) for an example.
# contours.size([size]) [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
If *size* is specified, sets the expected size of the input *values* grid to the [contour generator](#_contour) and returns the contour generator. The *size* is specified as an array \[n, m\] where n is the number of columns in the grid and m is the number of rows; *n* and *m* must be positive integers. If *size* is not specified, returns the current size which defaults to [1, 1].
# contours.smooth([smooth]) [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
If *smooth* is specified, sets whether or not the generated contour polygons are smoothed using linear interpolation. If *smooth* is not specified, returns the current smoothing flag, which defaults to true.
# contours.thresholds([thresholds]) [<>](https://github.com/d3/d3-contour/blob/master/src/contours.js "Source")
If *thresholds* is specified, sets the threshold generator to the specified function or array and returns this contour generator. If *thresholds* is not specified, returns the current threshold generator, which by default implements [Sturges’ formula](https://github.com/d3/d3-array/blob/master/README.md#thresholdSturges).
Thresholds are defined as an array of values [*x0*, *x1*, …]. The first [generated contour](#_contour) corresponds to the area where the input values are greater than or equal to *x0*; the second contour corresponds to the area where the input values are greater than or equal to *x1*, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as geometry.value.
If a *count* is specified instead of an array of *thresholds*, then the input values’ [extent](https://github.com/d3/d3-array/blob/master/README.md#extent) will be uniformly divided into approximately *count* bins; see [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks).
## Density Estimation
# d3.contourDensity() [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
Constructs a new density estimator with the default settings.
# density(data) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
Estimates the density contours for the given array of *data*, returning an array of [GeoJSON](http://geojson.org/geojson-spec.html) [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon) [geometry objects](http://geojson.org/geojson-spec.html#geometry-objects). Each geometry object represents the area where the estimated number of points per square pixel is greater than or equal to the corresponding [threshold value](#density_thresholds); the threshold value for each geometry object is exposed as geometry.value. The returned geometry objects are typically passed to [d3.geoPath](https://github.com/d3/d3-geo/blob/master/README.md#geoPath) to display, using null or [d3.geoIdentity](https://github.com/d3/d3-geo/blob/master/README.md#geoIdentity) as the associated projection. See also [d3.contours](#contours).
The *x*- and *y*-coordinate for each data point are computed using [*density*.x](#density_x) and [*density*.y](#density_y). In addition, [*density*.weight](#density_weight) indicates the relative contribution of each data point (default 1). The generated contours are only accurate within the estimator’s [defined size](#density_size).
# density.x([x]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *x* is specified, sets the *x*-coordinate accessor. If *x* is not specified, returns the current *x*-coordinate accessor, which defaults to:
```js
function x(d) {
return d[0];
}
```
# density.y([y]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *y* is specified, sets the *y*-coordinate accessor. If *y* is not specified, returns the current *y*-coordinate accessor, which defaults to:
```js
function y(d) {
return d[1];
}
```
# density.weight([weight]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *weight* is specified, sets the accessor for point weights. If *weight* is not specified, returns the current point weight accessor, which defaults to:
```js
function weight() {
return 1;
}
```
# density.size([size]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *size* is specified, sets the size of the density estimator to the specified bounds and returns the estimator. The *size* is specified as an array \[width, height\], where width is the maximum *x*-value and height is the maximum *y*-value. If *size* is not specified, returns the current size which defaults to [960, 500]. The [estimated density contours](#_density) are only accurate within the defined size.
# density.cellSize([cellSize]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *cellSize* is specified, sets the size of individual cells in the underlying bin grid to the specified positive integer and returns the estimator. If *cellSize* is not specified, returns the current cell size, which defaults to 4. The cell size is rounded down to the nearest power of two. Smaller cells produce more detailed contour polygons, but are more expensive to compute.
# density.thresholds([thresholds]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *thresholds* is specified, sets the threshold generator to the specified function or array and returns this contour generator. If *thresholds* is not specified, returns the current threshold generator, which by default generates about twenty nicely-rounded density thresholds.
Thresholds are defined as an array of values [*x0*, *x1*, …]. The first [generated density contour](#_density) corresponds to the area where the estimated density is greater than or equal to *x0*; the second contour corresponds to the area where the estimated density is greater than or equal to *x1*, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as geometry.value. The first value *x0* should typically be greater than zero.
If a *count* is specified instead of an array of *thresholds*, then approximately *count* uniformly-spaced nicely-rounded thresholds will be generated; see [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks).
# density.bandwidth([bandwidth]) [<>](https://github.com/d3/d3-contour/blob/master/src/density.js "Source")
If *bandwidth* is specified, sets the bandwidth (the standard deviation) of the Gaussian kernel and returns the estimate. If *bandwidth* is not specified, returns the current bandwidth, which defaults to 20.4939…. The specified *bandwidth* is currently rounded to the nearest supported value by this implementation, and must be nonnegative.
d3-contour-1.3.2/d3-contour.sublime-project 0000664 0000000 0000000 00000000524 13340073622 0020536 0 ustar 00root root 0000000 0000000 {
"folders": [
{
"path": ".",
"file_exclude_patterns": ["*.sublime-workspace"],
"folder_exclude_patterns": ["dist"]
}
],
"build_systems": [
{
"name": "yarn test",
"cmd": ["yarn", "test"],
"file_regex": "\\((...*?):([0-9]*):([0-9]*)\\)",
"working_dir": "$project_path"
}
]
}
d3-contour-1.3.2/img/ 0000775 0000000 0000000 00000000000 13340073622 0014266 5 ustar 00root root 0000000 0000000 d3-contour-1.3.2/img/clouds.png 0000664 0000000 0000000 00005313655 13340073622 0016307 0 ustar 00root root 0000000 0000000 PNG
IHDR (t iCCPICC Profile HWXS[R -)wW#l$@(]Tp"+ ذ+`TTVł
7)k;79Nf PaJ 1A̤& @(
pg> &rJ_(sB6 H4i!; |A! N7U/C
A gHI&.bo TK7(99<>5{3YCl"bӴd-fxL+cKsٟ'a?%7G4>LAp8gX01BOX<^fel` ?b-xc $p /F-D,䆌Z0 v&14pqf\'z 0L1(F
+f$k^3ゥXW>Ɓr8\~7F[-j9A1:cEcWaI=bFz_'冣 "8@At& d .i<%3|O@8+"2>@dH
Bk➸;p.SqlUb џL$`C9p s-)pKIL^Lza@Yvi0
nY;⾸\X03sV>^\Q"m1w5w؏rv;]ڱN`X'vL;ቤVpˆqxc66M66X%[_\/a!wvc˟#ed2}ne֖L;[g {txÐ7]I \ˠ2㛎e ѧ }clHoǀ _(¯B `
Nx
@H3`3A.<A)(kFPAh9pt~w`ABC!x"H8$#HGDJEUQm>hNG3]B+:tڌB/7^:Lc`zaQX
XVa6;_zA#N8l _ī?_!+F"X!$BaPAE8B8~;" wL"%$n!'$I$ɂA"HRf UR?YK#S|r ||<"$g$&%Ǒ#Zn\~2ńAdQS*)(g))o]W 'B5QQEUzIfL
ihӴ
tkBjf
/}g(+V(R8$dRZTtTҰ2]V9J9WynUH****;TNf%sHOK/XO]KoDD?^DA!C]yMw\267zolbh̸III}Siiu3Yns<ӼjdbcIt[YZ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