BOC v1.0: RS256 auth, Ledger integration, Prometheus metrics, CI/CD, backup

This commit is contained in:
Bernt
2026-07-28 23:08:32 +00:00
parent 0b4f160af1
commit af874040ca
11541 changed files with 1654104 additions and 1103 deletions
+81
View File
@@ -0,0 +1,81 @@
# victory-vendor
## 36.9.2
## 36.9.1
## 36.9.0
## 36.8.6
## 36.8.5
### Patch Changes
- Replace instances of lodash.assign with Object.assign ([#2757](https://github.com/FormidableLabs/victory/pull/2757))
## 36.8.4
## 36.8.3
## 36.8.2
## 36.8.1
## 36.8.0
## 36.7.0
## 36.6.12
## 36.6.11
## 36.6.10
### Patch Changes
- Setup NPM Provenance ([#2590](https://github.com/FormidableLabs/victory/pull/2590))
## 36.6.9
### Patch Changes
- Setup NPM Provenance ([#2587](https://github.com/FormidableLabs/victory/pull/2587))
## 36.6.8
## 36.6.7
## 36.6.6
## 36.6.5
### Patch Changes
- Export types directly from d3-\* (fixes [#2439](https://github.com/FormidableLabs/victory/issues/2439)) ([#2440](https://github.com/FormidableLabs/victory/pull/2440))
## 36.6.4
### Patch Changes
- Allow data accessors to accept any data types (fixes [#2360](https://github.com/FormidableLabs/victory/issues/2360)) ([#2436](https://github.com/FormidableLabs/victory/pull/2436))
## 36.6.3
### Patch Changes
- Do not generate \*.js.map sourcemaps (fixes [#2346](https://github.com/FormidableLabs/victory/issues/2346)) ([#2432](https://github.com/FormidableLabs/victory/pull/2432))
## 36.6.2
## 36.6.1
## 36.6.0
### Patch Changes
- Update source code with minor lint-based improvements (see [#2236](https://github.com/FormidableLabs/victory/issues/2236)). ([#2403](https://github.com/FormidableLabs/victory/pull/2403))
## 36.5.3 and earlier
Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
+70
View File
@@ -0,0 +1,70 @@
# VictoryVendor
Vendored dependencies for Victory.
## Background
D3 has released most of its libraries as ESM-only. This means that consumers in Node.js applications can no longer just `require()` anything with a d3 transitive dependency, including much of Victory.
To help provide an easy path to folks still using CommonJS in their Node.js applications that consume Victory, we now provide this package to vendor in various d3-related packages.
## Packages
We presently provide the following top-level libraries:
<!-- cat packages/victory-vendor/package.json | egrep '"d3-' | egrep -o 'd3-[^"]*'| sor t-->
- d3-ease
- d3-interpolate
- d3-scale
- d3-shape
- d3-timer
This is the total list of top and transitive libraries we vendor:
<!-- ls packages/victory-vendor/lib-vendor | sort -->
- d3-array
- d3-color
- d3-ease
- d3-format
- d3-interpolate
- d3-path
- d3-scale
- d3-shape
- d3-time
- d3-time-format
- d3-timer
- internmap
Note that this does _not_ include the following D3 libraries that still support CommonJS:
- d3-voronoi
## How it works
We provide two alternate paths and behaviors -- for ESM and CommonJS
### ESM
If you do a Node.js import like:
```js
import { interpolate } from "victory-vendor/d3-interpolate";
```
under the hood it's going to just re-export and pass you through to `node_modules/d3-interpolate`, the **real** ESM library from D3.
### CommonJS
If you do a Node.js import like:
```js
const { interpolate } = require("victory-vendor/d3-interpolate");
```
under the hood it's going to will go to an alternate path that contains the transpiled version of the underlying d3 library to be found at `victory-vendor/lib-vendor/d3-interpolate/**/*.js`. This futher has internally consistent import references to other `victory-vendor/lib-vendor/<pkg-name>` paths.
Note that for some tooling (like Jest) that doesn't play well with `package.json:exports` routing to this CommonJS path, we **also** output a root file in the form of `victory-vendor/d3-interpolate.js`.
## Licenses
This project is released under the MIT license, but the vendor'ed in libraries include other licenses (e.g. ISC) that we enumerate in our `package.json:license` field.
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-array` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-array";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-array` (CommonJS)
// See upstream license: https://github.com/d3/d3-array/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-array");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-ease` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-ease";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-ease` (CommonJS)
// See upstream license: https://github.com/d3/d3-ease/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-ease");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-interpolate` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-interpolate";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-interpolate` (CommonJS)
// See upstream license: https://github.com/d3/d3-interpolate/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-interpolate");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-scale` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-scale";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-scale` (CommonJS)
// See upstream license: https://github.com/d3/d3-scale/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-scale");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-shape` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-shape";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-shape` (CommonJS)
// See upstream license: https://github.com/d3/d3-shape/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-shape");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-time` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-time";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-time` (CommonJS)
// See upstream license: https://github.com/d3/d3-time/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-time");
+5
View File
@@ -0,0 +1,5 @@
// `victory-vendor/d3-timer` (TypeScript)
//
// Export the type definitions for this package:
export * from "d3-timer";
+7
View File
@@ -0,0 +1,7 @@
// `victory-vendor/d3-timer` (CommonJS)
// See upstream license: https://github.com/d3/d3-timer/blob/main/LICENSE
//
// This file only exists for tooling that doesn't work yet with package.json:exports
// by proxying through the CommonJS version.
module.exports = require("./lib/d3-timer");
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-array` (ESM)
// See upstream license: https://github.com/d3/d3-array/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-array`
export * from "d3-array";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-color` (ESM)
// See upstream license: https://github.com/d3/d3-color/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-color`
export * from "d3-color";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-ease` (ESM)
// See upstream license: https://github.com/d3/d3-ease/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-ease`
export * from "d3-ease";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-format` (ESM)
// See upstream license: https://github.com/d3/d3-format/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-format`
export * from "d3-format";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-interpolate` (ESM)
// See upstream license: https://github.com/d3/d3-interpolate/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-interpolate`
export * from "d3-interpolate";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-path` (ESM)
// See upstream license: https://github.com/d3/d3-path/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-path`
export * from "d3-path";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-scale` (ESM)
// See upstream license: https://github.com/d3/d3-scale/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-scale`
export * from "d3-scale";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-shape` (ESM)
// See upstream license: https://github.com/d3/d3-shape/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-shape`
export * from "d3-shape";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-time-format` (ESM)
// See upstream license: https://github.com/d3/d3-time-format/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-time-format`
export * from "d3-time-format";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-time` (ESM)
// See upstream license: https://github.com/d3/d3-time/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-time`
export * from "d3-time";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-timer` (ESM)
// See upstream license: https://github.com/d3/d3-timer/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-timer`
export * from "d3-timer";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/d3-voronoi` (ESM)
// See upstream license: https://github.com/d3/d3-voronoi/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-voronoi`
export * from "d3-voronoi";
+6
View File
@@ -0,0 +1,6 @@
// `victory-vendor/internmap` (ESM)
// See upstream license: https://github.com/mbostock/internmap/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/internmap`
export * from "internmap";
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2022 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.slice = exports.map = void 0;
var array = Array.prototype;
var slice = array.slice;
exports.slice = slice;
var map = array.map;
exports.map = map;
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ascending;
function ascending(a, b) {
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
+142
View File
@@ -0,0 +1,142 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = bin;
var _array = require("./array.js");
var _bisect = _interopRequireDefault(require("./bisect.js"));
var _constant = _interopRequireDefault(require("./constant.js"));
var _extent = _interopRequireDefault(require("./extent.js"));
var _identity = _interopRequireDefault(require("./identity.js"));
var _nice = _interopRequireDefault(require("./nice.js"));
var _ticks = _interopRequireWildcard(require("./ticks.js"));
var _sturges = _interopRequireDefault(require("./threshold/sturges.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function bin() {
var value = _identity.default,
domain = _extent.default,
threshold = _sturges.default;
function histogram(data) {
if (!Array.isArray(data)) data = Array.from(data);
var i,
n = data.length,
x,
step,
values = new Array(n);
for (i = 0; i < n; ++i) {
values[i] = value(data[i], i, data);
}
var xz = domain(values),
x0 = xz[0],
x1 = xz[1],
tz = threshold(values, x0, x1); // Convert number of thresholds into uniform thresholds, and nice the
// default domain accordingly.
if (!Array.isArray(tz)) {
const max = x1,
tn = +tz;
if (domain === _extent.default) [x0, x1] = (0, _nice.default)(x0, x1, tn);
tz = (0, _ticks.default)(x0, x1, tn); // If the domain is aligned with the first tick (which it will by
// default), then we can use quantization rather than bisection to bin
// values, which is substantially faster.
if (tz[0] <= x0) step = (0, _ticks.tickIncrement)(x0, x1, tn); // If the last threshold is coincident with the domains upper bound, the
// last bin will be zero-width. If the default domain is used, and this
// last threshold is coincident with the maximum input value, we can
// extend the niced upper bound by one tick to ensure uniform bin widths;
// otherwise, we simply remove the last threshold. Note that we dont
// coerce values or the domain to numbers, and thus must be careful to
// compare order (>=) rather than strict equality (===)!
if (tz[tz.length - 1] >= x1) {
if (max >= x1 && domain === _extent.default) {
const step = (0, _ticks.tickIncrement)(x0, x1, tn);
if (isFinite(step)) {
if (step > 0) {
x1 = (Math.floor(x1 / step) + 1) * step;
} else if (step < 0) {
x1 = (Math.ceil(x1 * -step) + 1) / -step;
}
}
} else {
tz.pop();
}
}
} // Remove any thresholds outside the domain.
var m = tz.length;
while (tz[0] <= x0) tz.shift(), --m;
while (tz[m - 1] > x1) tz.pop(), --m;
var bins = new Array(m + 1),
bin; // Initialize bins.
for (i = 0; i <= m; ++i) {
bin = bins[i] = [];
bin.x0 = i > 0 ? tz[i - 1] : x0;
bin.x1 = i < m ? tz[i] : x1;
} // Assign data to bins by value, ignoring any outside the domain.
if (isFinite(step)) {
if (step > 0) {
for (i = 0; i < n; ++i) {
if ((x = values[i]) != null && x0 <= x && x <= x1) {
bins[Math.min(m, Math.floor((x - x0) / step))].push(data[i]);
}
}
} else if (step < 0) {
for (i = 0; i < n; ++i) {
if ((x = values[i]) != null && x0 <= x && x <= x1) {
const j = Math.floor((x0 - x) * step);
bins[Math.min(m, j + (tz[j] <= x))].push(data[i]); // handle off-by-one due to rounding
}
}
}
} else {
for (i = 0; i < n; ++i) {
if ((x = values[i]) != null && x0 <= x && x <= x1) {
bins[(0, _bisect.default)(tz, x, 0, m)].push(data[i]);
}
}
}
return bins;
}
histogram.value = function (_) {
return arguments.length ? (value = typeof _ === "function" ? _ : (0, _constant.default)(_), histogram) : value;
};
histogram.domain = function (_) {
return arguments.length ? (domain = typeof _ === "function" ? _ : (0, _constant.default)([_[0], _[1]]), histogram) : domain;
};
histogram.thresholds = function (_) {
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? (0, _constant.default)(_array.slice.call(_)) : (0, _constant.default)(_), histogram) : threshold;
};
return histogram;
}
+24
View File
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.bisectRight = exports.bisectLeft = exports.bisectCenter = void 0;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _bisector = _interopRequireDefault(require("./bisector.js"));
var _number = _interopRequireDefault(require("./number.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const ascendingBisect = (0, _bisector.default)(_ascending.default);
const bisectRight = ascendingBisect.right;
exports.bisectRight = bisectRight;
const bisectLeft = ascendingBisect.left;
exports.bisectLeft = bisectLeft;
const bisectCenter = (0, _bisector.default)(_number.default).center;
exports.bisectCenter = bisectCenter;
var _default = bisectRight;
exports.default = _default;
+73
View File
@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = bisector;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _descending = _interopRequireDefault(require("./descending.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function bisector(f) {
let compare1, compare2, delta; // If an accessor is specified, promote it to a comparator. In this case we
// can test whether the search value is (self-) comparable. We cant do this
// for a comparator (except for specific, known comparators) because we cant
// tell if the comparator is symmetric, and an asymmetric comparator cant be
// used to test whether a single value is comparable.
if (f.length !== 2) {
compare1 = _ascending.default;
compare2 = (d, x) => (0, _ascending.default)(f(d), x);
delta = (d, x) => f(d) - x;
} else {
compare1 = f === _ascending.default || f === _descending.default ? f : zero;
compare2 = f;
delta = f;
}
function left(a, x, lo = 0, hi = a.length) {
if (lo < hi) {
if (compare1(x, x) !== 0) return hi;
do {
const mid = lo + hi >>> 1;
if (compare2(a[mid], x) < 0) lo = mid + 1;else hi = mid;
} while (lo < hi);
}
return lo;
}
function right(a, x, lo = 0, hi = a.length) {
if (lo < hi) {
if (compare1(x, x) !== 0) return hi;
do {
const mid = lo + hi >>> 1;
if (compare2(a[mid], x) <= 0) lo = mid + 1;else hi = mid;
} while (lo < hi);
}
return lo;
}
function center(a, x, lo = 0, hi = a.length) {
const i = left(a, x, lo, hi - 1);
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
}
return {
left,
center,
right
};
}
function zero() {
return 0;
}
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = constant;
function constant(x) {
return () => x;
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = count;
function count(values, valueof) {
let count = 0;
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
++count;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
++count;
}
}
}
return count;
}
+42
View File
@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cross;
function length(array) {
return array.length | 0;
}
function empty(length) {
return !(length > 0);
}
function arrayify(values) {
return typeof values !== "object" || "length" in values ? values : Array.from(values);
}
function reducer(reduce) {
return values => reduce(...values);
}
function cross(...values) {
const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop());
values = values.map(arrayify);
const lengths = values.map(length);
const j = values.length - 1;
const index = new Array(j + 1).fill(0);
const product = [];
if (j < 0 || lengths.some(empty)) return product;
while (true) {
product.push(index.map((j, i) => values[i][j]));
let i = j;
while (++index[i] === lengths[i]) {
if (i === 0) return reduce ? product.map(reduce) : product;
index[i--] = 0;
}
}
}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cumsum;
function cumsum(values, valueof) {
var sum = 0,
index = 0;
return Float64Array.from(values, valueof === undefined ? v => sum += +v || 0 : v => sum += +valueof(v, index++, values) || 0);
}
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = descending;
function descending(a, b) {
return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
}
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = deviation;
var _variance = _interopRequireDefault(require("./variance.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function deviation(values, valueof) {
const v = (0, _variance.default)(values, valueof);
return v ? Math.sqrt(v) : v;
}
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = difference;
var _index = require("../../../lib-vendor/internmap/src/index.js");
function difference(values, ...others) {
values = new _index.InternSet(values);
for (const other of others) {
for (const value of other) {
values.delete(value);
}
}
return values;
}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = disjoint;
var _index = require("../../../lib-vendor/internmap/src/index.js");
function disjoint(values, other) {
const iterator = other[Symbol.iterator](),
set = new _index.InternSet();
for (const v of values) {
if (set.has(v)) return false;
let value, done;
while (({
value,
done
} = iterator.next())) {
if (done) break;
if (Object.is(v, value)) return false;
set.add(value);
}
}
return true;
}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = every;
function every(values, test) {
if (typeof test !== "function") throw new TypeError("test is not a function");
let index = -1;
for (const value of values) {
if (!test(value, ++index, values)) {
return false;
}
}
return true;
}
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = extent;
function extent(values, valueof) {
let min;
let max;
if (valueof === undefined) {
for (const value of values) {
if (value != null) {
if (min === undefined) {
if (value >= value) min = max = value;
} else {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null) {
if (min === undefined) {
if (value >= value) min = max = value;
} else {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
}
return [min, max];
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = filter;
function filter(values, test) {
if (typeof test !== "function") throw new TypeError("test is not a function");
const array = [];
let index = -1;
for (const value of values) {
if (test(value, ++index, values)) {
array.push(value);
}
}
return array;
}
+93
View File
@@ -0,0 +1,93 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Adder = void 0;
exports.fcumsum = fcumsum;
exports.fsum = fsum;
// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423
class Adder {
constructor() {
this._partials = new Float64Array(32);
this._n = 0;
}
add(x) {
const p = this._partials;
let i = 0;
for (let j = 0; j < this._n && j < 32; j++) {
const y = p[j],
hi = x + y,
lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);
if (lo) p[i++] = lo;
x = hi;
}
p[i] = x;
this._n = i + 1;
return this;
}
valueOf() {
const p = this._partials;
let n = this._n,
x,
y,
lo,
hi = 0;
if (n > 0) {
hi = p[--n];
while (n > 0) {
x = hi;
y = p[--n];
hi = x + y;
lo = y - (hi - x);
if (lo) break;
}
if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) {
y = lo * 2;
x = hi + y;
if (y == x - hi) hi = x;
}
}
return hi;
}
}
exports.Adder = Adder;
function fsum(values, valueof) {
const adder = new Adder();
if (valueof === undefined) {
for (let value of values) {
if (value = +value) {
adder.add(value);
}
}
} else {
let index = -1;
for (let value of values) {
if (value = +valueof(value, ++index, values)) {
adder.add(value);
}
}
}
return +adder;
}
function fcumsum(values, valueof) {
const adder = new Adder();
let index = -1;
return Float64Array.from(values, valueof === undefined ? v => adder.add(+v || 0) : v => adder.add(+valueof(v, ++index, values) || 0));
}
+38
View File
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = greatest;
var _ascending = _interopRequireDefault(require("./ascending.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function greatest(values, compare = _ascending.default) {
let max;
let defined = false;
if (compare.length === 1) {
let maxValue;
for (const element of values) {
const value = compare(element);
if (defined ? (0, _ascending.default)(value, maxValue) > 0 : (0, _ascending.default)(value, value) === 0) {
max = element;
maxValue = value;
defined = true;
}
}
} else {
for (const value of values) {
if (defined ? compare(value, max) > 0 : compare(value, value) === 0) {
max = value;
defined = true;
}
}
}
return max;
}
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = greatestIndex;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _maxIndex = _interopRequireDefault(require("./maxIndex.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function greatestIndex(values, compare = _ascending.default) {
if (compare.length === 1) return (0, _maxIndex.default)(values, compare);
let maxValue;
let max = -1;
let index = -1;
for (const value of values) {
++index;
if (max < 0 ? compare(value, value) === 0 : compare(value, maxValue) > 0) {
maxValue = value;
max = index;
}
}
return max;
}
+85
View File
@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = group;
exports.flatGroup = flatGroup;
exports.flatRollup = flatRollup;
exports.groups = groups;
exports.index = index;
exports.indexes = indexes;
exports.rollup = rollup;
exports.rollups = rollups;
var _index = require("../../../lib-vendor/internmap/src/index.js");
var _identity = _interopRequireDefault(require("./identity.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function group(values, ...keys) {
return nest(values, _identity.default, _identity.default, keys);
}
function groups(values, ...keys) {
return nest(values, Array.from, _identity.default, keys);
}
function flatten(groups, keys) {
for (let i = 1, n = keys.length; i < n; ++i) {
groups = groups.flatMap(g => g.pop().map(([key, value]) => [...g, key, value]));
}
return groups;
}
function flatGroup(values, ...keys) {
return flatten(groups(values, ...keys), keys);
}
function flatRollup(values, reduce, ...keys) {
return flatten(rollups(values, reduce, ...keys), keys);
}
function rollup(values, reduce, ...keys) {
return nest(values, _identity.default, reduce, keys);
}
function rollups(values, reduce, ...keys) {
return nest(values, Array.from, reduce, keys);
}
function index(values, ...keys) {
return nest(values, _identity.default, unique, keys);
}
function indexes(values, ...keys) {
return nest(values, Array.from, unique, keys);
}
function unique(values) {
if (values.length !== 1) throw new Error("duplicate key");
return values[0];
}
function nest(values, map, reduce, keys) {
return function regroup(values, i) {
if (i >= keys.length) return reduce(values);
const groups = new _index.InternMap();
const keyof = keys[i++];
let index = -1;
for (const value of values) {
const key = keyof(value, ++index, values);
const group = groups.get(key);
if (group) group.push(value);else groups.set(key, [value]);
}
for (const [key, values] of groups) {
groups.set(key, regroup(values, i));
}
return map(groups);
}(values, 0);
}
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = groupSort;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _group = _interopRequireWildcard(require("./group.js"));
var _sort = _interopRequireDefault(require("./sort.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function groupSort(values, reduce, key) {
return (reduce.length !== 2 ? (0, _sort.default)((0, _group.rollup)(values, reduce, key), ([ak, av], [bk, bv]) => (0, _ascending.default)(av, bv) || (0, _ascending.default)(ak, bk)) : (0, _sort.default)((0, _group.default)(values, key), ([ak, av], [bk, bv]) => reduce(av, bv) || (0, _ascending.default)(ak, bk))).map(([key]) => key);
}
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = identity;
function identity(x) {
return x;
}
+567
View File
@@ -0,0 +1,567 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Adder", {
enumerable: true,
get: function () {
return _fsum.Adder;
}
});
Object.defineProperty(exports, "InternMap", {
enumerable: true,
get: function () {
return _index.InternMap;
}
});
Object.defineProperty(exports, "InternSet", {
enumerable: true,
get: function () {
return _index.InternSet;
}
});
Object.defineProperty(exports, "ascending", {
enumerable: true,
get: function () {
return _ascending.default;
}
});
Object.defineProperty(exports, "bin", {
enumerable: true,
get: function () {
return _bin.default;
}
});
Object.defineProperty(exports, "bisect", {
enumerable: true,
get: function () {
return _bisect.default;
}
});
Object.defineProperty(exports, "bisectCenter", {
enumerable: true,
get: function () {
return _bisect.bisectCenter;
}
});
Object.defineProperty(exports, "bisectLeft", {
enumerable: true,
get: function () {
return _bisect.bisectLeft;
}
});
Object.defineProperty(exports, "bisectRight", {
enumerable: true,
get: function () {
return _bisect.bisectRight;
}
});
Object.defineProperty(exports, "bisector", {
enumerable: true,
get: function () {
return _bisector.default;
}
});
Object.defineProperty(exports, "count", {
enumerable: true,
get: function () {
return _count.default;
}
});
Object.defineProperty(exports, "cross", {
enumerable: true,
get: function () {
return _cross.default;
}
});
Object.defineProperty(exports, "cumsum", {
enumerable: true,
get: function () {
return _cumsum.default;
}
});
Object.defineProperty(exports, "descending", {
enumerable: true,
get: function () {
return _descending.default;
}
});
Object.defineProperty(exports, "deviation", {
enumerable: true,
get: function () {
return _deviation.default;
}
});
Object.defineProperty(exports, "difference", {
enumerable: true,
get: function () {
return _difference.default;
}
});
Object.defineProperty(exports, "disjoint", {
enumerable: true,
get: function () {
return _disjoint.default;
}
});
Object.defineProperty(exports, "every", {
enumerable: true,
get: function () {
return _every.default;
}
});
Object.defineProperty(exports, "extent", {
enumerable: true,
get: function () {
return _extent.default;
}
});
Object.defineProperty(exports, "fcumsum", {
enumerable: true,
get: function () {
return _fsum.fcumsum;
}
});
Object.defineProperty(exports, "filter", {
enumerable: true,
get: function () {
return _filter.default;
}
});
Object.defineProperty(exports, "flatGroup", {
enumerable: true,
get: function () {
return _group.flatGroup;
}
});
Object.defineProperty(exports, "flatRollup", {
enumerable: true,
get: function () {
return _group.flatRollup;
}
});
Object.defineProperty(exports, "fsum", {
enumerable: true,
get: function () {
return _fsum.fsum;
}
});
Object.defineProperty(exports, "greatest", {
enumerable: true,
get: function () {
return _greatest.default;
}
});
Object.defineProperty(exports, "greatestIndex", {
enumerable: true,
get: function () {
return _greatestIndex.default;
}
});
Object.defineProperty(exports, "group", {
enumerable: true,
get: function () {
return _group.default;
}
});
Object.defineProperty(exports, "groupSort", {
enumerable: true,
get: function () {
return _groupSort.default;
}
});
Object.defineProperty(exports, "groups", {
enumerable: true,
get: function () {
return _group.groups;
}
});
Object.defineProperty(exports, "histogram", {
enumerable: true,
get: function () {
return _bin.default;
}
});
Object.defineProperty(exports, "index", {
enumerable: true,
get: function () {
return _group.index;
}
});
Object.defineProperty(exports, "indexes", {
enumerable: true,
get: function () {
return _group.indexes;
}
});
Object.defineProperty(exports, "intersection", {
enumerable: true,
get: function () {
return _intersection.default;
}
});
Object.defineProperty(exports, "least", {
enumerable: true,
get: function () {
return _least.default;
}
});
Object.defineProperty(exports, "leastIndex", {
enumerable: true,
get: function () {
return _leastIndex.default;
}
});
Object.defineProperty(exports, "map", {
enumerable: true,
get: function () {
return _map.default;
}
});
Object.defineProperty(exports, "max", {
enumerable: true,
get: function () {
return _max.default;
}
});
Object.defineProperty(exports, "maxIndex", {
enumerable: true,
get: function () {
return _maxIndex.default;
}
});
Object.defineProperty(exports, "mean", {
enumerable: true,
get: function () {
return _mean.default;
}
});
Object.defineProperty(exports, "median", {
enumerable: true,
get: function () {
return _median.default;
}
});
Object.defineProperty(exports, "merge", {
enumerable: true,
get: function () {
return _merge.default;
}
});
Object.defineProperty(exports, "min", {
enumerable: true,
get: function () {
return _min.default;
}
});
Object.defineProperty(exports, "minIndex", {
enumerable: true,
get: function () {
return _minIndex.default;
}
});
Object.defineProperty(exports, "mode", {
enumerable: true,
get: function () {
return _mode.default;
}
});
Object.defineProperty(exports, "nice", {
enumerable: true,
get: function () {
return _nice.default;
}
});
Object.defineProperty(exports, "pairs", {
enumerable: true,
get: function () {
return _pairs.default;
}
});
Object.defineProperty(exports, "permute", {
enumerable: true,
get: function () {
return _permute.default;
}
});
Object.defineProperty(exports, "quantile", {
enumerable: true,
get: function () {
return _quantile.default;
}
});
Object.defineProperty(exports, "quantileSorted", {
enumerable: true,
get: function () {
return _quantile.quantileSorted;
}
});
Object.defineProperty(exports, "quickselect", {
enumerable: true,
get: function () {
return _quickselect.default;
}
});
Object.defineProperty(exports, "range", {
enumerable: true,
get: function () {
return _range.default;
}
});
Object.defineProperty(exports, "rank", {
enumerable: true,
get: function () {
return _rank.default;
}
});
Object.defineProperty(exports, "reduce", {
enumerable: true,
get: function () {
return _reduce.default;
}
});
Object.defineProperty(exports, "reverse", {
enumerable: true,
get: function () {
return _reverse.default;
}
});
Object.defineProperty(exports, "rollup", {
enumerable: true,
get: function () {
return _group.rollup;
}
});
Object.defineProperty(exports, "rollups", {
enumerable: true,
get: function () {
return _group.rollups;
}
});
Object.defineProperty(exports, "scan", {
enumerable: true,
get: function () {
return _scan.default;
}
});
Object.defineProperty(exports, "shuffle", {
enumerable: true,
get: function () {
return _shuffle.default;
}
});
Object.defineProperty(exports, "shuffler", {
enumerable: true,
get: function () {
return _shuffle.shuffler;
}
});
Object.defineProperty(exports, "some", {
enumerable: true,
get: function () {
return _some.default;
}
});
Object.defineProperty(exports, "sort", {
enumerable: true,
get: function () {
return _sort.default;
}
});
Object.defineProperty(exports, "subset", {
enumerable: true,
get: function () {
return _subset.default;
}
});
Object.defineProperty(exports, "sum", {
enumerable: true,
get: function () {
return _sum.default;
}
});
Object.defineProperty(exports, "superset", {
enumerable: true,
get: function () {
return _superset.default;
}
});
Object.defineProperty(exports, "thresholdFreedmanDiaconis", {
enumerable: true,
get: function () {
return _freedmanDiaconis.default;
}
});
Object.defineProperty(exports, "thresholdScott", {
enumerable: true,
get: function () {
return _scott.default;
}
});
Object.defineProperty(exports, "thresholdSturges", {
enumerable: true,
get: function () {
return _sturges.default;
}
});
Object.defineProperty(exports, "tickIncrement", {
enumerable: true,
get: function () {
return _ticks.tickIncrement;
}
});
Object.defineProperty(exports, "tickStep", {
enumerable: true,
get: function () {
return _ticks.tickStep;
}
});
Object.defineProperty(exports, "ticks", {
enumerable: true,
get: function () {
return _ticks.default;
}
});
Object.defineProperty(exports, "transpose", {
enumerable: true,
get: function () {
return _transpose.default;
}
});
Object.defineProperty(exports, "union", {
enumerable: true,
get: function () {
return _union.default;
}
});
Object.defineProperty(exports, "variance", {
enumerable: true,
get: function () {
return _variance.default;
}
});
Object.defineProperty(exports, "zip", {
enumerable: true,
get: function () {
return _zip.default;
}
});
var _bisect = _interopRequireWildcard(require("./bisect.js"));
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _bisector = _interopRequireDefault(require("./bisector.js"));
var _count = _interopRequireDefault(require("./count.js"));
var _cross = _interopRequireDefault(require("./cross.js"));
var _cumsum = _interopRequireDefault(require("./cumsum.js"));
var _descending = _interopRequireDefault(require("./descending.js"));
var _deviation = _interopRequireDefault(require("./deviation.js"));
var _extent = _interopRequireDefault(require("./extent.js"));
var _fsum = require("./fsum.js");
var _group = _interopRequireWildcard(require("./group.js"));
var _groupSort = _interopRequireDefault(require("./groupSort.js"));
var _bin = _interopRequireDefault(require("./bin.js"));
var _freedmanDiaconis = _interopRequireDefault(require("./threshold/freedmanDiaconis.js"));
var _scott = _interopRequireDefault(require("./threshold/scott.js"));
var _sturges = _interopRequireDefault(require("./threshold/sturges.js"));
var _max = _interopRequireDefault(require("./max.js"));
var _maxIndex = _interopRequireDefault(require("./maxIndex.js"));
var _mean = _interopRequireDefault(require("./mean.js"));
var _median = _interopRequireDefault(require("./median.js"));
var _merge = _interopRequireDefault(require("./merge.js"));
var _min = _interopRequireDefault(require("./min.js"));
var _minIndex = _interopRequireDefault(require("./minIndex.js"));
var _mode = _interopRequireDefault(require("./mode.js"));
var _nice = _interopRequireDefault(require("./nice.js"));
var _pairs = _interopRequireDefault(require("./pairs.js"));
var _permute = _interopRequireDefault(require("./permute.js"));
var _quantile = _interopRequireWildcard(require("./quantile.js"));
var _quickselect = _interopRequireDefault(require("./quickselect.js"));
var _range = _interopRequireDefault(require("./range.js"));
var _rank = _interopRequireDefault(require("./rank.js"));
var _least = _interopRequireDefault(require("./least.js"));
var _leastIndex = _interopRequireDefault(require("./leastIndex.js"));
var _greatest = _interopRequireDefault(require("./greatest.js"));
var _greatestIndex = _interopRequireDefault(require("./greatestIndex.js"));
var _scan = _interopRequireDefault(require("./scan.js"));
var _shuffle = _interopRequireWildcard(require("./shuffle.js"));
var _sum = _interopRequireDefault(require("./sum.js"));
var _ticks = _interopRequireWildcard(require("./ticks.js"));
var _transpose = _interopRequireDefault(require("./transpose.js"));
var _variance = _interopRequireDefault(require("./variance.js"));
var _zip = _interopRequireDefault(require("./zip.js"));
var _every = _interopRequireDefault(require("./every.js"));
var _some = _interopRequireDefault(require("./some.js"));
var _filter = _interopRequireDefault(require("./filter.js"));
var _map = _interopRequireDefault(require("./map.js"));
var _reduce = _interopRequireDefault(require("./reduce.js"));
var _reverse = _interopRequireDefault(require("./reverse.js"));
var _sort = _interopRequireDefault(require("./sort.js"));
var _difference = _interopRequireDefault(require("./difference.js"));
var _disjoint = _interopRequireDefault(require("./disjoint.js"));
var _intersection = _interopRequireDefault(require("./intersection.js"));
var _subset = _interopRequireDefault(require("./subset.js"));
var _superset = _interopRequireDefault(require("./superset.js"));
var _union = _interopRequireDefault(require("./union.js"));
var _index = require("../../../lib-vendor/internmap/src/index.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = intersection;
var _index = require("../../../lib-vendor/internmap/src/index.js");
function intersection(values, ...others) {
values = new _index.InternSet(values);
others = others.map(set);
out: for (const value of values) {
for (const other of others) {
if (!other.has(value)) {
values.delete(value);
continue out;
}
}
}
return values;
}
function set(values) {
return values instanceof _index.InternSet ? values : new _index.InternSet(values);
}
+38
View File
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = least;
var _ascending = _interopRequireDefault(require("./ascending.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function least(values, compare = _ascending.default) {
let min;
let defined = false;
if (compare.length === 1) {
let minValue;
for (const element of values) {
const value = compare(element);
if (defined ? (0, _ascending.default)(value, minValue) < 0 : (0, _ascending.default)(value, value) === 0) {
min = element;
minValue = value;
defined = true;
}
}
} else {
for (const value of values) {
if (defined ? compare(value, min) < 0 : compare(value, value) === 0) {
min = value;
defined = true;
}
}
}
return min;
}
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = leastIndex;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _minIndex = _interopRequireDefault(require("./minIndex.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function leastIndex(values, compare = _ascending.default) {
if (compare.length === 1) return (0, _minIndex.default)(values, compare);
let minValue;
let min = -1;
let index = -1;
for (const value of values) {
++index;
if (min < 0 ? compare(value, value) === 0 : compare(value, minValue) < 0) {
minValue = value;
min = index;
}
}
return min;
}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = map;
function map(values, mapper) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
if (typeof mapper !== "function") throw new TypeError("mapper is not a function");
return Array.from(values, (value, index) => mapper(value, index, values));
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = max;
function max(values, valueof) {
let max;
if (valueof === undefined) {
for (const value of values) {
if (value != null && (max < value || max === undefined && value >= value)) {
max = value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (max < value || max === undefined && value >= value)) {
max = value;
}
}
}
return max;
}
+30
View File
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = maxIndex;
function maxIndex(values, valueof) {
let max;
let maxIndex = -1;
let index = -1;
if (valueof === undefined) {
for (const value of values) {
++index;
if (value != null && (max < value || max === undefined && value >= value)) {
max = value, maxIndex = index;
}
}
} else {
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (max < value || max === undefined && value >= value)) {
max = value, maxIndex = index;
}
}
}
return maxIndex;
}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = mean;
function mean(values, valueof) {
let count = 0;
let sum = 0;
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
++count, sum += value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
++count, sum += value;
}
}
}
if (count) return sum / count;
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = median;
var _quantile = _interopRequireDefault(require("./quantile.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function median(values, valueof) {
return (0, _quantile.default)(values, 0.5, valueof);
}
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = merge;
function* flatten(arrays) {
for (const array of arrays) {
yield* array;
}
}
function merge(arrays) {
return Array.from(flatten(arrays));
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = min;
function min(values, valueof) {
let min;
if (valueof === undefined) {
for (const value of values) {
if (value != null && (min > value || min === undefined && value >= value)) {
min = value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (min > value || min === undefined && value >= value)) {
min = value;
}
}
}
return min;
}
+30
View File
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = minIndex;
function minIndex(values, valueof) {
let min;
let minIndex = -1;
let index = -1;
if (valueof === undefined) {
for (const value of values) {
++index;
if (value != null && (min > value || min === undefined && value >= value)) {
min = value, minIndex = index;
}
}
} else {
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (min > value || min === undefined && value >= value)) {
min = value, minIndex = index;
}
}
}
return minIndex;
}
+40
View File
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = mode;
var _index = require("../../../lib-vendor/internmap/src/index.js");
function mode(values, valueof) {
const counts = new _index.InternMap();
if (valueof === undefined) {
for (let value of values) {
if (value != null && value >= value) {
counts.set(value, (counts.get(value) || 0) + 1);
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && value >= value) {
counts.set(value, (counts.get(value) || 0) + 1);
}
}
}
let modeValue;
let modeCount = 0;
for (const [value, count] of counts) {
if (count > modeCount) {
modeCount = count;
modeValue = value;
}
}
return modeValue;
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nice;
var _ticks = require("./ticks.js");
function nice(start, stop, count) {
let prestep;
while (true) {
const step = (0, _ticks.tickIncrement)(start, stop, count);
if (step === prestep || step === 0 || !isFinite(step)) {
return [start, stop];
} else if (step > 0) {
start = Math.floor(start / step) * step;
stop = Math.ceil(stop / step) * step;
} else if (step < 0) {
start = Math.ceil(start * step) / step;
stop = Math.floor(stop * step) / step;
}
prestep = step;
}
}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = number;
exports.numbers = numbers;
function number(x) {
return x === null ? NaN : +x;
}
function* numbers(values, valueof) {
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
yield value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
yield value;
}
}
}
}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = pairs;
exports.pair = pair;
function pairs(values, pairof = pair) {
const pairs = [];
let previous;
let first = false;
for (const value of values) {
if (first) pairs.push(pairof(previous, value));
previous = value;
first = true;
}
return pairs;
}
function pair(a, b) {
return [a, b];
}
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = permute;
function permute(source, keys) {
return Array.from(keys, key => source[key]);
}
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = quantile;
exports.quantileSorted = quantileSorted;
var _max = _interopRequireDefault(require("./max.js"));
var _min = _interopRequireDefault(require("./min.js"));
var _quickselect = _interopRequireDefault(require("./quickselect.js"));
var _number = _interopRequireWildcard(require("./number.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function quantile(values, p, valueof) {
values = Float64Array.from((0, _number.numbers)(values, valueof));
if (!(n = values.length)) return;
if ((p = +p) <= 0 || n < 2) return (0, _min.default)(values);
if (p >= 1) return (0, _max.default)(values);
var n,
i = (n - 1) * p,
i0 = Math.floor(i),
value0 = (0, _max.default)((0, _quickselect.default)(values, i0).subarray(0, i0 + 1)),
value1 = (0, _min.default)(values.subarray(i0 + 1));
return value0 + (value1 - value0) * (i - i0);
}
function quantileSorted(values, p, valueof = _number.default) {
if (!(n = values.length)) return;
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
var n,
i = (n - 1) * p,
i0 = Math.floor(i),
value0 = +valueof(values[i0], i0, values),
value1 = +valueof(values[i0 + 1], i0 + 1, values);
return value0 + (value1 - value0) * (i - i0);
}
@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = quickselect;
var _sort = require("./sort.js");
// Based on https://github.com/mourner/quickselect
// ISC license, Copyright 2018 Vladimir Agafonkin.
function quickselect(array, k, left = 0, right = array.length - 1, compare) {
compare = compare === undefined ? _sort.ascendingDefined : (0, _sort.compareDefined)(compare);
while (right > left) {
if (right - left > 600) {
const n = right - left + 1;
const m = k - left + 1;
const z = Math.log(n);
const s = 0.5 * Math.exp(2 * z / 3);
const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
quickselect(array, k, newLeft, newRight, compare);
}
const t = array[k];
let i = left;
let j = right;
swap(array, left, k);
if (compare(array[right], t) > 0) swap(array, left, right);
while (i < j) {
swap(array, i, j), ++i, --j;
while (compare(array[i], t) < 0) ++i;
while (compare(array[j], t) > 0) --j;
}
if (compare(array[left], t) === 0) swap(array, left, j);else ++j, swap(array, j, right);
if (j <= k) left = j + 1;
if (k <= j) right = j - 1;
}
return array;
}
function swap(array, i, j) {
const t = array[i];
array[i] = array[j];
array[j] = t;
}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = range;
function range(start, stop, step) {
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
}
+34
View File
@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = rank;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _sort = require("./sort.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function rank(values, valueof = _ascending.default) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
let V = Array.from(values);
const R = new Float64Array(V.length);
if (valueof.length !== 2) V = V.map(valueof), valueof = _ascending.default;
const compareIndex = (i, j) => valueof(V[i], V[j]);
let k, r;
Uint32Array.from(V, (_, i) => i).sort(valueof === _ascending.default ? (i, j) => (0, _sort.ascendingDefined)(V[i], V[j]) : (0, _sort.compareDefined)(compareIndex)).forEach((j, i) => {
const c = compareIndex(j, k === undefined ? j : k);
if (c >= 0) {
if (k === undefined || c > 0) k = j, r = i;
R[j] = r;
} else {
R[j] = NaN;
}
});
return R;
}
+32
View File
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = reduce;
function reduce(values, reducer, value) {
if (typeof reducer !== "function") throw new TypeError("reducer is not a function");
const iterator = values[Symbol.iterator]();
let done,
next,
index = -1;
if (arguments.length < 3) {
({
done,
value
} = iterator.next());
if (done) return;
++index;
}
while (({
done,
value: next
} = iterator.next()), !done) {
value = reducer(value, next, ++index, values);
}
return value;
}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = reverse;
function reverse(values) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
return Array.from(values).reverse();
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = scan;
var _leastIndex = _interopRequireDefault(require("./leastIndex.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function scan(values, compare) {
const index = (0, _leastIndex.default)(values, compare);
return index < 0 ? undefined : index;
}
+26
View File
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.shuffler = shuffler;
var _default = shuffler(Math.random);
exports.default = _default;
function shuffler(random) {
return function shuffle(array, i0 = 0, i1 = array.length) {
let m = i1 - (i0 = +i0);
while (m) {
const i = random() * m-- | 0,
t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
};
}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = some;
function some(values, test) {
if (typeof test !== "function") throw new TypeError("test is not a function");
let index = -1;
for (const value of values) {
if (test(value, ++index, values)) {
return true;
}
}
return false;
}
+55
View File
@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ascendingDefined = ascendingDefined;
exports.compareDefined = compareDefined;
exports.default = sort;
var _ascending = _interopRequireDefault(require("./ascending.js"));
var _permute = _interopRequireDefault(require("./permute.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function sort(values, ...F) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
values = Array.from(values);
let [f] = F;
if (f && f.length !== 2 || F.length > 1) {
const index = Uint32Array.from(values, (d, i) => i);
if (F.length > 1) {
F = F.map(f => values.map(f));
index.sort((i, j) => {
for (const f of F) {
const c = ascendingDefined(f[i], f[j]);
if (c) return c;
}
});
} else {
f = values.map(f);
index.sort((i, j) => ascendingDefined(f[i], f[j]));
}
return (0, _permute.default)(values, index);
}
return values.sort(compareDefined(f));
}
function compareDefined(compare = _ascending.default) {
if (compare === _ascending.default) return ascendingDefined;
if (typeof compare !== "function") throw new TypeError("compare is not a function");
return (a, b) => {
const x = compare(a, b);
if (x || x === 0) return x;
return (compare(b, b) === 0) - (compare(a, a) === 0);
};
}
function ascendingDefined(a, b) {
return (a == null || !(a >= a)) - (b == null || !(b >= b)) || (a < b ? -1 : a > b ? 1 : 0);
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = subset;
var _superset = _interopRequireDefault(require("./superset.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function subset(values, other) {
return (0, _superset.default)(other, values);
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = sum;
function sum(values, valueof) {
let sum = 0;
if (valueof === undefined) {
for (let value of values) {
if (value = +value) {
sum += value;
}
}
} else {
let index = -1;
for (let value of values) {
if (value = +valueof(value, ++index, values)) {
sum += value;
}
}
}
return sum;
}
+33
View File
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = superset;
function superset(values, other) {
const iterator = values[Symbol.iterator](),
set = new Set();
for (const o of other) {
const io = intern(o);
if (set.has(io)) continue;
let value, done;
while (({
value,
done
} = iterator.next())) {
if (done) return false;
const ivalue = intern(value);
set.add(ivalue);
if (Object.is(io, ivalue)) break;
}
}
return true;
}
function intern(value) {
return value !== null && typeof value === "object" ? value.valueOf() : value;
}
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = thresholdFreedmanDiaconis;
var _count = _interopRequireDefault(require("../count.js"));
var _quantile = _interopRequireDefault(require("../quantile.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function thresholdFreedmanDiaconis(values, min, max) {
return Math.ceil((max - min) / (2 * ((0, _quantile.default)(values, 0.75) - (0, _quantile.default)(values, 0.25)) * Math.pow((0, _count.default)(values), -1 / 3)));
}
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = thresholdScott;
var _count = _interopRequireDefault(require("../count.js"));
var _deviation = _interopRequireDefault(require("../deviation.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function thresholdScott(values, min, max) {
return Math.ceil((max - min) * Math.cbrt((0, _count.default)(values)) / (3.49 * (0, _deviation.default)(values)));
}
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = thresholdSturges;
var _count = _interopRequireDefault(require("../count.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function thresholdSturges(values) {
return Math.ceil(Math.log((0, _count.default)(values)) / Math.LN2) + 1;
}
+60
View File
@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ticks;
exports.tickIncrement = tickIncrement;
exports.tickStep = tickStep;
var e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);
function ticks(start, stop, count) {
var reverse,
i = -1,
n,
ticks,
step;
stop = +stop, start = +start, count = +count;
if (start === stop && count > 0) return [start];
if (reverse = stop < start) n = start, start = stop, stop = n;
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
if (step > 0) {
let r0 = Math.round(start / step),
r1 = Math.round(stop / step);
if (r0 * step < start) ++r0;
if (r1 * step > stop) --r1;
ticks = new Array(n = r1 - r0 + 1);
while (++i < n) ticks[i] = (r0 + i) * step;
} else {
step = -step;
let r0 = Math.round(start * step),
r1 = Math.round(stop * step);
if (r0 / step < start) ++r0;
if (r1 / step > stop) --r1;
ticks = new Array(n = r1 - r0 + 1);
while (++i < n) ticks[i] = (r0 + i) / step;
}
if (reverse) ticks.reverse();
return ticks;
}
function tickIncrement(start, stop, count) {
var step = (stop - start) / Math.max(0, count),
power = Math.floor(Math.log(step) / Math.LN10),
error = step / Math.pow(10, power);
return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
}
function tickStep(start, stop, count) {
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;else if (error >= e5) step1 *= 5;else if (error >= e2) step1 *= 2;
return stop < start ? -step1 : step1;
}
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transpose;
var _min = _interopRequireDefault(require("./min.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function transpose(matrix) {
if (!(n = matrix.length)) return [];
for (var i = -1, m = (0, _min.default)(matrix, length), transpose = new Array(m); ++i < m;) {
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {
row[j] = matrix[j][i];
}
}
return transpose;
}
function length(d) {
return d.length;
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = union;
var _index = require("../../../lib-vendor/internmap/src/index.js");
function union(...others) {
const set = new _index.InternSet();
for (const other of others) {
for (const o of other) {
set.add(o);
}
}
return set;
}
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = variance;
function variance(values, valueof) {
let count = 0;
let delta;
let mean = 0;
let sum = 0;
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
delta = value - mean;
mean += delta / ++count;
sum += delta * (value - mean);
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
delta = value - mean;
mean += delta / ++count;
sum += delta * (value - mean);
}
}
}
if (count > 1) return sum / (count - 1);
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = zip;
var _transpose = _interopRequireDefault(require("./transpose.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function zip() {
return (0, _transpose.default)(arguments);
}
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2022 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+413
View File
@@ -0,0 +1,413 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Color = Color;
exports.Rgb = Rgb;
exports.darker = exports.brighter = void 0;
exports.default = color;
exports.hsl = hsl;
exports.hslConvert = hslConvert;
exports.rgb = rgb;
exports.rgbConvert = rgbConvert;
var _define = _interopRequireWildcard(require("./define.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function Color() {}
var darker = 0.7;
exports.darker = darker;
var brighter = 1 / darker;
exports.brighter = brighter;
var reI = "\\s*([+-]?\\d+)\\s*",
reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
reHex = /^#([0-9a-f]{3,8})$/,
reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
var named = {
aliceblue: 0xf0f8ff,
antiquewhite: 0xfaebd7,
aqua: 0x00ffff,
aquamarine: 0x7fffd4,
azure: 0xf0ffff,
beige: 0xf5f5dc,
bisque: 0xffe4c4,
black: 0x000000,
blanchedalmond: 0xffebcd,
blue: 0x0000ff,
blueviolet: 0x8a2be2,
brown: 0xa52a2a,
burlywood: 0xdeb887,
cadetblue: 0x5f9ea0,
chartreuse: 0x7fff00,
chocolate: 0xd2691e,
coral: 0xff7f50,
cornflowerblue: 0x6495ed,
cornsilk: 0xfff8dc,
crimson: 0xdc143c,
cyan: 0x00ffff,
darkblue: 0x00008b,
darkcyan: 0x008b8b,
darkgoldenrod: 0xb8860b,
darkgray: 0xa9a9a9,
darkgreen: 0x006400,
darkgrey: 0xa9a9a9,
darkkhaki: 0xbdb76b,
darkmagenta: 0x8b008b,
darkolivegreen: 0x556b2f,
darkorange: 0xff8c00,
darkorchid: 0x9932cc,
darkred: 0x8b0000,
darksalmon: 0xe9967a,
darkseagreen: 0x8fbc8f,
darkslateblue: 0x483d8b,
darkslategray: 0x2f4f4f,
darkslategrey: 0x2f4f4f,
darkturquoise: 0x00ced1,
darkviolet: 0x9400d3,
deeppink: 0xff1493,
deepskyblue: 0x00bfff,
dimgray: 0x696969,
dimgrey: 0x696969,
dodgerblue: 0x1e90ff,
firebrick: 0xb22222,
floralwhite: 0xfffaf0,
forestgreen: 0x228b22,
fuchsia: 0xff00ff,
gainsboro: 0xdcdcdc,
ghostwhite: 0xf8f8ff,
gold: 0xffd700,
goldenrod: 0xdaa520,
gray: 0x808080,
green: 0x008000,
greenyellow: 0xadff2f,
grey: 0x808080,
honeydew: 0xf0fff0,
hotpink: 0xff69b4,
indianred: 0xcd5c5c,
indigo: 0x4b0082,
ivory: 0xfffff0,
khaki: 0xf0e68c,
lavender: 0xe6e6fa,
lavenderblush: 0xfff0f5,
lawngreen: 0x7cfc00,
lemonchiffon: 0xfffacd,
lightblue: 0xadd8e6,
lightcoral: 0xf08080,
lightcyan: 0xe0ffff,
lightgoldenrodyellow: 0xfafad2,
lightgray: 0xd3d3d3,
lightgreen: 0x90ee90,
lightgrey: 0xd3d3d3,
lightpink: 0xffb6c1,
lightsalmon: 0xffa07a,
lightseagreen: 0x20b2aa,
lightskyblue: 0x87cefa,
lightslategray: 0x778899,
lightslategrey: 0x778899,
lightsteelblue: 0xb0c4de,
lightyellow: 0xffffe0,
lime: 0x00ff00,
limegreen: 0x32cd32,
linen: 0xfaf0e6,
magenta: 0xff00ff,
maroon: 0x800000,
mediumaquamarine: 0x66cdaa,
mediumblue: 0x0000cd,
mediumorchid: 0xba55d3,
mediumpurple: 0x9370db,
mediumseagreen: 0x3cb371,
mediumslateblue: 0x7b68ee,
mediumspringgreen: 0x00fa9a,
mediumturquoise: 0x48d1cc,
mediumvioletred: 0xc71585,
midnightblue: 0x191970,
mintcream: 0xf5fffa,
mistyrose: 0xffe4e1,
moccasin: 0xffe4b5,
navajowhite: 0xffdead,
navy: 0x000080,
oldlace: 0xfdf5e6,
olive: 0x808000,
olivedrab: 0x6b8e23,
orange: 0xffa500,
orangered: 0xff4500,
orchid: 0xda70d6,
palegoldenrod: 0xeee8aa,
palegreen: 0x98fb98,
paleturquoise: 0xafeeee,
palevioletred: 0xdb7093,
papayawhip: 0xffefd5,
peachpuff: 0xffdab9,
peru: 0xcd853f,
pink: 0xffc0cb,
plum: 0xdda0dd,
powderblue: 0xb0e0e6,
purple: 0x800080,
rebeccapurple: 0x663399,
red: 0xff0000,
rosybrown: 0xbc8f8f,
royalblue: 0x4169e1,
saddlebrown: 0x8b4513,
salmon: 0xfa8072,
sandybrown: 0xf4a460,
seagreen: 0x2e8b57,
seashell: 0xfff5ee,
sienna: 0xa0522d,
silver: 0xc0c0c0,
skyblue: 0x87ceeb,
slateblue: 0x6a5acd,
slategray: 0x708090,
slategrey: 0x708090,
snow: 0xfffafa,
springgreen: 0x00ff7f,
steelblue: 0x4682b4,
tan: 0xd2b48c,
teal: 0x008080,
thistle: 0xd8bfd8,
tomato: 0xff6347,
turquoise: 0x40e0d0,
violet: 0xee82ee,
wheat: 0xf5deb3,
white: 0xffffff,
whitesmoke: 0xf5f5f5,
yellow: 0xffff00,
yellowgreen: 0x9acd32
};
(0, _define.default)(Color, color, {
copy(channels) {
return Object.assign(new this.constructor(), this, channels);
},
displayable() {
return this.rgb().displayable();
},
hex: color_formatHex,
// Deprecated! Use color.formatHex.
formatHex: color_formatHex,
formatHex8: color_formatHex8,
formatHsl: color_formatHsl,
formatRgb: color_formatRgb,
toString: color_formatRgb
});
function color_formatHex() {
return this.rgb().formatHex();
}
function color_formatHex8() {
return this.rgb().formatHex8();
}
function color_formatHsl() {
return hslConvert(this).formatHsl();
}
function color_formatRgb() {
return this.rgb().formatRgb();
}
function color(format) {
var m, l;
format = (format + "").trim().toLowerCase();
return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
: l === 3 ? new Rgb(m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00
: l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
: l === 4 ? rgba(m >> 12 & 0xf | m >> 8 & 0xf0, m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, ((m & 0xf) << 4 | m & 0xf) / 0xff) // #f000
: null // invalid hex
) : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
: named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
}
function rgbn(n) {
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
}
function rgba(r, g, b, a) {
if (a <= 0) r = g = b = NaN;
return new Rgb(r, g, b, a);
}
function rgbConvert(o) {
if (!(o instanceof Color)) o = color(o);
if (!o) return new Rgb();
o = o.rgb();
return new Rgb(o.r, o.g, o.b, o.opacity);
}
function rgb(r, g, b, opacity) {
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
}
function Rgb(r, g, b, opacity) {
this.r = +r;
this.g = +g;
this.b = +b;
this.opacity = +opacity;
}
(0, _define.default)(Rgb, rgb, (0, _define.extend)(Color, {
brighter(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
darker(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
rgb() {
return this;
},
clamp() {
return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
},
displayable() {
return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
},
hex: rgb_formatHex,
// Deprecated! Use color.formatHex.
formatHex: rgb_formatHex,
formatHex8: rgb_formatHex8,
formatRgb: rgb_formatRgb,
toString: rgb_formatRgb
}));
function rgb_formatHex() {
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
}
function rgb_formatHex8() {
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function rgb_formatRgb() {
const a = clampa(this.opacity);
return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
}
function clampa(opacity) {
return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
}
function clampi(value) {
return Math.max(0, Math.min(255, Math.round(value) || 0));
}
function hex(value) {
value = clampi(value);
return (value < 16 ? "0" : "") + value.toString(16);
}
function hsla(h, s, l, a) {
if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN;
return new Hsl(h, s, l, a);
}
function hslConvert(o) {
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
if (!(o instanceof Color)) o = color(o);
if (!o) return new Hsl();
if (o instanceof Hsl) return o;
o = o.rgb();
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
min = Math.min(r, g, b),
max = Math.max(r, g, b),
h = NaN,
s = max - min,
l = (max + min) / 2;
if (s) {
if (r === max) h = (g - b) / s + (g < b) * 6;else if (g === max) h = (b - r) / s + 2;else h = (r - g) / s + 4;
s /= l < 0.5 ? max + min : 2 - max - min;
h *= 60;
} else {
s = l > 0 && l < 1 ? 0 : h;
}
return new Hsl(h, s, l, o.opacity);
}
function hsl(h, s, l, opacity) {
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
}
function Hsl(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
(0, _define.default)(Hsl, hsl, (0, _define.extend)(Color, {
brighter(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
darker(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
rgb() {
var h = this.h % 360 + (this.h < 0) * 360,
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
l = this.l,
m2 = l + (l < 0.5 ? l : 1 - l) * s,
m1 = 2 * l - m2;
return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity);
},
clamp() {
return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
},
displayable() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
},
formatHsl() {
const a = clampa(this.opacity);
return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
}
}));
function clamph(value) {
value = (value || 0) % 360;
return value < 0 ? value + 360 : value;
}
function clampt(value) {
return Math.max(0, Math.min(1, value || 0));
}
/* From FvD 13.37, CSS Color Module Level 3 */
function hsl2rgb(h, m1, m2) {
return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
}
@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Cubehelix = Cubehelix;
exports.default = cubehelix;
var _define = _interopRequireWildcard(require("./define.js"));
var _color = require("./color.js");
var _math = require("./math.js");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var A = -0.14861,
B = +1.78277,
C = -0.29227,
D = -0.90649,
E = +1.97294,
ED = E * D,
EB = E * B,
BC_DA = B * C - D * A;
function cubehelixConvert(o) {
if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
if (!(o instanceof _color.Rgb)) o = (0, _color.rgbConvert)(o);
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
bl = b - l,
k = (E * (g - l) - C * bl) / D,
s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
// NaN if l=0 or l=1
h = s ? Math.atan2(k, bl) * _math.degrees - 120 : NaN;
return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
}
function cubehelix(h, s, l, opacity) {
return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
}
function Cubehelix(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
(0, _define.default)(Cubehelix, cubehelix, (0, _define.extend)(_color.Color, {
brighter(k) {
k = k == null ? _color.brighter : Math.pow(_color.brighter, k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
darker(k) {
k = k == null ? _color.darker : Math.pow(_color.darker, k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
rgb() {
var h = isNaN(this.h) ? 0 : (this.h + 120) * _math.radians,
l = +this.l,
a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
cosh = Math.cos(h),
sinh = Math.sin(h);
return new _color.Rgb(255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity);
}
}));
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.extend = extend;
function _default(constructor, factory, prototype) {
constructor.prototype = factory.prototype = prototype;
prototype.constructor = constructor;
}
function extend(parent, definition) {
var prototype = Object.create(parent.prototype);
for (var key in definition) prototype[key] = definition[key];
return prototype;
}
+65
View File
@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "color", {
enumerable: true,
get: function () {
return _color.default;
}
});
Object.defineProperty(exports, "cubehelix", {
enumerable: true,
get: function () {
return _cubehelix.default;
}
});
Object.defineProperty(exports, "gray", {
enumerable: true,
get: function () {
return _lab.gray;
}
});
Object.defineProperty(exports, "hcl", {
enumerable: true,
get: function () {
return _lab.hcl;
}
});
Object.defineProperty(exports, "hsl", {
enumerable: true,
get: function () {
return _color.hsl;
}
});
Object.defineProperty(exports, "lab", {
enumerable: true,
get: function () {
return _lab.default;
}
});
Object.defineProperty(exports, "lch", {
enumerable: true,
get: function () {
return _lab.lch;
}
});
Object.defineProperty(exports, "rgb", {
enumerable: true,
get: function () {
return _color.rgb;
}
});
var _color = _interopRequireWildcard(require("./color.js"));
var _lab = _interopRequireWildcard(require("./lab.js"));
var _cubehelix = _interopRequireDefault(require("./cubehelix.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+146
View File
@@ -0,0 +1,146 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Hcl = Hcl;
exports.Lab = Lab;
exports.default = lab;
exports.gray = gray;
exports.hcl = hcl;
exports.lch = lch;
var _define = _interopRequireWildcard(require("./define.js"));
var _color = require("./color.js");
var _math = require("./math.js");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// https://observablehq.com/@mbostock/lab-and-rgb
const K = 18,
Xn = 0.96422,
Yn = 1,
Zn = 0.82521,
t0 = 4 / 29,
t1 = 6 / 29,
t2 = 3 * t1 * t1,
t3 = t1 * t1 * t1;
function labConvert(o) {
if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
if (o instanceof Hcl) return hcl2lab(o);
if (!(o instanceof _color.Rgb)) o = (0, _color.rgbConvert)(o);
var r = rgb2lrgb(o.r),
g = rgb2lrgb(o.g),
b = rgb2lrgb(o.b),
y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn),
x,
z;
if (r === g && g === b) x = z = y;else {
x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
}
return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
}
function gray(l, opacity) {
return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
}
function lab(l, a, b, opacity) {
return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
}
function Lab(l, a, b, opacity) {
this.l = +l;
this.a = +a;
this.b = +b;
this.opacity = +opacity;
}
(0, _define.default)(Lab, lab, (0, _define.extend)(_color.Color, {
brighter(k) {
return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
darker(k) {
return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
rgb() {
var y = (this.l + 16) / 116,
x = isNaN(this.a) ? y : y + this.a / 500,
z = isNaN(this.b) ? y : y - this.b / 200;
x = Xn * lab2xyz(x);
y = Yn * lab2xyz(y);
z = Zn * lab2xyz(z);
return new _color.Rgb(lrgb2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), lrgb2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity);
}
}));
function xyz2lab(t) {
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
}
function lab2xyz(t) {
return t > t1 ? t * t * t : t2 * (t - t0);
}
function lrgb2rgb(x) {
return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
}
function rgb2lrgb(x) {
return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
}
function hclConvert(o) {
if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
if (!(o instanceof Lab)) o = labConvert(o);
if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
var h = Math.atan2(o.b, o.a) * _math.degrees;
return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
}
function lch(l, c, h, opacity) {
return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
}
function hcl(h, c, l, opacity) {
return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
}
function Hcl(h, c, l, opacity) {
this.h = +h;
this.c = +c;
this.l = +l;
this.opacity = +opacity;
}
function hcl2lab(o) {
if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
var h = o.h * _math.radians;
return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
}
(0, _define.default)(Hcl, hcl, (0, _define.extend)(_color.Color, {
brighter(k) {
return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
},
darker(k) {
return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
},
rgb() {
return hcl2lab(this).rgb();
}
}));
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.radians = exports.degrees = void 0;
const radians = Math.PI / 180;
exports.radians = radians;
const degrees = 180 / Math.PI;
exports.degrees = degrees;
+28
View File
@@ -0,0 +1,28 @@
Copyright 2010-2021 Mike Bostock
Copyright 2001 Robert Penner
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.
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.backOut = exports.backInOut = exports.backIn = void 0;
var overshoot = 1.70158;
var backIn = function custom(s) {
s = +s;
function backIn(t) {
return (t = +t) * t * (s * (t - 1) + t);
}
backIn.overshoot = custom;
return backIn;
}(overshoot);
exports.backIn = backIn;
var backOut = function custom(s) {
s = +s;
function backOut(t) {
return --t * t * ((t + 1) * s + t) + 1;
}
backOut.overshoot = custom;
return backOut;
}(overshoot);
exports.backOut = backOut;
var backInOut = function custom(s) {
s = +s;
function backInOut(t) {
return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
}
backInOut.overshoot = custom;
return backInOut;
}(overshoot);
exports.backInOut = backInOut;
+30
View File
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bounceIn = bounceIn;
exports.bounceInOut = bounceInOut;
exports.bounceOut = bounceOut;
var b1 = 4 / 11,
b2 = 6 / 11,
b3 = 8 / 11,
b4 = 3 / 4,
b5 = 9 / 11,
b6 = 10 / 11,
b7 = 15 / 16,
b8 = 21 / 22,
b9 = 63 / 64,
b0 = 1 / b1 / b1;
function bounceIn(t) {
return 1 - bounceOut(1 - t);
}
function bounceOut(t) {
return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
}
function bounceInOut(t) {
return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.circleIn = circleIn;
exports.circleInOut = circleInOut;
exports.circleOut = circleOut;
function circleIn(t) {
return 1 - Math.sqrt(1 - t * t);
}
function circleOut(t) {
return Math.sqrt(1 - --t * t);
}
function circleInOut(t) {
return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cubicIn = cubicIn;
exports.cubicInOut = cubicInOut;
exports.cubicOut = cubicOut;
function cubicIn(t) {
return t * t * t;
}
function cubicOut(t) {
return --t * t * t + 1;
}
function cubicInOut(t) {
return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
}
+72
View File
@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.elasticOut = exports.elasticInOut = exports.elasticIn = void 0;
var _math = require("./math.js");
var tau = 2 * Math.PI,
amplitude = 1,
period = 0.3;
var elasticIn = function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticIn(t) {
return a * (0, _math.tpmt)(- --t) * Math.sin((s - t) / p);
}
elasticIn.amplitude = function (a) {
return custom(a, p * tau);
};
elasticIn.period = function (p) {
return custom(a, p);
};
return elasticIn;
}(amplitude, period);
exports.elasticIn = elasticIn;
var elasticOut = function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticOut(t) {
return 1 - a * (0, _math.tpmt)(t = +t) * Math.sin((t + s) / p);
}
elasticOut.amplitude = function (a) {
return custom(a, p * tau);
};
elasticOut.period = function (p) {
return custom(a, p);
};
return elasticOut;
}(amplitude, period);
exports.elasticOut = elasticOut;
var elasticInOut = function custom(a, p) {
var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
function elasticInOut(t) {
return ((t = t * 2 - 1) < 0 ? a * (0, _math.tpmt)(-t) * Math.sin((s - t) / p) : 2 - a * (0, _math.tpmt)(t) * Math.sin((s + t) / p)) / 2;
}
elasticInOut.amplitude = function (a) {
return custom(a, p * tau);
};
elasticInOut.period = function (p) {
return custom(a, p);
};
return elasticInOut;
}(amplitude, period);
exports.elasticInOut = elasticInOut;
+22
View File
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.expIn = expIn;
exports.expInOut = expInOut;
exports.expOut = expOut;
var _math = require("./math.js");
function expIn(t) {
return (0, _math.tpmt)(1 - +t);
}
function expOut(t) {
return 1 - (0, _math.tpmt)(t);
}
function expInOut(t) {
return ((t *= 2) <= 1 ? (0, _math.tpmt)(1 - t) : 2 - (0, _math.tpmt)(t - 1)) / 2;
}
+247
View File
@@ -0,0 +1,247 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "easeBack", {
enumerable: true,
get: function () {
return _back.backInOut;
}
});
Object.defineProperty(exports, "easeBackIn", {
enumerable: true,
get: function () {
return _back.backIn;
}
});
Object.defineProperty(exports, "easeBackInOut", {
enumerable: true,
get: function () {
return _back.backInOut;
}
});
Object.defineProperty(exports, "easeBackOut", {
enumerable: true,
get: function () {
return _back.backOut;
}
});
Object.defineProperty(exports, "easeBounce", {
enumerable: true,
get: function () {
return _bounce.bounceOut;
}
});
Object.defineProperty(exports, "easeBounceIn", {
enumerable: true,
get: function () {
return _bounce.bounceIn;
}
});
Object.defineProperty(exports, "easeBounceInOut", {
enumerable: true,
get: function () {
return _bounce.bounceInOut;
}
});
Object.defineProperty(exports, "easeBounceOut", {
enumerable: true,
get: function () {
return _bounce.bounceOut;
}
});
Object.defineProperty(exports, "easeCircle", {
enumerable: true,
get: function () {
return _circle.circleInOut;
}
});
Object.defineProperty(exports, "easeCircleIn", {
enumerable: true,
get: function () {
return _circle.circleIn;
}
});
Object.defineProperty(exports, "easeCircleInOut", {
enumerable: true,
get: function () {
return _circle.circleInOut;
}
});
Object.defineProperty(exports, "easeCircleOut", {
enumerable: true,
get: function () {
return _circle.circleOut;
}
});
Object.defineProperty(exports, "easeCubic", {
enumerable: true,
get: function () {
return _cubic.cubicInOut;
}
});
Object.defineProperty(exports, "easeCubicIn", {
enumerable: true,
get: function () {
return _cubic.cubicIn;
}
});
Object.defineProperty(exports, "easeCubicInOut", {
enumerable: true,
get: function () {
return _cubic.cubicInOut;
}
});
Object.defineProperty(exports, "easeCubicOut", {
enumerable: true,
get: function () {
return _cubic.cubicOut;
}
});
Object.defineProperty(exports, "easeElastic", {
enumerable: true,
get: function () {
return _elastic.elasticOut;
}
});
Object.defineProperty(exports, "easeElasticIn", {
enumerable: true,
get: function () {
return _elastic.elasticIn;
}
});
Object.defineProperty(exports, "easeElasticInOut", {
enumerable: true,
get: function () {
return _elastic.elasticInOut;
}
});
Object.defineProperty(exports, "easeElasticOut", {
enumerable: true,
get: function () {
return _elastic.elasticOut;
}
});
Object.defineProperty(exports, "easeExp", {
enumerable: true,
get: function () {
return _exp.expInOut;
}
});
Object.defineProperty(exports, "easeExpIn", {
enumerable: true,
get: function () {
return _exp.expIn;
}
});
Object.defineProperty(exports, "easeExpInOut", {
enumerable: true,
get: function () {
return _exp.expInOut;
}
});
Object.defineProperty(exports, "easeExpOut", {
enumerable: true,
get: function () {
return _exp.expOut;
}
});
Object.defineProperty(exports, "easeLinear", {
enumerable: true,
get: function () {
return _linear.linear;
}
});
Object.defineProperty(exports, "easePoly", {
enumerable: true,
get: function () {
return _poly.polyInOut;
}
});
Object.defineProperty(exports, "easePolyIn", {
enumerable: true,
get: function () {
return _poly.polyIn;
}
});
Object.defineProperty(exports, "easePolyInOut", {
enumerable: true,
get: function () {
return _poly.polyInOut;
}
});
Object.defineProperty(exports, "easePolyOut", {
enumerable: true,
get: function () {
return _poly.polyOut;
}
});
Object.defineProperty(exports, "easeQuad", {
enumerable: true,
get: function () {
return _quad.quadInOut;
}
});
Object.defineProperty(exports, "easeQuadIn", {
enumerable: true,
get: function () {
return _quad.quadIn;
}
});
Object.defineProperty(exports, "easeQuadInOut", {
enumerable: true,
get: function () {
return _quad.quadInOut;
}
});
Object.defineProperty(exports, "easeQuadOut", {
enumerable: true,
get: function () {
return _quad.quadOut;
}
});
Object.defineProperty(exports, "easeSin", {
enumerable: true,
get: function () {
return _sin.sinInOut;
}
});
Object.defineProperty(exports, "easeSinIn", {
enumerable: true,
get: function () {
return _sin.sinIn;
}
});
Object.defineProperty(exports, "easeSinInOut", {
enumerable: true,
get: function () {
return _sin.sinInOut;
}
});
Object.defineProperty(exports, "easeSinOut", {
enumerable: true,
get: function () {
return _sin.sinOut;
}
});
var _linear = require("./linear.js");
var _quad = require("./quad.js");
var _cubic = require("./cubic.js");
var _poly = require("./poly.js");
var _sin = require("./sin.js");
var _exp = require("./exp.js");
var _circle = require("./circle.js");
var _bounce = require("./bounce.js");
var _back = require("./back.js");
var _elastic = require("./elastic.js");
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.linear = void 0;
const linear = t => +t;
exports.linear = linear;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tpmt = tpmt;
// tpmt is two power minus ten times t scaled to [0,1]
function tpmt(x) {
return (Math.pow(2, -10 * x) - 0.0009765625) * 1.0009775171065494;
}
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.polyOut = exports.polyInOut = exports.polyIn = void 0;
var exponent = 3;
var polyIn = function custom(e) {
e = +e;
function polyIn(t) {
return Math.pow(t, e);
}
polyIn.exponent = custom;
return polyIn;
}(exponent);
exports.polyIn = polyIn;
var polyOut = function custom(e) {
e = +e;
function polyOut(t) {
return 1 - Math.pow(1 - t, e);
}
polyOut.exponent = custom;
return polyOut;
}(exponent);
exports.polyOut = polyOut;
var polyInOut = function custom(e) {
e = +e;
function polyInOut(t) {
return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
}
polyInOut.exponent = custom;
return polyInOut;
}(exponent);
exports.polyInOut = polyInOut;
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.quadIn = quadIn;
exports.quadInOut = quadInOut;
exports.quadOut = quadOut;
function quadIn(t) {
return t * t;
}
function quadOut(t) {
return t * (2 - t);
}
function quadInOut(t) {
return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
}
+22
View File
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sinIn = sinIn;
exports.sinInOut = sinInOut;
exports.sinOut = sinOut;
var pi = Math.PI,
halfPi = pi / 2;
function sinIn(t) {
return +t === 1 ? 1 : 1 - Math.cos(t * halfPi);
}
function sinOut(t) {
return Math.sin(t * halfPi);
}
function sinInOut(t) {
return (1 - Math.cos(pi * t)) / 2;
}
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2021 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = defaultLocale;
exports.formatPrefix = exports.format = void 0;
var _locale = _interopRequireDefault(require("./locale.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var locale;
var format;
exports.format = format;
var formatPrefix;
exports.formatPrefix = formatPrefix;
defaultLocale({
thousands: ",",
grouping: [3],
currency: ["$", ""]
});
function defaultLocale(definition) {
locale = (0, _locale.default)(definition);
exports.format = format = locale.format;
exports.formatPrefix = formatPrefix = locale.formatPrefix;
return locale;
}
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _formatDecimal = require("./formatDecimal.js");
function _default(x) {
return x = (0, _formatDecimal.formatDecimalParts)(Math.abs(x)), x ? x[1] : NaN;
}
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.formatDecimalParts = formatDecimalParts;
function _default(x) {
return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10);
} // Computes the decimal coefficient and exponent of the specified number x with
// significant digits p, where x is positive and p is in [1, 21] or undefined.
// For example, formatDecimalParts(1.23) returns ["123", 0].
function formatDecimalParts(x, p) {
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
var i,
coefficient = x.slice(0, i); // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
// (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
return [coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, +x.slice(i + 1)];
}
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(grouping, thousands) {
return function (value, width) {
var i = value.length,
t = [],
j = 0,
g = grouping[0],
length = 0;
while (i > 0 && g > 0) {
if (length + g + 1 > width) g = Math.max(1, width - length);
t.push(value.substring(i -= g, i + g));
if ((length += g + 1) > width) break;
g = grouping[j = (j + 1) % grouping.length];
}
return t.reverse().join(thousands);
};
}
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(numerals) {
return function (value) {
return value.replace(/[0-9]/g, function (i) {
return numerals[+i];
});
};
}
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.prefixExponent = void 0;
var _formatDecimal = require("./formatDecimal.js");
var prefixExponent;
exports.prefixExponent = prefixExponent;
function _default(x, p) {
var d = (0, _formatDecimal.formatDecimalParts)(x, p);
if (!d) return x + "";
var coefficient = d[0],
exponent = d[1],
i = exponent - (exports.prefixExponent = prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
n = coefficient.length;
return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + (0, _formatDecimal.formatDecimalParts)(x, Math.max(0, p + i - 1))[0]; // less than 1y!
}
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _formatDecimal = require("./formatDecimal.js");
function _default(x, p) {
var d = (0, _formatDecimal.formatDecimalParts)(x, p);
if (!d) return x + "";
var coefficient = d[0],
exponent = d[1];
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
}
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FormatSpecifier = FormatSpecifier;
exports.default = formatSpecifier;
// [[fill]align][sign][symbol][0][width][,][.precision][~][type]
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function formatSpecifier(specifier) {
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
var match;
return new FormatSpecifier({
fill: match[1],
align: match[2],
sign: match[3],
symbol: match[4],
zero: match[5],
width: match[6],
comma: match[7],
precision: match[8] && match[8].slice(1),
trim: match[9],
type: match[10]
});
}
formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
function FormatSpecifier(specifier) {
this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
this.align = specifier.align === undefined ? ">" : specifier.align + "";
this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
this.zero = !!specifier.zero;
this.width = specifier.width === undefined ? undefined : +specifier.width;
this.comma = !!specifier.comma;
this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
this.trim = !!specifier.trim;
this.type = specifier.type === undefined ? "" : specifier.type + "";
}
FormatSpecifier.prototype.toString = function () {
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
function _default(s) {
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
switch (s[i]) {
case ".":
i0 = i1 = i;
break;
case "0":
if (i0 === 0) i0 = i;
i1 = i;
break;
default:
if (!+s[i]) break out;
if (i0 > 0) i0 = 0;
break;
}
}
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
}
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _formatDecimal = _interopRequireDefault(require("./formatDecimal.js"));
var _formatPrefixAuto = _interopRequireDefault(require("./formatPrefixAuto.js"));
var _formatRounded = _interopRequireDefault(require("./formatRounded.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
"%": (x, p) => (x * 100).toFixed(p),
"b": x => Math.round(x).toString(2),
"c": x => x + "",
"d": _formatDecimal.default,
"e": (x, p) => x.toExponential(p),
"f": (x, p) => x.toFixed(p),
"g": (x, p) => x.toPrecision(p),
"o": x => Math.round(x).toString(8),
"p": (x, p) => (0, _formatRounded.default)(x * 100, p),
"r": _formatRounded.default,
"s": _formatPrefixAuto.default,
"X": x => Math.round(x).toString(16).toUpperCase(),
"x": x => Math.round(x).toString(16)
};
exports.default = _default;
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(x) {
return x;
}
+77
View File
@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "FormatSpecifier", {
enumerable: true,
get: function () {
return _formatSpecifier.FormatSpecifier;
}
});
Object.defineProperty(exports, "format", {
enumerable: true,
get: function () {
return _defaultLocale.format;
}
});
Object.defineProperty(exports, "formatDefaultLocale", {
enumerable: true,
get: function () {
return _defaultLocale.default;
}
});
Object.defineProperty(exports, "formatLocale", {
enumerable: true,
get: function () {
return _locale.default;
}
});
Object.defineProperty(exports, "formatPrefix", {
enumerable: true,
get: function () {
return _defaultLocale.formatPrefix;
}
});
Object.defineProperty(exports, "formatSpecifier", {
enumerable: true,
get: function () {
return _formatSpecifier.default;
}
});
Object.defineProperty(exports, "precisionFixed", {
enumerable: true,
get: function () {
return _precisionFixed.default;
}
});
Object.defineProperty(exports, "precisionPrefix", {
enumerable: true,
get: function () {
return _precisionPrefix.default;
}
});
Object.defineProperty(exports, "precisionRound", {
enumerable: true,
get: function () {
return _precisionRound.default;
}
});
var _defaultLocale = _interopRequireWildcard(require("./defaultLocale.js"));
var _locale = _interopRequireDefault(require("./locale.js"));
var _formatSpecifier = _interopRequireWildcard(require("./formatSpecifier.js"));
var _precisionFixed = _interopRequireDefault(require("./precisionFixed.js"));
var _precisionPrefix = _interopRequireDefault(require("./precisionPrefix.js"));
var _precisionRound = _interopRequireDefault(require("./precisionRound.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+159
View File
@@ -0,0 +1,159 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _exponent = _interopRequireDefault(require("./exponent.js"));
var _formatGroup = _interopRequireDefault(require("./formatGroup.js"));
var _formatNumerals = _interopRequireDefault(require("./formatNumerals.js"));
var _formatSpecifier = _interopRequireDefault(require("./formatSpecifier.js"));
var _formatTrim = _interopRequireDefault(require("./formatTrim.js"));
var _formatTypes = _interopRequireDefault(require("./formatTypes.js"));
var _formatPrefixAuto = require("./formatPrefixAuto.js");
var _identity = _interopRequireDefault(require("./identity.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var map = Array.prototype.map,
prefixes = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function _default(locale) {
var group = locale.grouping === undefined || locale.thousands === undefined ? _identity.default : (0, _formatGroup.default)(map.call(locale.grouping, Number), locale.thousands + ""),
currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
decimal = locale.decimal === undefined ? "." : locale.decimal + "",
numerals = locale.numerals === undefined ? _identity.default : (0, _formatNumerals.default)(map.call(locale.numerals, String)),
percent = locale.percent === undefined ? "%" : locale.percent + "",
minus = locale.minus === undefined ? "" : locale.minus + "",
nan = locale.nan === undefined ? "NaN" : locale.nan + "";
function newFormat(specifier) {
specifier = (0, _formatSpecifier.default)(specifier);
var fill = specifier.fill,
align = specifier.align,
sign = specifier.sign,
symbol = specifier.symbol,
zero = specifier.zero,
width = specifier.width,
comma = specifier.comma,
precision = specifier.precision,
trim = specifier.trim,
type = specifier.type; // The "n" type is an alias for ",g".
if (type === "n") comma = true, type = "g"; // The "" type, and any invalid type, is an alias for ".12~g".
else if (!_formatTypes.default[type]) precision === undefined && (precision = 12), trim = true, type = "g"; // If zero fill is specified, padding goes after sign and before digits.
if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "="; // Compute the prefix and suffix.
// For SI-prefix, the suffix is lazily computed.
var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; // What format function should we use?
// Is this an integer type?
// Can this type generate exponential notation?
var formatType = _formatTypes.default[type],
maybeSuffix = /[defgprs%]/.test(type); // Set the default precision if not specified,
// or clamp the specified precision to the supported range.
// For significant precision, it must be in [1, 21].
// For fixed precision, it must be in [0, 20].
precision = precision === undefined ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
function format(value) {
var valuePrefix = prefix,
valueSuffix = suffix,
i,
n,
c;
if (type === "c") {
valueSuffix = formatType(value) + valueSuffix;
value = "";
} else {
value = +value; // Determine the sign. -0 is not less than 0, but 1 / -0 is!
var valueNegative = value < 0 || 1 / value < 0; // Perform the initial formatting.
value = isNaN(value) ? nan : formatType(Math.abs(value), precision); // Trim insignificant zeros.
if (trim) value = (0, _formatTrim.default)(value); // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; // Compute the prefix and suffix.
valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
valueSuffix = (type === "s" ? prefixes[8 + _formatPrefixAuto.prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); // Break the formatted value into the integer “value” part that can be
// grouped, and fractional or exponential “suffix” part that is not.
if (maybeSuffix) {
i = -1, n = value.length;
while (++i < n) {
if (c = value.charCodeAt(i), 48 > c || c > 57) {
valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
value = value.slice(0, i);
break;
}
}
}
} // If the fill character is not "0", grouping is applied before padding.
if (comma && !zero) value = group(value, Infinity); // Compute the padding.
var length = valuePrefix.length + value.length + valueSuffix.length,
padding = length < width ? new Array(width - length + 1).join(fill) : ""; // If the fill character is "0", grouping is applied after padding.
if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; // Reconstruct the final output based on the desired alignment.
switch (align) {
case "<":
value = valuePrefix + value + valueSuffix + padding;
break;
case "=":
value = valuePrefix + padding + value + valueSuffix;
break;
case "^":
value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
break;
default:
value = padding + valuePrefix + value + valueSuffix;
break;
}
return numerals(value);
}
format.toString = function () {
return specifier + "";
};
return format;
}
function formatPrefix(specifier, value) {
var f = newFormat((specifier = (0, _formatSpecifier.default)(specifier), specifier.type = "f", specifier)),
e = Math.max(-8, Math.min(8, Math.floor((0, _exponent.default)(value) / 3))) * 3,
k = Math.pow(10, -e),
prefix = prefixes[8 + e / 3];
return function (value) {
return f(k * value) + prefix;
};
}
return {
format: newFormat,
formatPrefix: formatPrefix
};
}
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _exponent = _interopRequireDefault(require("./exponent.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(step) {
return Math.max(0, -(0, _exponent.default)(Math.abs(step)));
}
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _exponent = _interopRequireDefault(require("./exponent.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(step, value) {
return Math.max(0, Math.max(-8, Math.min(8, Math.floor((0, _exponent.default)(value) / 3))) * 3 - (0, _exponent.default)(Math.abs(step)));
}
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _exponent = _interopRequireDefault(require("./exponent.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(step, max) {
step = Math.abs(step), max = Math.abs(max) - step;
return Math.max(0, (0, _exponent.default)(max) - (0, _exponent.default)(step)) + 1;
}
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2021 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.genericArray = genericArray;
var _value = _interopRequireDefault(require("./value.js"));
var _numberArray = _interopRequireWildcard(require("./numberArray.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(a, b) {
return ((0, _numberArray.isNumberArray)(b) ? _numberArray.default : genericArray)(a, b);
}
function genericArray(a, b) {
var nb = b ? b.length : 0,
na = a ? Math.min(nb, a.length) : 0,
x = new Array(na),
c = new Array(nb),
i;
for (i = 0; i < na; ++i) x[i] = (0, _value.default)(a[i], b[i]);
for (; i < nb; ++i) c[i] = b[i];
return function (t) {
for (i = 0; i < na; ++i) c[i] = x[i](t);
return c;
};
}
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.basis = basis;
exports.default = _default;
function basis(t1, v0, v1, v2, v3) {
var t2 = t1 * t1,
t3 = t2 * t1;
return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
}
function _default(values) {
var n = values.length - 1;
return function (t) {
var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
v1 = values[i],
v2 = values[i + 1],
v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
return basis((t - i / n) * n, v0, v1, v2, v3);
};
}
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _basis = require("./basis.js");
function _default(values) {
var n = values.length;
return function (t) {
var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
v0 = values[(i + n - 1) % n],
v1 = values[i % n],
v2 = values[(i + 1) % n],
v3 = values[(i + 2) % n];
return (0, _basis.basis)((t - i / n) * n, v0, v1, v2, v3);
};
}
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nogamma;
exports.gamma = gamma;
exports.hue = hue;
var _constant = _interopRequireDefault(require("./constant.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function linear(a, d) {
return function (t) {
return a + t * d;
};
}
function exponential(a, b, y) {
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) {
return Math.pow(a + t * b, y);
};
}
function hue(a, b) {
var d = b - a;
return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : (0, _constant.default)(isNaN(a) ? b : a);
}
function gamma(y) {
return (y = +y) === 1 ? nogamma : function (a, b) {
return b - a ? exponential(a, b, y) : (0, _constant.default)(isNaN(a) ? b : a);
};
}
function nogamma(a, b) {
var d = b - a;
return d ? linear(a, d) : (0, _constant.default)(isNaN(a) ? b : a);
}
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = x => () => x;
exports.default = _default;
@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.cubehelixLong = void 0;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _color = _interopRequireWildcard(require("./color.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function cubehelix(hue) {
return function cubehelixGamma(y) {
y = +y;
function cubehelix(start, end) {
var h = hue((start = (0, _index.cubehelix)(start)).h, (end = (0, _index.cubehelix)(end)).h),
s = (0, _color.default)(start.s, end.s),
l = (0, _color.default)(start.l, end.l),
opacity = (0, _color.default)(start.opacity, end.opacity);
return function (t) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = cubehelixGamma;
return cubehelix;
}(1);
}
var _default = cubehelix(_color.hue);
exports.default = _default;
var cubehelixLong = cubehelix(_color.default);
exports.cubehelixLong = cubehelixLong;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(a, b) {
var d = new Date();
return a = +a, b = +b, function (t) {
return d.setTime(a * (1 - t) + b * t), d;
};
}
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(range) {
var n = range.length;
return function (t) {
return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
};
}
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hclLong = exports.default = void 0;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _color = _interopRequireWildcard(require("./color.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function hcl(hue) {
return function (start, end) {
var h = hue((start = (0, _index.hcl)(start)).h, (end = (0, _index.hcl)(end)).h),
c = (0, _color.default)(start.c, end.c),
l = (0, _color.default)(start.l, end.l),
opacity = (0, _color.default)(start.opacity, end.opacity);
return function (t) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
};
}
var _default = hcl(_color.hue);
exports.default = _default;
var hclLong = hcl(_color.default);
exports.hclLong = hclLong;
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hslLong = exports.default = void 0;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _color = _interopRequireWildcard(require("./color.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function hsl(hue) {
return function (start, end) {
var h = hue((start = (0, _index.hsl)(start)).h, (end = (0, _index.hsl)(end)).h),
s = (0, _color.default)(start.s, end.s),
l = (0, _color.default)(start.l, end.l),
opacity = (0, _color.default)(start.opacity, end.opacity);
return function (t) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
};
}
var _default = hsl(_color.hue);
exports.default = _default;
var hslLong = hsl(_color.default);
exports.hslLong = hslLong;
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _color = require("./color.js");
function _default(a, b) {
var i = (0, _color.hue)(+a, +b);
return function (t) {
var x = i(t);
return x - 360 * Math.floor(x / 360);
};
}
@@ -0,0 +1,215 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "interpolate", {
enumerable: true,
get: function () {
return _value.default;
}
});
Object.defineProperty(exports, "interpolateArray", {
enumerable: true,
get: function () {
return _array.default;
}
});
Object.defineProperty(exports, "interpolateBasis", {
enumerable: true,
get: function () {
return _basis.default;
}
});
Object.defineProperty(exports, "interpolateBasisClosed", {
enumerable: true,
get: function () {
return _basisClosed.default;
}
});
Object.defineProperty(exports, "interpolateCubehelix", {
enumerable: true,
get: function () {
return _cubehelix.default;
}
});
Object.defineProperty(exports, "interpolateCubehelixLong", {
enumerable: true,
get: function () {
return _cubehelix.cubehelixLong;
}
});
Object.defineProperty(exports, "interpolateDate", {
enumerable: true,
get: function () {
return _date.default;
}
});
Object.defineProperty(exports, "interpolateDiscrete", {
enumerable: true,
get: function () {
return _discrete.default;
}
});
Object.defineProperty(exports, "interpolateHcl", {
enumerable: true,
get: function () {
return _hcl.default;
}
});
Object.defineProperty(exports, "interpolateHclLong", {
enumerable: true,
get: function () {
return _hcl.hclLong;
}
});
Object.defineProperty(exports, "interpolateHsl", {
enumerable: true,
get: function () {
return _hsl.default;
}
});
Object.defineProperty(exports, "interpolateHslLong", {
enumerable: true,
get: function () {
return _hsl.hslLong;
}
});
Object.defineProperty(exports, "interpolateHue", {
enumerable: true,
get: function () {
return _hue.default;
}
});
Object.defineProperty(exports, "interpolateLab", {
enumerable: true,
get: function () {
return _lab.default;
}
});
Object.defineProperty(exports, "interpolateNumber", {
enumerable: true,
get: function () {
return _number.default;
}
});
Object.defineProperty(exports, "interpolateNumberArray", {
enumerable: true,
get: function () {
return _numberArray.default;
}
});
Object.defineProperty(exports, "interpolateObject", {
enumerable: true,
get: function () {
return _object.default;
}
});
Object.defineProperty(exports, "interpolateRgb", {
enumerable: true,
get: function () {
return _rgb.default;
}
});
Object.defineProperty(exports, "interpolateRgbBasis", {
enumerable: true,
get: function () {
return _rgb.rgbBasis;
}
});
Object.defineProperty(exports, "interpolateRgbBasisClosed", {
enumerable: true,
get: function () {
return _rgb.rgbBasisClosed;
}
});
Object.defineProperty(exports, "interpolateRound", {
enumerable: true,
get: function () {
return _round.default;
}
});
Object.defineProperty(exports, "interpolateString", {
enumerable: true,
get: function () {
return _string.default;
}
});
Object.defineProperty(exports, "interpolateTransformCss", {
enumerable: true,
get: function () {
return _index.interpolateTransformCss;
}
});
Object.defineProperty(exports, "interpolateTransformSvg", {
enumerable: true,
get: function () {
return _index.interpolateTransformSvg;
}
});
Object.defineProperty(exports, "interpolateZoom", {
enumerable: true,
get: function () {
return _zoom.default;
}
});
Object.defineProperty(exports, "piecewise", {
enumerable: true,
get: function () {
return _piecewise.default;
}
});
Object.defineProperty(exports, "quantize", {
enumerable: true,
get: function () {
return _quantize.default;
}
});
var _value = _interopRequireDefault(require("./value.js"));
var _array = _interopRequireDefault(require("./array.js"));
var _basis = _interopRequireDefault(require("./basis.js"));
var _basisClosed = _interopRequireDefault(require("./basisClosed.js"));
var _date = _interopRequireDefault(require("./date.js"));
var _discrete = _interopRequireDefault(require("./discrete.js"));
var _hue = _interopRequireDefault(require("./hue.js"));
var _number = _interopRequireDefault(require("./number.js"));
var _numberArray = _interopRequireDefault(require("./numberArray.js"));
var _object = _interopRequireDefault(require("./object.js"));
var _round = _interopRequireDefault(require("./round.js"));
var _string = _interopRequireDefault(require("./string.js"));
var _index = require("./transform/index.js");
var _zoom = _interopRequireDefault(require("./zoom.js"));
var _rgb = _interopRequireWildcard(require("./rgb.js"));
var _hsl = _interopRequireWildcard(require("./hsl.js"));
var _lab = _interopRequireDefault(require("./lab.js"));
var _hcl = _interopRequireWildcard(require("./hcl.js"));
var _cubehelix = _interopRequireWildcard(require("./cubehelix.js"));
var _piecewise = _interopRequireDefault(require("./piecewise.js"));
var _quantize = _interopRequireDefault(require("./quantize.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = lab;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _color = _interopRequireDefault(require("./color.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function lab(start, end) {
var l = (0, _color.default)((start = (0, _index.lab)(start)).l, (end = (0, _index.lab)(end)).l),
a = (0, _color.default)(start.a, end.a),
b = (0, _color.default)(start.b, end.b),
opacity = (0, _color.default)(start.opacity, end.opacity);
return function (t) {
start.l = l(t);
start.a = a(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(a, b) {
return a = +a, b = +b, function (t) {
return a * (1 - t) + b * t;
};
}
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.isNumberArray = isNumberArray;
function _default(a, b) {
if (!b) b = [];
var n = a ? Math.min(b.length, a.length) : 0,
c = b.slice(),
i;
return function (t) {
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
return c;
};
}
function isNumberArray(x) {
return ArrayBuffer.isView(x) && !(x instanceof DataView);
}
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _value = _interopRequireDefault(require("./value.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(a, b) {
var i = {},
c = {},
k;
if (a === null || typeof a !== "object") a = {};
if (b === null || typeof b !== "object") b = {};
for (k in b) {
if (k in a) {
i[k] = (0, _value.default)(a[k], b[k]);
} else {
c[k] = b[k];
}
}
return function (t) {
for (k in i) c[k] = i[k](t);
return c;
};
}
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = piecewise;
var _value = _interopRequireDefault(require("./value.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function piecewise(interpolate, values) {
if (values === undefined) values = interpolate, interpolate = _value.default;
var i = 0,
n = values.length - 1,
v = values[0],
I = new Array(n < 0 ? 0 : n);
while (i < n) I[i] = interpolate(v, v = values[++i]);
return function (t) {
var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n)));
return I[i](t - i);
};
}
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(interpolator, n) {
var samples = new Array(n);
for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
return samples;
}
@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.rgbBasisClosed = exports.rgbBasis = exports.default = void 0;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _basis = _interopRequireDefault(require("./basis.js"));
var _basisClosed = _interopRequireDefault(require("./basisClosed.js"));
var _color = _interopRequireWildcard(require("./color.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function rgbGamma(y) {
var color = (0, _color.gamma)(y);
function rgb(start, end) {
var r = color((start = (0, _index.rgb)(start)).r, (end = (0, _index.rgb)(end)).r),
g = color(start.g, end.g),
b = color(start.b, end.b),
opacity = (0, _color.default)(start.opacity, end.opacity);
return function (t) {
start.r = r(t);
start.g = g(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
rgb.gamma = rgbGamma;
return rgb;
}(1);
exports.default = _default;
function rgbSpline(spline) {
return function (colors) {
var n = colors.length,
r = new Array(n),
g = new Array(n),
b = new Array(n),
i,
color;
for (i = 0; i < n; ++i) {
color = (0, _index.rgb)(colors[i]);
r[i] = color.r || 0;
g[i] = color.g || 0;
b[i] = color.b || 0;
}
r = spline(r);
g = spline(g);
b = spline(b);
color.opacity = 1;
return function (t) {
color.r = r(t);
color.g = g(t);
color.b = b(t);
return color + "";
};
};
}
var rgbBasis = rgbSpline(_basis.default);
exports.rgbBasis = rgbBasis;
var rgbBasisClosed = rgbSpline(_basisClosed.default);
exports.rgbBasisClosed = rgbBasisClosed;
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(a, b) {
return a = +a, b = +b, function (t) {
return Math.round(a * (1 - t) + b * t);
};
}
@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _number = _interopRequireDefault(require("./number.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
reB = new RegExp(reA.source, "g");
function zero(b) {
return function () {
return b;
};
}
function one(b) {
return function (t) {
return b(t) + "";
};
}
function _default(a, b) {
var bi = reA.lastIndex = reB.lastIndex = 0,
// scan index for next number in b
am,
// current match in a
bm,
// current match in b
bs,
// string preceding current number in b, if any
i = -1,
// index in s
s = [],
// string constants and placeholders
q = []; // number interpolators
// Coerce inputs to strings.
a = a + "", b = b + ""; // Interpolate pairs of numbers in a & b.
while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
if ((bs = bm.index) > bi) {
// a string precedes the next number in b
bs = b.slice(bi, bs);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
}
if ((am = am[0]) === (bm = bm[0])) {
// numbers in a & b match
if (s[i]) s[i] += bm; // coalesce with previous string
else s[++i] = bm;
} else {
// interpolate non-matching numbers
s[++i] = null;
q.push({
i: i,
x: (0, _number.default)(am, bm)
});
}
bi = reB.lastIndex;
} // Add remains of b.
if (bi < b.length) {
bs = b.slice(bi);
if (s[i]) s[i] += bs; // coalesce with previous string
else s[++i] = bs;
} // Special optimization for only a single match.
// Otherwise, interpolate each of the numbers and rejoin the string.
return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
return s.join("");
});
}
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.identity = void 0;
var degrees = 180 / Math.PI;
var identity = {
translateX: 0,
translateY: 0,
rotate: 0,
skewX: 0,
scaleX: 1,
scaleY: 1
};
exports.identity = identity;
function _default(a, b, c, d, e, f) {
var scaleX, scaleY, skewX;
if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
return {
translateX: e,
translateY: f,
rotate: Math.atan2(b, a) * degrees,
skewX: Math.atan(skewX) * degrees,
scaleX: scaleX,
scaleY: scaleY
};
}
@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.interpolateTransformSvg = exports.interpolateTransformCss = void 0;
var _number = _interopRequireDefault(require("../number.js"));
var _parse = require("./parse.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function interpolateTransform(parse, pxComma, pxParen, degParen) {
function pop(s) {
return s.length ? s.pop() + " " : "";
}
function translate(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push("translate(", null, pxComma, null, pxParen);
q.push({
i: i - 4,
x: (0, _number.default)(xa, xb)
}, {
i: i - 2,
x: (0, _number.default)(ya, yb)
});
} else if (xb || yb) {
s.push("translate(" + xb + pxComma + yb + pxParen);
}
}
function rotate(a, b, s, q) {
if (a !== b) {
if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path
q.push({
i: s.push(pop(s) + "rotate(", null, degParen) - 2,
x: (0, _number.default)(a, b)
});
} else if (b) {
s.push(pop(s) + "rotate(" + b + degParen);
}
}
function skewX(a, b, s, q) {
if (a !== b) {
q.push({
i: s.push(pop(s) + "skewX(", null, degParen) - 2,
x: (0, _number.default)(a, b)
});
} else if (b) {
s.push(pop(s) + "skewX(" + b + degParen);
}
}
function scale(xa, ya, xb, yb, s, q) {
if (xa !== xb || ya !== yb) {
var i = s.push(pop(s) + "scale(", null, ",", null, ")");
q.push({
i: i - 4,
x: (0, _number.default)(xa, xb)
}, {
i: i - 2,
x: (0, _number.default)(ya, yb)
});
} else if (xb !== 1 || yb !== 1) {
s.push(pop(s) + "scale(" + xb + "," + yb + ")");
}
}
return function (a, b) {
var s = [],
// string constants and placeholders
q = []; // number interpolators
a = parse(a), b = parse(b);
translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
rotate(a.rotate, b.rotate, s, q);
skewX(a.skewX, b.skewX, s, q);
scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
a = b = null; // gc
return function (t) {
var i = -1,
n = q.length,
o;
while (++i < n) s[(o = q[i]).i] = o.x(t);
return s.join("");
};
};
}
var interpolateTransformCss = interpolateTransform(_parse.parseCss, "px, ", "px)", "deg)");
exports.interpolateTransformCss = interpolateTransformCss;
var interpolateTransformSvg = interpolateTransform(_parse.parseSvg, ", ", ")", ")");
exports.interpolateTransformSvg = interpolateTransformSvg;
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseCss = parseCss;
exports.parseSvg = parseSvg;
var _decompose = _interopRequireWildcard(require("./decompose.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var svgNode;
/* eslint-disable no-undef */
function parseCss(value) {
const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
return m.isIdentity ? _decompose.identity : (0, _decompose.default)(m.a, m.b, m.c, m.d, m.e, m.f);
}
function parseSvg(value) {
if (value == null) return _decompose.identity;
if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
svgNode.setAttribute("transform", value);
if (!(value = svgNode.transform.baseVal.consolidate())) return _decompose.identity;
value = value.matrix;
return (0, _decompose.default)(value.a, value.b, value.c, value.d, value.e, value.f);
}
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../../lib-vendor/d3-color/src/index.js");
var _rgb = _interopRequireDefault(require("./rgb.js"));
var _array = require("./array.js");
var _date = _interopRequireDefault(require("./date.js"));
var _number = _interopRequireDefault(require("./number.js"));
var _object = _interopRequireDefault(require("./object.js"));
var _string = _interopRequireDefault(require("./string.js"));
var _constant = _interopRequireDefault(require("./constant.js"));
var _numberArray = _interopRequireWildcard(require("./numberArray.js"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(a, b) {
var t = typeof b,
c;
return b == null || t === "boolean" ? (0, _constant.default)(b) : (t === "number" ? _number.default : t === "string" ? (c = (0, _index.color)(b)) ? (b = c, _rgb.default) : _string.default : b instanceof _index.color ? _rgb.default : b instanceof Date ? _date.default : (0, _numberArray.isNumberArray)(b) ? _numberArray.default : Array.isArray(b) ? _array.genericArray : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? _object.default : _number.default)(a, b);
}
@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var epsilon2 = 1e-12;
function cosh(x) {
return ((x = Math.exp(x)) + 1 / x) / 2;
}
function sinh(x) {
return ((x = Math.exp(x)) - 1 / x) / 2;
}
function tanh(x) {
return ((x = Math.exp(2 * x)) - 1) / (x + 1);
}
var _default = function zoomRho(rho, rho2, rho4) {
// p0 = [ux0, uy0, w0]
// p1 = [ux1, uy1, w1]
function zoom(p0, p1) {
var ux0 = p0[0],
uy0 = p0[1],
w0 = p0[2],
ux1 = p1[0],
uy1 = p1[1],
w1 = p1[2],
dx = ux1 - ux0,
dy = uy1 - uy0,
d2 = dx * dx + dy * dy,
i,
S; // Special case for u0 ≅ u1.
if (d2 < epsilon2) {
S = Math.log(w1 / w0) / rho;
i = function (t) {
return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
};
} // General case.
else {
var d1 = Math.sqrt(d2),
b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
S = (r1 - r0) / rho;
i = function (t) {
var s = t * S,
coshr0 = cosh(r0),
u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
};
}
i.duration = S * 1000 * rho / Math.SQRT2;
return i;
}
zoom.rho = function (_) {
var _1 = Math.max(1e-3, +_),
_2 = _1 * _1,
_4 = _2 * _2;
return zoomRho(_1, _2, _4);
};
return zoom;
}(Math.SQRT2, 2, 4);
exports.default = _default;
+13
View File
@@ -0,0 +1,13 @@
Copyright 2015-2021 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+15
View File
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "path", {
enumerable: true,
get: function () {
return _path.default;
}
});
var _path = _interopRequireDefault(require("./path.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+120
View File
@@ -0,0 +1,120 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const pi = Math.PI,
tau = 2 * pi,
epsilon = 1e-6,
tauEpsilon = tau - epsilon;
function Path() {
this._x0 = this._y0 = // start of current subpath
this._x1 = this._y1 = null; // end of current subpath
this._ = "";
}
function path() {
return new Path();
}
Path.prototype = path.prototype = {
constructor: Path,
moveTo: function (x, y) {
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
},
closePath: function () {
if (this._x1 !== null) {
this._x1 = this._x0, this._y1 = this._y0;
this._ += "Z";
}
},
lineTo: function (x, y) {
this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
},
quadraticCurveTo: function (x1, y1, x, y) {
this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
},
bezierCurveTo: function (x1, y1, x2, y2, x, y) {
this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
},
arcTo: function (x1, y1, x2, y2, r) {
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
var x0 = this._x1,
y0 = this._y1,
x21 = x2 - x1,
y21 = y2 - y1,
x01 = x0 - x1,
y01 = y0 - y1,
l01_2 = x01 * x01 + y01 * y01; // Is the radius negative? Error.
if (r < 0) throw new Error("negative radius: " + r); // Is this path empty? Move to (x1,y1).
if (this._x1 === null) {
this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
} // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.
else if (!(l01_2 > epsilon)) ; // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?
// Equivalently, is (x1,y1) coincident with (x2,y2)?
// Or, is the radius zero? Line to (x1,y1).
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
} // Otherwise, draw an arc!
else {
var x20 = x2 - x0,
y20 = y2 - y0,
l21_2 = x21 * x21 + y21 * y21,
l20_2 = x20 * x20 + y20 * y20,
l21 = Math.sqrt(l21_2),
l01 = Math.sqrt(l01_2),
l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
t01 = l / l01,
t21 = l / l21; // If the start tangent is not coincident with (x0,y0), line to.
if (Math.abs(t01 - 1) > epsilon) {
this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
}
this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
}
},
arc: function (x, y, r, a0, a1, ccw) {
x = +x, y = +y, r = +r, ccw = !!ccw;
var dx = r * Math.cos(a0),
dy = r * Math.sin(a0),
x0 = x + dx,
y0 = y + dy,
cw = 1 ^ ccw,
da = ccw ? a0 - a1 : a1 - a0; // Is the radius negative? Error.
if (r < 0) throw new Error("negative radius: " + r); // Is this path empty? Move to (x0,y0).
if (this._x1 === null) {
this._ += "M" + x0 + "," + y0;
} // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).
else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
this._ += "L" + x0 + "," + y0;
} // Is this arc empty? Were done.
if (!r) return; // Does the angle go the wrong way? Flip the direction.
if (da < 0) da = da % tau + tau; // Is this a complete circle? Draw two arcs to complete the circle.
if (da > tauEpsilon) {
this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
} // Is this arc non-empty? Draw an arc!
else if (da > epsilon) {
this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
}
},
rect: function (x, y, w, h) {
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
},
toString: function () {
return this._;
}
};
var _default = path;
exports.default = _default;
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2021 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+109
View File
@@ -0,0 +1,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = band;
exports.point = point;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _init = require("./init.js");
var _ordinal = _interopRequireDefault(require("./ordinal.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function band() {
var scale = (0, _ordinal.default)().unknown(undefined),
domain = scale.domain,
ordinalRange = scale.range,
r0 = 0,
r1 = 1,
step,
bandwidth,
round = false,
paddingInner = 0,
paddingOuter = 0,
align = 0.5;
delete scale.unknown;
function rescale() {
var n = domain().length,
reverse = r1 < r0,
start = reverse ? r1 : r0,
stop = reverse ? r0 : r1;
step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
if (round) step = Math.floor(step);
start += (stop - start - step * (n - paddingInner)) * align;
bandwidth = step * (1 - paddingInner);
if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
var values = (0, _index.range)(n).map(function (i) {
return start + step * i;
});
return ordinalRange(reverse ? values.reverse() : values);
}
scale.domain = function (_) {
return arguments.length ? (domain(_), rescale()) : domain();
};
scale.range = function (_) {
return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
};
scale.rangeRound = function (_) {
return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale();
};
scale.bandwidth = function () {
return bandwidth;
};
scale.step = function () {
return step;
};
scale.round = function (_) {
return arguments.length ? (round = !!_, rescale()) : round;
};
scale.padding = function (_) {
return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
};
scale.paddingInner = function (_) {
return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
};
scale.paddingOuter = function (_) {
return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
};
scale.align = function (_) {
return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
};
scale.copy = function () {
return band(domain(), [r0, r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align);
};
return _init.initRange.apply(rescale(), arguments);
}
function pointish(scale) {
var copy = scale.copy;
scale.padding = scale.paddingOuter;
delete scale.paddingInner;
delete scale.paddingOuter;
scale.copy = function () {
return pointish(copy());
};
return scale;
}
function point() {
return pointish(band.apply(null, arguments).paddingInner(1));
}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = colors;
function colors(s) {
return s.match(/.{6}/g).map(function (x) {
return "#" + x;
});
}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = constants;
function constants(x) {
return function () {
return x;
};
}
@@ -0,0 +1,140 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.copy = copy;
exports.default = continuous;
exports.identity = identity;
exports.transformer = transformer;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _index2 = require("../../../lib-vendor/d3-interpolate/src/index.js");
var _constant = _interopRequireDefault(require("./constant.js"));
var _number = _interopRequireDefault(require("./number.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var unit = [0, 1];
function identity(x) {
return x;
}
function normalize(a, b) {
return (b -= a = +a) ? function (x) {
return (x - a) / b;
} : (0, _constant.default)(isNaN(b) ? NaN : 0.5);
}
function clamper(a, b) {
var t;
if (a > b) t = a, a = b, b = t;
return function (x) {
return Math.max(a, Math.min(b, x));
};
} // normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
function bimap(domain, range, interpolate) {
var d0 = domain[0],
d1 = domain[1],
r0 = range[0],
r1 = range[1];
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
return function (x) {
return r0(d0(x));
};
}
function polymap(domain, range, interpolate) {
var j = Math.min(domain.length, range.length) - 1,
d = new Array(j),
r = new Array(j),
i = -1; // Reverse descending domains.
if (domain[j] < domain[0]) {
domain = domain.slice().reverse();
range = range.slice().reverse();
}
while (++i < j) {
d[i] = normalize(domain[i], domain[i + 1]);
r[i] = interpolate(range[i], range[i + 1]);
}
return function (x) {
var i = (0, _index.bisect)(domain, x, 1, j) - 1;
return r[i](d[i](x));
};
}
function copy(source, target) {
return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
}
function transformer() {
var domain = unit,
range = unit,
interpolate = _index2.interpolate,
transform,
untransform,
unknown,
clamp = identity,
piecewise,
output,
input;
function rescale() {
var n = Math.min(domain.length, range.length);
if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]);
piecewise = n > 2 ? polymap : bimap;
output = input = null;
return scale;
}
function scale(x) {
return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x)));
}
scale.invert = function (y) {
return clamp(untransform((input || (input = piecewise(range, domain.map(transform), _index2.interpolateNumber)))(y)));
};
scale.domain = function (_) {
return arguments.length ? (domain = Array.from(_, _number.default), rescale()) : domain.slice();
};
scale.range = function (_) {
return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
};
scale.rangeRound = function (_) {
return range = Array.from(_), interpolate = _index2.interpolateRound, rescale();
};
scale.clamp = function (_) {
return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity;
};
scale.interpolate = function (_) {
return arguments.length ? (interpolate = _, rescale()) : interpolate;
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
return function (t, u) {
transform = t, untransform = u;
return rescale();
};
}
function continuous() {
return transformer()(identity, identity);
}
+121
View File
@@ -0,0 +1,121 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = diverging;
exports.divergingLog = divergingLog;
exports.divergingPow = divergingPow;
exports.divergingSqrt = divergingSqrt;
exports.divergingSymlog = divergingSymlog;
var _index = require("../../../lib-vendor/d3-interpolate/src/index.js");
var _continuous = require("./continuous.js");
var _init = require("./init.js");
var _linear = require("./linear.js");
var _log = require("./log.js");
var _sequential = require("./sequential.js");
var _symlog = require("./symlog.js");
var _pow = require("./pow.js");
function transformer() {
var x0 = 0,
x1 = 0.5,
x2 = 1,
s = 1,
t0,
t1,
t2,
k10,
k21,
interpolator = _continuous.identity,
transform,
clamp = false,
unknown;
function scale(x) {
return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (s * x < s * t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x));
}
scale.domain = function (_) {
return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1, scale) : [x0, x1, x2];
};
scale.clamp = function (_) {
return arguments.length ? (clamp = !!_, scale) : clamp;
};
scale.interpolator = function (_) {
return arguments.length ? (interpolator = _, scale) : interpolator;
};
function range(interpolate) {
return function (_) {
var r0, r1, r2;
return arguments.length ? ([r0, r1, r2] = _, interpolator = (0, _index.piecewise)(interpolate, [r0, r1, r2]), scale) : [interpolator(0), interpolator(0.5), interpolator(1)];
};
}
scale.range = range(_index.interpolate);
scale.rangeRound = range(_index.interpolateRound);
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
return function (t) {
transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1;
return scale;
};
}
function diverging() {
var scale = (0, _linear.linearish)(transformer()(_continuous.identity));
scale.copy = function () {
return (0, _sequential.copy)(scale, diverging());
};
return _init.initInterpolator.apply(scale, arguments);
}
function divergingLog() {
var scale = (0, _log.loggish)(transformer()).domain([0.1, 1, 10]);
scale.copy = function () {
return (0, _sequential.copy)(scale, divergingLog()).base(scale.base());
};
return _init.initInterpolator.apply(scale, arguments);
}
function divergingSymlog() {
var scale = (0, _symlog.symlogish)(transformer());
scale.copy = function () {
return (0, _sequential.copy)(scale, divergingSymlog()).constant(scale.constant());
};
return _init.initInterpolator.apply(scale, arguments);
}
function divergingPow() {
var scale = (0, _pow.powish)(transformer());
scale.copy = function () {
return (0, _sequential.copy)(scale, divergingPow()).exponent(scale.exponent());
};
return _init.initInterpolator.apply(scale, arguments);
}
function divergingSqrt() {
return divergingPow.apply(null, arguments).exponent(0.5);
}
+37
View File
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = identity;
var _linear = require("./linear.js");
var _number = _interopRequireDefault(require("./number.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function identity(domain) {
var unknown;
function scale(x) {
return x == null || isNaN(x = +x) ? unknown : x;
}
scale.invert = scale;
scale.domain = scale.range = function (_) {
return arguments.length ? (domain = Array.from(_, _number.default), scale) : domain.slice();
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function () {
return identity(domain).unknown(unknown);
};
domain = arguments.length ? Array.from(domain, _number.default) : [0, 1];
return (0, _linear.linearish)(scale);
}
+213
View File
@@ -0,0 +1,213 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "scaleBand", {
enumerable: true,
get: function () {
return _band.default;
}
});
Object.defineProperty(exports, "scaleDiverging", {
enumerable: true,
get: function () {
return _diverging.default;
}
});
Object.defineProperty(exports, "scaleDivergingLog", {
enumerable: true,
get: function () {
return _diverging.divergingLog;
}
});
Object.defineProperty(exports, "scaleDivergingPow", {
enumerable: true,
get: function () {
return _diverging.divergingPow;
}
});
Object.defineProperty(exports, "scaleDivergingSqrt", {
enumerable: true,
get: function () {
return _diverging.divergingSqrt;
}
});
Object.defineProperty(exports, "scaleDivergingSymlog", {
enumerable: true,
get: function () {
return _diverging.divergingSymlog;
}
});
Object.defineProperty(exports, "scaleIdentity", {
enumerable: true,
get: function () {
return _identity.default;
}
});
Object.defineProperty(exports, "scaleImplicit", {
enumerable: true,
get: function () {
return _ordinal.implicit;
}
});
Object.defineProperty(exports, "scaleLinear", {
enumerable: true,
get: function () {
return _linear.default;
}
});
Object.defineProperty(exports, "scaleLog", {
enumerable: true,
get: function () {
return _log.default;
}
});
Object.defineProperty(exports, "scaleOrdinal", {
enumerable: true,
get: function () {
return _ordinal.default;
}
});
Object.defineProperty(exports, "scalePoint", {
enumerable: true,
get: function () {
return _band.point;
}
});
Object.defineProperty(exports, "scalePow", {
enumerable: true,
get: function () {
return _pow.default;
}
});
Object.defineProperty(exports, "scaleQuantile", {
enumerable: true,
get: function () {
return _quantile.default;
}
});
Object.defineProperty(exports, "scaleQuantize", {
enumerable: true,
get: function () {
return _quantize.default;
}
});
Object.defineProperty(exports, "scaleRadial", {
enumerable: true,
get: function () {
return _radial.default;
}
});
Object.defineProperty(exports, "scaleSequential", {
enumerable: true,
get: function () {
return _sequential.default;
}
});
Object.defineProperty(exports, "scaleSequentialLog", {
enumerable: true,
get: function () {
return _sequential.sequentialLog;
}
});
Object.defineProperty(exports, "scaleSequentialPow", {
enumerable: true,
get: function () {
return _sequential.sequentialPow;
}
});
Object.defineProperty(exports, "scaleSequentialQuantile", {
enumerable: true,
get: function () {
return _sequentialQuantile.default;
}
});
Object.defineProperty(exports, "scaleSequentialSqrt", {
enumerable: true,
get: function () {
return _sequential.sequentialSqrt;
}
});
Object.defineProperty(exports, "scaleSequentialSymlog", {
enumerable: true,
get: function () {
return _sequential.sequentialSymlog;
}
});
Object.defineProperty(exports, "scaleSqrt", {
enumerable: true,
get: function () {
return _pow.sqrt;
}
});
Object.defineProperty(exports, "scaleSymlog", {
enumerable: true,
get: function () {
return _symlog.default;
}
});
Object.defineProperty(exports, "scaleThreshold", {
enumerable: true,
get: function () {
return _threshold.default;
}
});
Object.defineProperty(exports, "scaleTime", {
enumerable: true,
get: function () {
return _time.default;
}
});
Object.defineProperty(exports, "scaleUtc", {
enumerable: true,
get: function () {
return _utcTime.default;
}
});
Object.defineProperty(exports, "tickFormat", {
enumerable: true,
get: function () {
return _tickFormat.default;
}
});
var _band = _interopRequireWildcard(require("./band.js"));
var _identity = _interopRequireDefault(require("./identity.js"));
var _linear = _interopRequireDefault(require("./linear.js"));
var _log = _interopRequireDefault(require("./log.js"));
var _symlog = _interopRequireDefault(require("./symlog.js"));
var _ordinal = _interopRequireWildcard(require("./ordinal.js"));
var _pow = _interopRequireWildcard(require("./pow.js"));
var _radial = _interopRequireDefault(require("./radial.js"));
var _quantile = _interopRequireDefault(require("./quantile.js"));
var _quantize = _interopRequireDefault(require("./quantize.js"));
var _threshold = _interopRequireDefault(require("./threshold.js"));
var _time = _interopRequireDefault(require("./time.js"));
var _utcTime = _interopRequireDefault(require("./utcTime.js"));
var _sequential = _interopRequireWildcard(require("./sequential.js"));
var _sequentialQuantile = _interopRequireDefault(require("./sequentialQuantile.js"));
var _diverging = _interopRequireWildcard(require("./diverging.js"));
var _tickFormat = _interopRequireDefault(require("./tickFormat.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.initInterpolator = initInterpolator;
exports.initRange = initRange;
function initRange(domain, range) {
switch (arguments.length) {
case 0:
break;
case 1:
this.range(domain);
break;
default:
this.range(range).domain(domain);
break;
}
return this;
}
function initInterpolator(domain, interpolator) {
switch (arguments.length) {
case 0:
break;
case 1:
{
if (typeof domain === "function") this.interpolator(domain);else this.range(domain);
break;
}
default:
{
this.domain(domain);
if (typeof interpolator === "function") this.interpolator(interpolator);else this.range(interpolator);
break;
}
}
return this;
}
+88
View File
@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = linear;
exports.linearish = linearish;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _continuous = _interopRequireWildcard(require("./continuous.js"));
var _init = require("./init.js");
var _tickFormat = _interopRequireDefault(require("./tickFormat.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function linearish(scale) {
var domain = scale.domain;
scale.ticks = function (count) {
var d = domain();
return (0, _index.ticks)(d[0], d[d.length - 1], count == null ? 10 : count);
};
scale.tickFormat = function (count, specifier) {
var d = domain();
return (0, _tickFormat.default)(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
};
scale.nice = function (count) {
if (count == null) count = 10;
var d = domain();
var i0 = 0;
var i1 = d.length - 1;
var start = d[i0];
var stop = d[i1];
var prestep;
var step;
var maxIter = 10;
if (stop < start) {
step = start, start = stop, stop = step;
step = i0, i0 = i1, i1 = step;
}
while (maxIter-- > 0) {
step = (0, _index.tickIncrement)(start, stop, count);
if (step === prestep) {
d[i0] = start;
d[i1] = stop;
return domain(d);
} else if (step > 0) {
start = Math.floor(start / step) * step;
stop = Math.ceil(stop / step) * step;
} else if (step < 0) {
start = Math.ceil(start * step) / step;
stop = Math.floor(stop * step) / step;
} else {
break;
}
prestep = step;
}
return scale;
};
return scale;
}
function linear() {
var scale = (0, _continuous.default)();
scale.copy = function () {
return (0, _continuous.copy)(scale, linear());
};
_init.initRange.apply(scale, arguments);
return linearish(scale);
}
+156
View File
@@ -0,0 +1,156 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = log;
exports.loggish = loggish;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _index2 = require("../../../lib-vendor/d3-format/src/index.js");
var _nice = _interopRequireDefault(require("./nice.js"));
var _continuous = require("./continuous.js");
var _init = require("./init.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function transformLog(x) {
return Math.log(x);
}
function transformExp(x) {
return Math.exp(x);
}
function transformLogn(x) {
return -Math.log(-x);
}
function transformExpn(x) {
return -Math.exp(-x);
}
function pow10(x) {
return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x;
}
function powp(base) {
return base === 10 ? pow10 : base === Math.E ? Math.exp : x => Math.pow(base, x);
}
function logp(base) {
return base === Math.E ? Math.log : base === 10 && Math.log10 || base === 2 && Math.log2 || (base = Math.log(base), x => Math.log(x) / base);
}
function reflect(f) {
return (x, k) => -f(-x, k);
}
function loggish(transform) {
const scale = transform(transformLog, transformExp);
const domain = scale.domain;
let base = 10;
let logs;
let pows;
function rescale() {
logs = logp(base), pows = powp(base);
if (domain()[0] < 0) {
logs = reflect(logs), pows = reflect(pows);
transform(transformLogn, transformExpn);
} else {
transform(transformLog, transformExp);
}
return scale;
}
scale.base = function (_) {
return arguments.length ? (base = +_, rescale()) : base;
};
scale.domain = function (_) {
return arguments.length ? (domain(_), rescale()) : domain();
};
scale.ticks = count => {
const d = domain();
let u = d[0];
let v = d[d.length - 1];
const r = v < u;
if (r) [u, v] = [v, u];
let i = logs(u);
let j = logs(v);
let k;
let t;
const n = count == null ? 10 : +count;
let z = [];
if (!(base % 1) && j - i < n) {
i = Math.floor(i), j = Math.ceil(j);
if (u > 0) for (; i <= j; ++i) {
for (k = 1; k < base; ++k) {
t = i < 0 ? k / pows(-i) : k * pows(i);
if (t < u) continue;
if (t > v) break;
z.push(t);
}
} else for (; i <= j; ++i) {
for (k = base - 1; k >= 1; --k) {
t = i > 0 ? k / pows(-i) : k * pows(i);
if (t < u) continue;
if (t > v) break;
z.push(t);
}
}
if (z.length * 2 < n) z = (0, _index.ticks)(u, v, n);
} else {
z = (0, _index.ticks)(i, j, Math.min(j - i, n)).map(pows);
}
return r ? z.reverse() : z;
};
scale.tickFormat = (count, specifier) => {
if (count == null) count = 10;
if (specifier == null) specifier = base === 10 ? "s" : ",";
if (typeof specifier !== "function") {
if (!(base % 1) && (specifier = (0, _index2.formatSpecifier)(specifier)).precision == null) specifier.trim = true;
specifier = (0, _index2.format)(specifier);
}
if (count === Infinity) return specifier;
const k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
return d => {
let i = d / pows(Math.round(logs(d)));
if (i * base < base - 0.5) i *= base;
return i <= k ? specifier(d) : "";
};
};
scale.nice = () => {
return domain((0, _nice.default)(domain(), {
floor: x => pows(Math.floor(logs(x))),
ceil: x => pows(Math.ceil(logs(x)))
}));
};
return scale;
}
function log() {
const scale = loggish((0, _continuous.transformer)()).domain([1, 10]);
scale.copy = () => (0, _continuous.copy)(scale, log()).base(scale.base());
_init.initRange.apply(scale, arguments);
return scale;
}
+24
View File
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nice;
function nice(domain, interval) {
domain = domain.slice();
var i0 = 0,
i1 = domain.length - 1,
x0 = domain[i0],
x1 = domain[i1],
t;
if (x1 < x0) {
t = i0, i0 = i1, i1 = t;
t = x0, x0 = x1, x1 = t;
}
domain[i0] = interval.floor(x0);
domain[i1] = interval.ceil(x1);
return domain;
}
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = number;
function number(x) {
return +x;
}
+60
View File
@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ordinal;
exports.implicit = void 0;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _init = require("./init.js");
const implicit = Symbol("implicit");
exports.implicit = implicit;
function ordinal() {
var index = new _index.InternMap(),
domain = [],
range = [],
unknown = implicit;
function scale(d) {
let i = index.get(d);
if (i === undefined) {
if (unknown !== implicit) return unknown;
index.set(d, i = domain.push(d) - 1);
}
return range[i % range.length];
}
scale.domain = function (_) {
if (!arguments.length) return domain.slice();
domain = [], index = new _index.InternMap();
for (const value of _) {
if (index.has(value)) continue;
index.set(value, domain.push(value) - 1);
}
return scale;
};
scale.range = function (_) {
return arguments.length ? (range = Array.from(_), scale) : range.slice();
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function () {
return ordinal(domain, range).unknown(unknown);
};
_init.initRange.apply(scale, arguments);
return scale;
}
+59
View File
@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = pow;
exports.powish = powish;
exports.sqrt = sqrt;
var _linear = require("./linear.js");
var _continuous = require("./continuous.js");
var _init = require("./init.js");
function transformPow(exponent) {
return function (x) {
return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
};
}
function transformSqrt(x) {
return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x);
}
function transformSquare(x) {
return x < 0 ? -x * x : x * x;
}
function powish(transform) {
var scale = transform(_continuous.identity, _continuous.identity),
exponent = 1;
function rescale() {
return exponent === 1 ? transform(_continuous.identity, _continuous.identity) : exponent === 0.5 ? transform(transformSqrt, transformSquare) : transform(transformPow(exponent), transformPow(1 / exponent));
}
scale.exponent = function (_) {
return arguments.length ? (exponent = +_, rescale()) : exponent;
};
return (0, _linear.linearish)(scale);
}
function pow() {
var scale = powish((0, _continuous.transformer)());
scale.copy = function () {
return (0, _continuous.copy)(scale, pow()).exponent(scale.exponent());
};
_init.initRange.apply(scale, arguments);
return scale;
}
function sqrt() {
return pow.apply(null, arguments).exponent(0.5);
}
+64
View File
@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = quantile;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _init = require("./init.js");
function quantile() {
var domain = [],
range = [],
thresholds = [],
unknown;
function rescale() {
var i = 0,
n = Math.max(1, range.length);
thresholds = new Array(n - 1);
while (++i < n) thresholds[i - 1] = (0, _index.quantileSorted)(domain, i / n);
return scale;
}
function scale(x) {
return x == null || isNaN(x = +x) ? unknown : range[(0, _index.bisect)(thresholds, x)];
}
scale.invertExtent = function (y) {
var i = range.indexOf(y);
return i < 0 ? [NaN, NaN] : [i > 0 ? thresholds[i - 1] : domain[0], i < thresholds.length ? thresholds[i] : domain[domain.length - 1]];
};
scale.domain = function (_) {
if (!arguments.length) return domain.slice();
domain = [];
for (let d of _) if (d != null && !isNaN(d = +d)) domain.push(d);
domain.sort(_index.ascending);
return rescale();
};
scale.range = function (_) {
return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.quantiles = function () {
return thresholds.slice();
};
scale.copy = function () {
return quantile().domain(domain).range(range).unknown(unknown);
};
return _init.initRange.apply(scale, arguments);
}
+61
View File
@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = quantize;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _linear = require("./linear.js");
var _init = require("./init.js");
function quantize() {
var x0 = 0,
x1 = 1,
n = 1,
domain = [0.5],
range = [0, 1],
unknown;
function scale(x) {
return x != null && x <= x ? range[(0, _index.bisect)(domain, x, 0, n)] : unknown;
}
function rescale() {
var i = -1;
domain = new Array(n);
while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1);
return scale;
}
scale.domain = function (_) {
return arguments.length ? ([x0, x1] = _, x0 = +x0, x1 = +x1, rescale()) : [x0, x1];
};
scale.range = function (_) {
return arguments.length ? (n = (range = Array.from(_)).length - 1, rescale()) : range.slice();
};
scale.invertExtent = function (y) {
var i = range.indexOf(y);
return i < 0 ? [NaN, NaN] : i < 1 ? [x0, domain[0]] : i >= n ? [domain[n - 1], x1] : [domain[i - 1], domain[i]];
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : scale;
};
scale.thresholds = function () {
return domain.slice();
};
scale.copy = function () {
return quantize().domain([x0, x1]).range(range).unknown(unknown);
};
return _init.initRange.apply((0, _linear.linearish)(scale), arguments);
}
+72
View File
@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = radial;
var _continuous = _interopRequireDefault(require("./continuous.js"));
var _init = require("./init.js");
var _linear = require("./linear.js");
var _number = _interopRequireDefault(require("./number.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function square(x) {
return Math.sign(x) * x * x;
}
function unsquare(x) {
return Math.sign(x) * Math.sqrt(Math.abs(x));
}
function radial() {
var squared = (0, _continuous.default)(),
range = [0, 1],
round = false,
unknown;
function scale(x) {
var y = unsquare(squared(x));
return isNaN(y) ? unknown : round ? Math.round(y) : y;
}
scale.invert = function (y) {
return squared.invert(square(y));
};
scale.domain = function (_) {
return arguments.length ? (squared.domain(_), scale) : squared.domain();
};
scale.range = function (_) {
return arguments.length ? (squared.range((range = Array.from(_, _number.default)).map(square)), scale) : range.slice();
};
scale.rangeRound = function (_) {
return scale.range(_).round(true);
};
scale.round = function (_) {
return arguments.length ? (round = !!_, scale) : round;
};
scale.clamp = function (_) {
return arguments.length ? (squared.clamp(_), scale) : squared.clamp();
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function () {
return radial(squared.domain(), range).round(round).clamp(squared.clamp()).unknown(unknown);
};
_init.initRange.apply(scale, arguments);
return (0, _linear.linearish)(scale);
}
@@ -0,0 +1,120 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.copy = copy;
exports.default = sequential;
exports.sequentialLog = sequentialLog;
exports.sequentialPow = sequentialPow;
exports.sequentialSqrt = sequentialSqrt;
exports.sequentialSymlog = sequentialSymlog;
var _index = require("../../../lib-vendor/d3-interpolate/src/index.js");
var _continuous = require("./continuous.js");
var _init = require("./init.js");
var _linear = require("./linear.js");
var _log = require("./log.js");
var _symlog = require("./symlog.js");
var _pow = require("./pow.js");
function transformer() {
var x0 = 0,
x1 = 1,
t0,
t1,
k10,
transform,
interpolator = _continuous.identity,
clamp = false,
unknown;
function scale(x) {
return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
}
scale.domain = function (_) {
return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
};
scale.clamp = function (_) {
return arguments.length ? (clamp = !!_, scale) : clamp;
};
scale.interpolator = function (_) {
return arguments.length ? (interpolator = _, scale) : interpolator;
};
function range(interpolate) {
return function (_) {
var r0, r1;
return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
};
}
scale.range = range(_index.interpolate);
scale.rangeRound = range(_index.interpolateRound);
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
return function (t) {
transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
return scale;
};
}
function copy(source, target) {
return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown());
}
function sequential() {
var scale = (0, _linear.linearish)(transformer()(_continuous.identity));
scale.copy = function () {
return copy(scale, sequential());
};
return _init.initInterpolator.apply(scale, arguments);
}
function sequentialLog() {
var scale = (0, _log.loggish)(transformer()).domain([1, 10]);
scale.copy = function () {
return copy(scale, sequentialLog()).base(scale.base());
};
return _init.initInterpolator.apply(scale, arguments);
}
function sequentialSymlog() {
var scale = (0, _symlog.symlogish)(transformer());
scale.copy = function () {
return copy(scale, sequentialSymlog()).constant(scale.constant());
};
return _init.initInterpolator.apply(scale, arguments);
}
function sequentialPow() {
var scale = (0, _pow.powish)(transformer());
scale.copy = function () {
return copy(scale, sequentialPow()).exponent(scale.exponent());
};
return _init.initInterpolator.apply(scale, arguments);
}
function sequentialSqrt() {
return sequentialPow.apply(null, arguments).exponent(0.5);
}
@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = sequentialQuantile;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _continuous = require("./continuous.js");
var _init = require("./init.js");
function sequentialQuantile() {
var domain = [],
interpolator = _continuous.identity;
function scale(x) {
if (x != null && !isNaN(x = +x)) return interpolator(((0, _index.bisect)(domain, x, 1) - 1) / (domain.length - 1));
}
scale.domain = function (_) {
if (!arguments.length) return domain.slice();
domain = [];
for (let d of _) if (d != null && !isNaN(d = +d)) domain.push(d);
domain.sort(_index.ascending);
return scale;
};
scale.interpolator = function (_) {
return arguments.length ? (interpolator = _, scale) : interpolator;
};
scale.range = function () {
return domain.map((d, i) => interpolator(i / (domain.length - 1)));
};
scale.quantiles = function (n) {
return Array.from({
length: n + 1
}, (_, i) => (0, _index.quantile)(domain, i / n));
};
scale.copy = function () {
return sequentialQuantile(interpolator).domain(domain);
};
return _init.initInterpolator.apply(scale, arguments);
}
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = symlog;
exports.symlogish = symlogish;
var _linear = require("./linear.js");
var _continuous = require("./continuous.js");
var _init = require("./init.js");
function transformSymlog(c) {
return function (x) {
return Math.sign(x) * Math.log1p(Math.abs(x / c));
};
}
function transformSymexp(c) {
return function (x) {
return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
};
}
function symlogish(transform) {
var c = 1,
scale = transform(transformSymlog(c), transformSymexp(c));
scale.constant = function (_) {
return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c;
};
return (0, _linear.linearish)(scale);
}
function symlog() {
var scale = symlogish((0, _continuous.transformer)());
scale.copy = function () {
return (0, _continuous.copy)(scale, symlog()).constant(scale.constant());
};
return _init.initRange.apply(scale, arguments);
}
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = threshold;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _init = require("./init.js");
function threshold() {
var domain = [0.5],
range = [0, 1],
unknown,
n = 1;
function scale(x) {
return x != null && x <= x ? range[(0, _index.bisect)(domain, x, 0, n)] : unknown;
}
scale.domain = function (_) {
return arguments.length ? (domain = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice();
};
scale.range = function (_) {
return arguments.length ? (range = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice();
};
scale.invertExtent = function (y) {
var i = range.indexOf(y);
return [domain[i - 1], domain[i]];
};
scale.unknown = function (_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function () {
return threshold().domain(domain).range(range).unknown(unknown);
};
return _init.initRange.apply(scale, arguments);
}
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tickFormat;
var _index = require("../../../lib-vendor/d3-array/src/index.js");
var _index2 = require("../../../lib-vendor/d3-format/src/index.js");
function tickFormat(start, stop, count, specifier) {
var step = (0, _index.tickStep)(start, stop, count),
precision;
specifier = (0, _index2.formatSpecifier)(specifier == null ? ",f" : specifier);
switch (specifier.type) {
case "s":
{
var value = Math.max(Math.abs(start), Math.abs(stop));
if (specifier.precision == null && !isNaN(precision = (0, _index2.precisionPrefix)(step, value))) specifier.precision = precision;
return (0, _index2.formatPrefix)(specifier, value);
}
case "":
case "e":
case "g":
case "p":
case "r":
{
if (specifier.precision == null && !isNaN(precision = (0, _index2.precisionRound)(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
break;
}
case "f":
case "%":
{
if (specifier.precision == null && !isNaN(precision = (0, _index2.precisionFixed)(step))) specifier.precision = precision - (specifier.type === "%") * 2;
break;
}
}
return (0, _index2.format)(specifier);
}
+82
View File
@@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.calendar = calendar;
exports.default = time;
var _index = require("../../../lib-vendor/d3-time/src/index.js");
var _index2 = require("../../../lib-vendor/d3-time-format/src/index.js");
var _continuous = _interopRequireWildcard(require("./continuous.js"));
var _init = require("./init.js");
var _nice = _interopRequireDefault(require("./nice.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function date(t) {
return new Date(t);
}
function number(t) {
return t instanceof Date ? +t : +new Date(+t);
}
function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) {
var scale = (0, _continuous.default)(),
invert = scale.invert,
domain = scale.domain;
var formatMillisecond = format(".%L"),
formatSecond = format(":%S"),
formatMinute = format("%I:%M"),
formatHour = format("%I %p"),
formatDay = format("%a %d"),
formatWeek = format("%b %d"),
formatMonth = format("%B"),
formatYear = format("%Y");
function tickFormat(date) {
return (second(date) < date ? formatMillisecond : minute(date) < date ? formatSecond : hour(date) < date ? formatMinute : day(date) < date ? formatHour : month(date) < date ? week(date) < date ? formatDay : formatWeek : year(date) < date ? formatMonth : formatYear)(date);
}
scale.invert = function (y) {
return new Date(invert(y));
};
scale.domain = function (_) {
return arguments.length ? domain(Array.from(_, number)) : domain().map(date);
};
scale.ticks = function (interval) {
var d = domain();
return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval);
};
scale.tickFormat = function (count, specifier) {
return specifier == null ? tickFormat : format(specifier);
};
scale.nice = function (interval) {
var d = domain();
if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval);
return interval ? domain((0, _nice.default)(d, interval)) : scale;
};
scale.copy = function () {
return (0, _continuous.copy)(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format));
};
return scale;
}
function time() {
return _init.initRange.apply(calendar(_index.timeTicks, _index.timeTickInterval, _index.timeYear, _index.timeMonth, _index.timeWeek, _index.timeDay, _index.timeHour, _index.timeMinute, _index.timeSecond, _index2.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments);
}
+18
View File
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = utcTime;
var _index = require("../../../lib-vendor/d3-time/src/index.js");
var _index2 = require("../../../lib-vendor/d3-time-format/src/index.js");
var _time = require("./time.js");
var _init = require("./init.js");
function utcTime() {
return _init.initRange.apply((0, _time.calendar)(_index.utcTicks, _index.utcTickInterval, _index.utcYear, _index.utcMonth, _index.utcWeek, _index.utcDay, _index.utcHour, _index.utcMinute, _index.utcSecond, _index2.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]), arguments);
}
+13
View File
@@ -0,0 +1,13 @@
Copyright 2010-2021 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+243
View File
@@ -0,0 +1,243 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../../lib-vendor/d3-path/src/index.js");
var _constant = _interopRequireDefault(require("./constant.js"));
var _math = require("./math.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function arcInnerRadius(d) {
return d.innerRadius;
}
function arcOuterRadius(d) {
return d.outerRadius;
}
function arcStartAngle(d) {
return d.startAngle;
}
function arcEndAngle(d) {
return d.endAngle;
}
function arcPadAngle(d) {
return d && d.padAngle; // Note: optional!
}
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
var x10 = x1 - x0,
y10 = y1 - y0,
x32 = x3 - x2,
y32 = y3 - y2,
t = y32 * x10 - x32 * y10;
if (t * t < _math.epsilon) return;
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
return [x0 + t * x10, y0 + t * y10];
} // Compute perpendicular offset line of length rc.
// http://mathworld.wolfram.com/Circle-LineIntersection.html
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
var x01 = x0 - x1,
y01 = y0 - y1,
lo = (cw ? rc : -rc) / (0, _math.sqrt)(x01 * x01 + y01 * y01),
ox = lo * y01,
oy = -lo * x01,
x11 = x0 + ox,
y11 = y0 + oy,
x10 = x1 + ox,
y10 = y1 + oy,
x00 = (x11 + x10) / 2,
y00 = (y11 + y10) / 2,
dx = x10 - x11,
dy = y10 - y11,
d2 = dx * dx + dy * dy,
r = r1 - rc,
D = x11 * y10 - x10 * y11,
d = (dy < 0 ? -1 : 1) * (0, _math.sqrt)((0, _math.max)(0, r * r * d2 - D * D)),
cx0 = (D * dy - dx * d) / d2,
cy0 = (-D * dx - dy * d) / d2,
cx1 = (D * dy + dx * d) / d2,
cy1 = (-D * dx + dy * d) / d2,
dx0 = cx0 - x00,
dy0 = cy0 - y00,
dx1 = cx1 - x00,
dy1 = cy1 - y00; // Pick the closer of the two intersection points.
// TODO Is there a faster way to determine which intersection to use?
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
return {
cx: cx0,
cy: cy0,
x01: -ox,
y01: -oy,
x11: cx0 * (r1 / r - 1),
y11: cy0 * (r1 / r - 1)
};
}
function _default() {
var innerRadius = arcInnerRadius,
outerRadius = arcOuterRadius,
cornerRadius = (0, _constant.default)(0),
padRadius = null,
startAngle = arcStartAngle,
endAngle = arcEndAngle,
padAngle = arcPadAngle,
context = null;
function arc() {
var buffer,
r,
r0 = +innerRadius.apply(this, arguments),
r1 = +outerRadius.apply(this, arguments),
a0 = startAngle.apply(this, arguments) - _math.halfPi,
a1 = endAngle.apply(this, arguments) - _math.halfPi,
da = (0, _math.abs)(a1 - a0),
cw = a1 > a0;
if (!context) context = buffer = (0, _index.path)(); // Ensure that the outer radius is always larger than the inner radius.
if (r1 < r0) r = r1, r1 = r0, r0 = r; // Is it a point?
if (!(r1 > _math.epsilon)) context.moveTo(0, 0); // Or is it a circle or annulus?
else if (da > _math.tau - _math.epsilon) {
context.moveTo(r1 * (0, _math.cos)(a0), r1 * (0, _math.sin)(a0));
context.arc(0, 0, r1, a0, a1, !cw);
if (r0 > _math.epsilon) {
context.moveTo(r0 * (0, _math.cos)(a1), r0 * (0, _math.sin)(a1));
context.arc(0, 0, r0, a1, a0, cw);
}
} // Or is it a circular or annular sector?
else {
var a01 = a0,
a11 = a1,
a00 = a0,
a10 = a1,
da0 = da,
da1 = da,
ap = padAngle.apply(this, arguments) / 2,
rp = ap > _math.epsilon && (padRadius ? +padRadius.apply(this, arguments) : (0, _math.sqrt)(r0 * r0 + r1 * r1)),
rc = (0, _math.min)((0, _math.abs)(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
rc0 = rc,
rc1 = rc,
t0,
t1; // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
if (rp > _math.epsilon) {
var p0 = (0, _math.asin)(rp / r0 * (0, _math.sin)(ap)),
p1 = (0, _math.asin)(rp / r1 * (0, _math.sin)(ap));
if ((da0 -= p0 * 2) > _math.epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;else da0 = 0, a00 = a10 = (a0 + a1) / 2;
if ((da1 -= p1 * 2) > _math.epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;else da1 = 0, a01 = a11 = (a0 + a1) / 2;
}
var x01 = r1 * (0, _math.cos)(a01),
y01 = r1 * (0, _math.sin)(a01),
x10 = r0 * (0, _math.cos)(a10),
y10 = r0 * (0, _math.sin)(a10); // Apply rounded corners?
if (rc > _math.epsilon) {
var x11 = r1 * (0, _math.cos)(a11),
y11 = r1 * (0, _math.sin)(a11),
x00 = r0 * (0, _math.cos)(a00),
y00 = r0 * (0, _math.sin)(a00),
oc; // Restrict the corner radius according to the sector angle.
if (da < _math.pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
var ax = x01 - oc[0],
ay = y01 - oc[1],
bx = x11 - oc[0],
by = y11 - oc[1],
kc = 1 / (0, _math.sin)((0, _math.acos)((ax * bx + ay * by) / ((0, _math.sqrt)(ax * ax + ay * ay) * (0, _math.sqrt)(bx * bx + by * by))) / 2),
lc = (0, _math.sqrt)(oc[0] * oc[0] + oc[1] * oc[1]);
rc0 = (0, _math.min)(rc, (r0 - lc) / (kc - 1));
rc1 = (0, _math.min)(rc, (r1 - lc) / (kc + 1));
}
} // Is the sector collapsed to a line?
if (!(da1 > _math.epsilon)) context.moveTo(x01, y01); // Does the sectors outer ring have rounded corners?
else if (rc1 > _math.epsilon) {
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01); // Have the corners merged?
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, (0, _math.atan2)(t0.y01, t0.x01), (0, _math.atan2)(t1.y01, t1.x01), !cw); // Otherwise, draw the two corners and the ring.
else {
context.arc(t0.cx, t0.cy, rc1, (0, _math.atan2)(t0.y01, t0.x01), (0, _math.atan2)(t0.y11, t0.x11), !cw);
context.arc(0, 0, r1, (0, _math.atan2)(t0.cy + t0.y11, t0.cx + t0.x11), (0, _math.atan2)(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
context.arc(t1.cx, t1.cy, rc1, (0, _math.atan2)(t1.y11, t1.x11), (0, _math.atan2)(t1.y01, t1.x01), !cw);
}
} // Or is the outer ring just a circular arc?
else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); // Is there no inner ring, and its a circular sector?
// Or perhaps its an annular sector collapsed due to padding?
if (!(r0 > _math.epsilon) || !(da0 > _math.epsilon)) context.lineTo(x10, y10); // Does the sectors inner ring (or point) have rounded corners?
else if (rc0 > _math.epsilon) {
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01); // Have the corners merged?
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, (0, _math.atan2)(t0.y01, t0.x01), (0, _math.atan2)(t1.y01, t1.x01), !cw); // Otherwise, draw the two corners and the ring.
else {
context.arc(t0.cx, t0.cy, rc0, (0, _math.atan2)(t0.y01, t0.x01), (0, _math.atan2)(t0.y11, t0.x11), !cw);
context.arc(0, 0, r0, (0, _math.atan2)(t0.cy + t0.y11, t0.cx + t0.x11), (0, _math.atan2)(t1.cy + t1.y11, t1.cx + t1.x11), cw);
context.arc(t1.cx, t1.cy, rc0, (0, _math.atan2)(t1.y11, t1.x11), (0, _math.atan2)(t1.y01, t1.x01), !cw);
}
} // Or is the inner ring just a circular arc?
else context.arc(0, 0, r0, a10, a00, cw);
}
context.closePath();
if (buffer) return context = null, buffer + "" || null;
}
arc.centroid = function () {
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - _math.pi / 2;
return [(0, _math.cos)(a) * r, (0, _math.sin)(a) * r];
};
arc.innerRadius = function (_) {
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : innerRadius;
};
arc.outerRadius = function (_) {
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : outerRadius;
};
arc.cornerRadius = function (_) {
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : cornerRadius;
};
arc.padRadius = function (_) {
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : padRadius;
};
arc.startAngle = function (_) {
return arguments.length ? (startAngle = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : startAngle;
};
arc.endAngle = function (_) {
return arguments.length ? (endAngle = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : endAngle;
};
arc.padAngle = function (_) {
return arguments.length ? (padAngle = typeof _ === "function" ? _ : (0, _constant.default)(+_), arc) : padAngle;
};
arc.context = function (_) {
return arguments.length ? (context = _ == null ? null : _, arc) : context;
};
return arc;
}
+125
View File
@@ -0,0 +1,125 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../../lib-vendor/d3-path/src/index.js");
var _array = _interopRequireDefault(require("./array.js"));
var _constant = _interopRequireDefault(require("./constant.js"));
var _linear = _interopRequireDefault(require("./curve/linear.js"));
var _line = _interopRequireDefault(require("./line.js"));
var _point = require("./point.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(x0, y0, y1) {
var x1 = null,
defined = (0, _constant.default)(true),
context = null,
curve = _linear.default,
output = null;
x0 = typeof x0 === "function" ? x0 : x0 === undefined ? _point.x : (0, _constant.default)(+x0);
y0 = typeof y0 === "function" ? y0 : y0 === undefined ? (0, _constant.default)(0) : (0, _constant.default)(+y0);
y1 = typeof y1 === "function" ? y1 : y1 === undefined ? _point.y : (0, _constant.default)(+y1);
function area(data) {
var i,
j,
k,
n = (data = (0, _array.default)(data)).length,
d,
defined0 = false,
buffer,
x0z = new Array(n),
y0z = new Array(n);
if (context == null) output = curve(buffer = (0, _index.path)());
for (i = 0; i <= n; ++i) {
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
if (defined0 = !defined0) {
j = i;
output.areaStart();
output.lineStart();
} else {
output.lineEnd();
output.lineStart();
for (k = i - 1; k >= j; --k) {
output.point(x0z[k], y0z[k]);
}
output.lineEnd();
output.areaEnd();
}
}
if (defined0) {
x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
}
}
if (buffer) return output = null, buffer + "" || null;
}
function arealine() {
return (0, _line.default)().defined(defined).curve(curve).context(context);
}
area.x = function (_) {
return arguments.length ? (x0 = typeof _ === "function" ? _ : (0, _constant.default)(+_), x1 = null, area) : x0;
};
area.x0 = function (_) {
return arguments.length ? (x0 = typeof _ === "function" ? _ : (0, _constant.default)(+_), area) : x0;
};
area.x1 = function (_) {
return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : (0, _constant.default)(+_), area) : x1;
};
area.y = function (_) {
return arguments.length ? (y0 = typeof _ === "function" ? _ : (0, _constant.default)(+_), y1 = null, area) : y0;
};
area.y0 = function (_) {
return arguments.length ? (y0 = typeof _ === "function" ? _ : (0, _constant.default)(+_), area) : y0;
};
area.y1 = function (_) {
return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : (0, _constant.default)(+_), area) : y1;
};
area.lineX0 = area.lineY0 = function () {
return arealine().x(x0).y(y0);
};
area.lineY1 = function () {
return arealine().x(x0).y(y1);
};
area.lineX1 = function () {
return arealine().x(x1).y(y0);
};
area.defined = function (_) {
return arguments.length ? (defined = typeof _ === "function" ? _ : (0, _constant.default)(!!_), area) : defined;
};
area.curve = function (_) {
return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
};
area.context = function (_) {
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
};
return area;
}
@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _radial = _interopRequireWildcard(require("./curve/radial.js"));
var _area = _interopRequireDefault(require("./area.js"));
var _lineRadial = require("./lineRadial.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _default() {
var a = (0, _area.default)().curve(_radial.curveRadialLinear),
c = a.curve,
x0 = a.lineX0,
x1 = a.lineX1,
y0 = a.lineY0,
y1 = a.lineY1;
a.angle = a.x, delete a.x;
a.startAngle = a.x0, delete a.x0;
a.endAngle = a.x1, delete a.x1;
a.radius = a.y, delete a.y;
a.innerRadius = a.y0, delete a.y0;
a.outerRadius = a.y1, delete a.y1;
a.lineStartAngle = function () {
return (0, _lineRadial.lineRadial)(x0());
}, delete a.lineX0;
a.lineEndAngle = function () {
return (0, _lineRadial.lineRadial)(x1());
}, delete a.lineX1;
a.lineInnerRadius = function () {
return (0, _lineRadial.lineRadial)(y0());
}, delete a.lineY0;
a.lineOuterRadius = function () {
return (0, _lineRadial.lineRadial)(y1());
}, delete a.lineY1;
a.curve = function (_) {
return arguments.length ? c((0, _radial.default)(_)) : c()._curve;
};
return a;
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.slice = void 0;
var slice = Array.prototype.slice;
exports.slice = slice;
function _default(x) {
return typeof x === "object" && "length" in x ? x // Array, TypedArray, NodeList, array-like
: Array.from(x); // Map, Set, iterable, string, or anything else
}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(x) {
return function constant() {
return x;
};
}
@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Basis = Basis;
exports.default = _default;
exports.point = point;
function point(that, x, y) {
that._context.bezierCurveTo((2 * that._x0 + that._x1) / 3, (2 * that._y0 + that._y1) / 3, (that._x0 + 2 * that._x1) / 3, (that._y0 + 2 * that._y1) / 3, (that._x0 + 4 * that._x1 + x) / 6, (that._y0 + 4 * that._y1 + y) / 6);
}
function Basis(context) {
this._context = context;
}
Basis.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 3:
point(this, this._x1, this._y1);
// falls through
case 2:
this._context.lineTo(this._x1, this._y1);
break;
}
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
case 1:
this._point = 2;
break;
case 2:
this._point = 3;
this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
// falls through
default:
point(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = x;
this._y0 = this._y1, this._y1 = y;
}
};
function _default(context) {
return new Basis(context);
}
@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _noop = _interopRequireDefault(require("../noop.js"));
var _basis = require("./basis.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function BasisClosed(context) {
this._context = context;
}
BasisClosed.prototype = {
areaStart: _noop.default,
areaEnd: _noop.default,
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 1:
{
this._context.moveTo(this._x2, this._y2);
this._context.closePath();
break;
}
case 2:
{
this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
this._context.closePath();
break;
}
case 3:
{
this.point(this._x2, this._y2);
this.point(this._x3, this._y3);
this.point(this._x4, this._y4);
break;
}
}
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
this._x2 = x, this._y2 = y;
break;
case 1:
this._point = 2;
this._x3 = x, this._y3 = y;
break;
case 2:
this._point = 3;
this._x4 = x, this._y4 = y;
this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6);
break;
default:
(0, _basis.point)(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = x;
this._y0 = this._y1, this._y1 = y;
}
};
function _default(context) {
return new BasisClosed(context);
}
@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _basis = require("./basis.js");
function BasisOpen(context) {
this._context = context;
}
BasisOpen.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
this._point = 0;
},
lineEnd: function () {
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
break;
case 1:
this._point = 2;
break;
case 2:
this._point = 3;
var x0 = (this._x0 + 4 * this._x1 + x) / 6,
y0 = (this._y0 + 4 * this._y1 + y) / 6;
this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0);
break;
case 3:
this._point = 4;
// falls through
default:
(0, _basis.point)(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = x;
this._y0 = this._y1, this._y1 = y;
}
};
function _default(context) {
return new BasisOpen(context);
}
@@ -0,0 +1,104 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bumpRadial = bumpRadial;
exports.bumpX = bumpX;
exports.bumpY = bumpY;
var _pointRadial = _interopRequireDefault(require("../pointRadial.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Bump {
constructor(context, x) {
this._context = context;
this._x = x;
}
areaStart() {
this._line = 0;
}
areaEnd() {
this._line = NaN;
}
lineStart() {
this._point = 0;
}
lineEnd() {
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
this._line = 1 - this._line;
}
point(x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
{
this._point = 1;
if (this._line) this._context.lineTo(x, y);else this._context.moveTo(x, y);
break;
}
case 1:
this._point = 2;
// falls through
default:
{
if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y);else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y);
break;
}
}
this._x0 = x, this._y0 = y;
}
}
class BumpRadial {
constructor(context) {
this._context = context;
}
lineStart() {
this._point = 0;
}
lineEnd() {}
point(x, y) {
x = +x, y = +y;
if (this._point++ === 0) {
this._x0 = x, this._y0 = y;
} else {
const p0 = (0, _pointRadial.default)(this._x0, this._y0);
const p1 = (0, _pointRadial.default)(this._x0, this._y0 = (this._y0 + y) / 2);
const p2 = (0, _pointRadial.default)(x, this._y0);
const p3 = (0, _pointRadial.default)(x, y);
this._context.moveTo(...p0);
this._context.bezierCurveTo(...p1, ...p2, ...p3);
}
}
}
function bumpX(context) {
return new Bump(context, true);
}
function bumpY(context) {
return new Bump(context, false);
}
function bumpRadial(context) {
return new BumpRadial(context);
}
@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _basis = require("./basis.js");
function Bundle(context, beta) {
this._basis = new _basis.Basis(context);
this._beta = beta;
}
Bundle.prototype = {
lineStart: function () {
this._x = [];
this._y = [];
this._basis.lineStart();
},
lineEnd: function () {
var x = this._x,
y = this._y,
j = x.length - 1;
if (j > 0) {
var x0 = x[0],
y0 = y[0],
dx = x[j] - x0,
dy = y[j] - y0,
i = -1,
t;
while (++i <= j) {
t = i / j;
this._basis.point(this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), this._beta * y[i] + (1 - this._beta) * (y0 + t * dy));
}
}
this._x = this._y = null;
this._basis.lineEnd();
},
point: function (x, y) {
this._x.push(+x);
this._y.push(+y);
}
};
var _default = function custom(beta) {
function bundle(context) {
return beta === 1 ? new _basis.Basis(context) : new Bundle(context, beta);
}
bundle.beta = function (beta) {
return custom(+beta);
};
return bundle;
}(0.85);
exports.default = _default;
@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Cardinal = Cardinal;
exports.default = void 0;
exports.point = point;
function point(that, x, y) {
that._context.bezierCurveTo(that._x1 + that._k * (that._x2 - that._x0), that._y1 + that._k * (that._y2 - that._y0), that._x2 + that._k * (that._x1 - x), that._y2 + that._k * (that._y1 - y), that._x2, that._y2);
}
function Cardinal(context, tension) {
this._context = context;
this._k = (1 - tension) / 6;
}
Cardinal.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 2:
this._context.lineTo(this._x2, this._y2);
break;
case 3:
point(this, this._x1, this._y1);
break;
}
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
case 1:
this._point = 2;
this._x1 = x, this._y1 = y;
break;
case 2:
this._point = 3;
// falls through
default:
point(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(tension) {
function cardinal(context) {
return new Cardinal(context, tension);
}
cardinal.tension = function (tension) {
return custom(+tension);
};
return cardinal;
}(0);
exports.default = _default;
@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CardinalClosed = CardinalClosed;
exports.default = void 0;
var _noop = _interopRequireDefault(require("../noop.js"));
var _cardinal = require("./cardinal.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function CardinalClosed(context, tension) {
this._context = context;
this._k = (1 - tension) / 6;
}
CardinalClosed.prototype = {
areaStart: _noop.default,
areaEnd: _noop.default,
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 1:
{
this._context.moveTo(this._x3, this._y3);
this._context.closePath();
break;
}
case 2:
{
this._context.lineTo(this._x3, this._y3);
this._context.closePath();
break;
}
case 3:
{
this.point(this._x3, this._y3);
this.point(this._x4, this._y4);
this.point(this._x5, this._y5);
break;
}
}
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
this._x3 = x, this._y3 = y;
break;
case 1:
this._point = 2;
this._context.moveTo(this._x4 = x, this._y4 = y);
break;
case 2:
this._point = 3;
this._x5 = x, this._y5 = y;
break;
default:
(0, _cardinal.point)(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(tension) {
function cardinal(context) {
return new CardinalClosed(context, tension);
}
cardinal.tension = function (tension) {
return custom(+tension);
};
return cardinal;
}(0);
exports.default = _default;
@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CardinalOpen = CardinalOpen;
exports.default = void 0;
var _cardinal = require("./cardinal.js");
function CardinalOpen(context, tension) {
this._context = context;
this._k = (1 - tension) / 6;
}
CardinalOpen.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
this._point = 0;
},
lineEnd: function () {
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
break;
case 1:
this._point = 2;
break;
case 2:
this._point = 3;
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
break;
case 3:
this._point = 4;
// falls through
default:
(0, _cardinal.point)(this, x, y);
break;
}
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(tension) {
function cardinal(context) {
return new CardinalOpen(context, tension);
}
cardinal.tension = function (tension) {
return custom(+tension);
};
return cardinal;
}(0);
exports.default = _default;
@@ -0,0 +1,114 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.point = point;
var _math = require("../math.js");
var _cardinal = require("./cardinal.js");
function point(that, x, y) {
var x1 = that._x1,
y1 = that._y1,
x2 = that._x2,
y2 = that._y2;
if (that._l01_a > _math.epsilon) {
var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a,
n = 3 * that._l01_a * (that._l01_a + that._l12_a);
x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
}
if (that._l23_a > _math.epsilon) {
var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a,
m = 3 * that._l23_a * (that._l23_a + that._l12_a);
x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
}
that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
}
function CatmullRom(context, alpha) {
this._context = context;
this._alpha = alpha;
}
CatmullRom.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 2:
this._context.lineTo(this._x2, this._y2);
break;
case 3:
this.point(this._x2, this._y2);
break;
}
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
if (this._point) {
var x23 = this._x2 - x,
y23 = this._y2 - y;
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
}
switch (this._point) {
case 0:
this._point = 1;
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
case 1:
this._point = 2;
break;
case 2:
this._point = 3;
// falls through
default:
point(this, x, y);
break;
}
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(alpha) {
function catmullRom(context) {
return alpha ? new CatmullRom(context, alpha) : new _cardinal.Cardinal(context, 0);
}
catmullRom.alpha = function (alpha) {
return custom(+alpha);
};
return catmullRom;
}(0.5);
exports.default = _default;
@@ -0,0 +1,108 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _cardinalClosed = require("./cardinalClosed.js");
var _noop = _interopRequireDefault(require("../noop.js"));
var _catmullRom = require("./catmullRom.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function CatmullRomClosed(context, alpha) {
this._context = context;
this._alpha = alpha;
}
CatmullRomClosed.prototype = {
areaStart: _noop.default,
areaEnd: _noop.default,
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
},
lineEnd: function () {
switch (this._point) {
case 1:
{
this._context.moveTo(this._x3, this._y3);
this._context.closePath();
break;
}
case 2:
{
this._context.lineTo(this._x3, this._y3);
this._context.closePath();
break;
}
case 3:
{
this.point(this._x3, this._y3);
this.point(this._x4, this._y4);
this.point(this._x5, this._y5);
break;
}
}
},
point: function (x, y) {
x = +x, y = +y;
if (this._point) {
var x23 = this._x2 - x,
y23 = this._y2 - y;
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
}
switch (this._point) {
case 0:
this._point = 1;
this._x3 = x, this._y3 = y;
break;
case 1:
this._point = 2;
this._context.moveTo(this._x4 = x, this._y4 = y);
break;
case 2:
this._point = 3;
this._x5 = x, this._y5 = y;
break;
default:
(0, _catmullRom.point)(this, x, y);
break;
}
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(alpha) {
function catmullRom(context) {
return alpha ? new CatmullRomClosed(context, alpha) : new _cardinalClosed.CardinalClosed(context, 0);
}
catmullRom.alpha = function (alpha) {
return custom(+alpha);
};
return catmullRom;
}(0.5);
exports.default = _default;
@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _cardinalOpen = require("./cardinalOpen.js");
var _catmullRom = require("./catmullRom.js");
function CatmullRomOpen(context, alpha) {
this._context = context;
this._alpha = alpha;
}
CatmullRomOpen.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
},
lineEnd: function () {
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
if (this._point) {
var x23 = this._x2 - x,
y23 = this._y2 - y;
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
}
switch (this._point) {
case 0:
this._point = 1;
break;
case 1:
this._point = 2;
break;
case 2:
this._point = 3;
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
break;
case 3:
this._point = 4;
// falls through
default:
(0, _catmullRom.point)(this, x, y);
break;
}
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
}
};
var _default = function custom(alpha) {
function catmullRom(context) {
return alpha ? new CatmullRomOpen(context, alpha) : new _cardinalOpen.CardinalOpen(context, 0);
}
catmullRom.alpha = function (alpha) {
return custom(+alpha);
};
return catmullRom;
}(0.5);
exports.default = _default;
@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function Linear(context) {
this._context = context;
}
Linear.prototype = {
areaStart: function () {
this._line = 0;
},
areaEnd: function () {
this._line = NaN;
},
lineStart: function () {
this._point = 0;
},
lineEnd: function () {
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
this._line = 1 - this._line;
},
point: function (x, y) {
x = +x, y = +y;
switch (this._point) {
case 0:
this._point = 1;
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
case 1:
this._point = 2;
// falls through
default:
this._context.lineTo(x, y);
break;
}
}
};
function _default(context) {
return new Linear(context);
}

Some files were not shown because too many files have changed in this diff Show More