source: node_modules/victory-vendor/lib-vendor/d3-scale/src/sequentialQuantile.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = sequentialQuantile;
7var _index = require("../../../lib-vendor/d3-array/src/index.js");
8var _continuous = require("./continuous.js");
9var _init = require("./init.js");
10function sequentialQuantile() {
11 var domain = [],
12 interpolator = _continuous.identity;
13 function scale(x) {
14 if (x != null && !isNaN(x = +x)) return interpolator(((0, _index.bisect)(domain, x, 1) - 1) / (domain.length - 1));
15 }
16 scale.domain = function (_) {
17 if (!arguments.length) return domain.slice();
18 domain = [];
19 for (let d of _) if (d != null && !isNaN(d = +d)) domain.push(d);
20 domain.sort(_index.ascending);
21 return scale;
22 };
23 scale.interpolator = function (_) {
24 return arguments.length ? (interpolator = _, scale) : interpolator;
25 };
26 scale.range = function () {
27 return domain.map((d, i) => interpolator(i / (domain.length - 1)));
28 };
29 scale.quantiles = function (n) {
30 return Array.from({
31 length: n + 1
32 }, (_, i) => (0, _index.quantile)(domain, i / n));
33 };
34 scale.copy = function () {
35 return sequentialQuantile(interpolator).domain(domain);
36 };
37 return _init.initInterpolator.apply(scale, arguments);
38}
Note: See TracBrowser for help on using the repository browser.