Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visactor/vscale

Package Overview
Dependencies
Maintainers
15
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visactor/vscale - npm Package Compare versions

Comparing version 0.15.2 to 0.15.3

4

cjs/continuous-scale.d.ts
import { BaseScale } from './base-scale';
import type { BimapType, InterpolateType, PolymapType, TransformType, IContinuousScale, ContinuousScaleType, TickData } from './interface';
import type { BimapType, InterpolateType, PolymapType, TransformType, IContinuousScale, ContinuousScaleType, TickData, NiceType } from './interface';
export declare class ContinuousScale extends BaseScale implements IContinuousScale {

@@ -8,2 +8,3 @@ readonly type: ContinuousScaleType;

protected _niceDomain: number[];
protected _niceType?: NiceType;
protected _domain: number[];

@@ -17,2 +18,3 @@ protected _range: any[];

protected _piecewise: BimapType<any> | PolymapType<any>;
protected _domainValidator?: (val: number) => boolean;
_clamp?: (x: number) => number;

@@ -19,0 +21,0 @@ constructor(transformer?: TransformType, untransformer?: TransformType);

@@ -24,7 +24,8 @@ "use strict";

var _a;
return x = Number(x), Number.isNaN(x) ? this._unknown : (this._output || (this._output = this._piecewise((null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), this._calculateRange(this._range), this._interpolate)),
return x = Number(x), Number.isNaN(x) || this._domainValidator && !this._domainValidator(x) ? this._unknown : (this._output || (this._output = this._piecewise((null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), this._calculateRange(this._range), this._interpolate)),
this._output(this.transformer(this._clamp(x))));
}
invert(y) {
return this._input || (this._input = this._piecewise(this._calculateRange(this._range), this._domain.map(this.transformer), vutils_1.interpolateNumber)),
var _a;
return this._input || (this._input = this._piecewise(this._calculateRange(this._range), (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), vutils_1.interpolateNumber)),
this._clamp(this.untransformer(this._input(y)));

@@ -35,2 +36,3 @@ }

if (!_) return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).slice();
this._domainValidator = null, this._niceType = null, this._niceDomain = null;
const nextDomain = Array.from(_, vutils_1.toNumber);

@@ -37,0 +39,0 @@ return this._domain = nextDomain, this.rescale(slience);

@@ -111,1 +111,8 @@ import type { ScaleEnum } from './type';

}) => number[];
export interface NiceOptions {
forceMin?: number;
forceMax?: number;
min?: number;
max?: number;
}
export type NiceType = 'all' | 'min' | 'max';
import { ContinuousScale } from './continuous-scale';
import type { ContinuousScaleType } from './interface';
import type { ContinuousScaleType, NiceOptions } from './interface';
export declare class LinearScale extends ContinuousScale {
readonly type: ContinuousScaleType;
protected _needNiceMin?: boolean;
protected _needNiceMax?: boolean;
protected _needNice?: boolean;
clone(): LinearScale;
tickFormat(): () => void;
domain(): any[];
domain(_: any[], slience?: boolean): this;
d3Ticks(count?: number, options?: {

@@ -20,5 +15,5 @@ noDecimals?: boolean;

stepTicks(step: number): any[];
nice(count?: number): this;
nice(count?: number, option?: NiceOptions): this;
niceMin(count?: number): this;
niceMax(count?: number): this;
}

@@ -7,3 +7,3 @@ "use strict";

const type_1 = require("./type"), tick_sample_1 = require("./utils/tick-sample"), continuous_scale_1 = require("./continuous-scale"), vutils_1 = require("@visactor/vutils");
const type_1 = require("./type"), tick_sample_1 = require("./utils/tick-sample"), continuous_scale_1 = require("./continuous-scale");

@@ -20,9 +20,2 @@ class LinearScale extends continuous_scale_1.ContinuousScale {

}
domain(_, slience) {
var _a;
if (!_) return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).slice();
this._needNice = !1, this._needNiceMax = !1, this._needNiceMin = !1, this._niceDomain = null;
const nextDomain = Array.from(_, vutils_1.toNumber);
return this._domain = nextDomain, this.rescale(slience);
}
d3Ticks(count = 10, options) {

@@ -33,13 +26,17 @@ const d = this.calculateVisibleDomain(this._range);

ticks(count = 10, options) {
if (this._rangeFactor && (this._rangeFactor[0] > 0 || this._rangeFactor[1] < 1) && 2 === this._range.length || !this._needNice && !this._needNiceMin && !this._needNiceMax) return this.d3Ticks(count, options);
const domain = this._domain, start = domain[0], stop = domain[domain.length - 1];
let ticksResult = (0, tick_sample_1.ticks)(start, stop, count, options);
if (ticksResult.length && (ticksResult[0] !== start && (this._needNice || this._needNiceMin) || ticksResult[ticksResult.length - 1] !== stop && (this._needNice || this._needNiceMax))) {
const newNiceDomain = domain.slice();
if ((this._needNice || this._needNiceMin) && (newNiceDomain[0] = ticksResult[0]),
(this._needNice || this._needNiceMax) && (newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1]),
this._niceDomain = newNiceDomain, this.rescale(), !this._needNice) {
const min = Math.min(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]), max = Math.max(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]);
ticksResult = ticksResult.filter((entry => entry >= min && entry <= max));
}
var _a;
if (this._rangeFactor && (this._rangeFactor[0] > 0 || this._rangeFactor[1] < 1) && 2 === this._range.length || !this._niceType) return this.d3Ticks(count, options);
const curNiceDomain = null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain, originalDomain = this._domain, start = curNiceDomain[0], stop = curNiceDomain[curNiceDomain.length - 1];
let ticksResult = (0, tick_sample_1.ticks)(originalDomain[0], originalDomain[originalDomain.length - 1], count, options);
if (!ticksResult.length) return ticksResult;
if (ticksResult[0] !== start && "max" === this._niceType || ticksResult[ticksResult.length - 1] !== stop && "min" === this._niceType) {
const newNiceDomain = curNiceDomain.slice();
"min" === this._niceType ? newNiceDomain[0] = ticksResult[0] : newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1],
this._niceDomain = newNiceDomain, this.rescale();
const min = Math.min(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]), max = Math.max(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]);
ticksResult = ticksResult.filter((entry => entry >= min && entry <= max));
} else if ("all" !== this._niceType || ticksResult[0] === start && ticksResult[ticksResult.length - 1] === stop) this._domainValidator && (ticksResult = ticksResult.filter(this._domainValidator)); else {
const newNiceDomain = curNiceDomain.slice();
newNiceDomain[0] = ticksResult[0], newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1],
this._niceDomain = newNiceDomain, this.rescale();
}

@@ -56,9 +53,20 @@ return ticksResult;

}
nice(count = 10) {
this._needNice = !0;
const niceDomain = (0, tick_sample_1.niceLinear)(this.domain(), count);
return niceDomain && (this._niceDomain = niceDomain, this.rescale()), this;
nice(count = 10, option) {
var _a, _b;
const originalDomain = this._domain;
let niceMinMax = [];
if (option) {
const res = (0, tick_sample_1.parseNiceOptions)(originalDomain, option);
if (niceMinMax = res.niceMinMax, this._domainValidator = res.domainValidator, this._niceType = res.niceType,
res.niceDomain) return this._niceDomain = res.niceDomain, this.rescale(), this;
} else this._niceType = "all";
if (this._niceType) {
const niceDomain = (0, tick_sample_1.niceLinear)(originalDomain.slice(), count);
"min" === this._niceType ? niceDomain[niceDomain.length - 1] = null !== (_a = niceMinMax[1]) && void 0 !== _a ? _a : niceDomain[niceDomain.length - 1] : "max" === this._niceType && (niceDomain[0] = null !== (_b = niceMinMax[0]) && void 0 !== _b ? _b : niceDomain[0]),
this._niceDomain = niceDomain, this.rescale();
}
return this;
}
niceMin(count = 10) {
this._needNiceMin = !0;
this._niceType = "min";
const maxD = this._domain[this._domain.length - 1], niceDomain = (0, tick_sample_1.niceLinear)(this.domain(), count);

@@ -69,4 +77,4 @@ return niceDomain && (niceDomain[niceDomain.length - 1] = maxD, this._niceDomain = niceDomain,

niceMax(count = 10) {
this._needNiceMax = !0;
const minD = this._domain[0], niceDomain = (0, tick_sample_1.niceLinear)(this.domain(), count);
this._niceType = "max";
const minD = this._domain[0], niceDomain = (0, tick_sample_1.niceLinear)(this._domain.slice(), count);
return niceDomain && (niceDomain[0] = minD, this._niceDomain = niceDomain, this.rescale()),

@@ -73,0 +81,0 @@ this;

import { ContinuousScale } from './continuous-scale';
import { identity } from './utils/utils';
import type { ContinuousScaleType } from './interface';
import type { ContinuousScaleType, NiceOptions } from './interface';
export declare class LogScale extends ContinuousScale {

@@ -19,5 +19,5 @@ readonly type: ContinuousScaleType;

stepTicks(step: number): any[];
nice(): this;
nice(count?: number, option?: NiceOptions): this;
niceMin(): this;
niceMax(): this;
}

@@ -7,3 +7,3 @@ "use strict";

const tick_sample_1 = require("./utils/tick-sample"), continuous_scale_1 = require("./continuous-scale"), type_1 = require("./type"), utils_1 = require("./utils/utils"), vutils_1 = require("@visactor/vutils");
const tick_sample_1 = require("./utils/tick-sample"), continuous_scale_1 = require("./continuous-scale"), type_1 = require("./type"), utils_1 = require("./utils/utils");

@@ -24,7 +24,8 @@ function reflect(f) {

rescale(slience) {
var _a;
if (slience) return this;
super.rescale();
const logs = (0, utils_1.logp)(this._base), pows = (0, utils_1.powp)(this._base);
return this._domain[0] < 0 ? (this._logs = reflect(logs), this._pows = reflect(pows),
this.transformer = utils_1.logNegative, this.untransformer = utils_1.expNegative) : (this._logs = logs,
return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain)[0] < 0 ? (this._logs = reflect(logs),
this._pows = reflect(pows), this.transformer = utils_1.logNegative, this.untransformer = utils_1.expNegative) : (this._logs = logs,
this._pows = pows, this.transformer = logs, this.untransformer = pows), this;

@@ -71,7 +72,20 @@ }

}
nice() {
return this.domain((0, utils_1.nice)(this.domain(), {
floor: x => this._pows(Math.floor(this._logs(x))),
ceil: x => this._pows(Math.ceil(this._logs(x)))
}));
nice(count = 10, option) {
var _a, _b;
const originalDomain = this._domain;
let niceMinMax = [], niceType = null;
if (option) {
const res = (0, tick_sample_1.parseNiceOptions)(originalDomain, option);
if (niceMinMax = res.niceMinMax, this._domainValidator = res.domainValidator, niceType = res.niceType,
res.niceDomain) return this._niceDomain = res.niceDomain, this.rescale(), this;
} else niceType = "all";
if (niceType) {
const niceDomain = (0, utils_1.nice)(originalDomain.slice(), {
floor: x => this._pows(Math.floor(this._logs(x))),
ceil: x => this._pows(Math.ceil(this._logs(x)))
});
return "min" === niceType ? niceDomain[niceDomain.length - 1] = null !== (_a = niceMinMax[1]) && void 0 !== _a ? _a : niceDomain[niceDomain.length - 1] : "max" === niceType && (niceDomain[0] = null !== (_b = niceMinMax[0]) && void 0 !== _b ? _b : niceDomain[0]),
this._niceDomain = niceDomain, this.rescale(), this;
}
return this;
}

@@ -81,3 +95,3 @@ niceMin() {

this.nice();
const niceDomain = (0, vutils_1.cloneDeep)(this._domain);
const niceDomain = this._domain.slice();
return this._domain && (niceDomain[niceDomain.length - 1] = maxD, this.domain(niceDomain)),

@@ -89,3 +103,3 @@ this;

this.nice();
const niceDomain = (0, vutils_1.cloneDeep)(this._domain);
const niceDomain = this._domain.slice();
return this._domain && (niceDomain[0] = minD, this.domain(niceDomain)), this;

@@ -92,0 +106,0 @@ }

@@ -1,2 +0,2 @@

import type { ContinuousTicksFunc } from '../interface';
import type { ContinuousTicksFunc, NiceOptions, NiceType } from '../interface';
export declare const calculateTicksOfSingleValue: (value: number, tickCount: number, noDecimals?: boolean) => any[];

@@ -15,1 +15,7 @@ export declare const d3Ticks: ContinuousTicksFunc;

export declare function niceLinear(d: number[], count?: number): number[];
export declare function parseNiceOptions(originalDomain: number[], option: NiceOptions): {
niceType: NiceType;
niceDomain: number[];
niceMinMax: number[];
domainValidator: (x: number) => boolean;
};

@@ -5,3 +5,3 @@ "use strict";

value: !0
}), exports.niceLinear = exports.stepTicks = exports.forceTickIncrement = exports.forceTicks = exports.tickIncrement = exports.ticks = exports.appendTicksToCount = exports.d3Ticks = exports.calculateTicksOfSingleValue = void 0;
}), exports.parseNiceOptions = exports.niceLinear = exports.stepTicks = exports.forceTickIncrement = exports.forceTicks = exports.tickIncrement = exports.ticks = exports.appendTicksToCount = exports.d3Ticks = exports.calculateTicksOfSingleValue = void 0;

@@ -79,5 +79,5 @@ const vutils_1 = require("@visactor/vutils"), e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2), niceNumbers = [ 1, 2, 5, 10 ], calculateTicksOfSingleValue = (value, tickCount, noDecimals) => {

const {power: power, gap: gap} = stepRes, delatStep = 10 === gap ? 2 * 10 ** power : 1 * 10 ** power;
for (;cur <= 5 && (ticks = calculateTicksByStep(start, stop, step), ticks.length > count) && count > 2; ) step += delatStep,
for (;cur <= 5 && (ticks = calculateTicksByStep(start, stop, step), ticks.length > count + 1) && count > 2; ) step += delatStep,
cur += 1;
ticks.length < count && (ticks = (0, exports.appendTicksToCount)(ticks, count, step));
count > 2 && ticks.length < count - 1 && (ticks = (0, exports.appendTicksToCount)(ticks, count, step));
} else (null == options ? void 0 : options.noDecimals) && step < 0 && (step = 1),

@@ -144,4 +144,23 @@ ticks = calculateTicksByStep(start, stop, step);

function parseNiceOptions(originalDomain, option) {
const hasForceMin = (0, vutils_1.isNumber)(option.forceMin), hasForceMax = (0, vutils_1.isNumber)(option.forceMax);
let niceType = null;
const niceMinMax = [];
let niceDomain = null;
const domainValidator = hasForceMin && hasForceMax ? x => x >= option.forceMin && x <= option.forceMax : hasForceMin ? x => x >= option.forceMin : hasForceMax ? x => x <= option.forceMax : null;
return hasForceMin ? niceMinMax[0] = option.forceMin : (0, vutils_1.isNumber)(option.min) && option.min <= Math.min(originalDomain[0], originalDomain[originalDomain.length - 1]) && (niceMinMax[0] = option.min),
hasForceMax ? niceMinMax[1] = option.forceMax : (0, vutils_1.isNumber)(option.max) && option.max >= Math.max(originalDomain[0], originalDomain[originalDomain.length - 1]) && (niceMinMax[1] = option.max),
(0, vutils_1.isNumber)(niceMinMax[0]) && (0, vutils_1.isNumber)(niceMinMax[1]) ? (niceDomain = originalDomain.slice(),
niceDomain[0] = niceMinMax[0], niceDomain[niceDomain.length - 1] = niceMinMax[1]) : niceType = (0,
vutils_1.isNumber)(niceMinMax[0]) || (0, vutils_1.isNumber)(niceMinMax[1]) ? (0,
vutils_1.isNumber)(niceMinMax[0]) ? "max" : "min" : "all", {
niceType: niceType,
niceDomain: niceDomain,
niceMinMax: niceMinMax,
domainValidator: domainValidator
};
}
exports.tickIncrement = tickIncrement, exports.forceTicks = forceTicks, exports.forceTickIncrement = forceTickIncrement,
exports.stepTicks = stepTicks, exports.niceLinear = niceLinear;
exports.stepTicks = stepTicks, exports.niceLinear = niceLinear, exports.parseNiceOptions = parseNiceOptions;
//# sourceMappingURL=tick-sample.js.map

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VScale={})}(this,(function(t){"use strict";!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||t,o),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i<s;i++)o[i]=r[i].fn;return o},a.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},a.prototype.emit=function(t,e,r,i,s,o){var a=n?n+t:t;if(!this._events[a])return!1;var h,l,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,i),!0;case 5:return c.fn.call(c.context,e,r,i,s),!0;case 6:return c.fn.call(c.context,e,r,i,s,o),!0}for(l=1,h=new Array(u-1);l<u;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var g,d=c.length;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,r);break;case 4:c[l].fn.call(c[l].context,e,r,i);break;default:if(!h)for(g=1,h=new Array(u-1);g<u;g++)h[g-1]=arguments[g];c[l].fn.apply(c[l].context,h)}}return!0},a.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,r,i){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||i&&!a.once||r&&a.context!==r||o(this,s);else{for(var h=0,l=[],c=a.length;h<c;h++)(a[h].fn!==e||i&&!a[h].once||r&&a[h].context!==r)&&l.push(a[h]);l.length?this._events[s]=1===l.length?l[0]:l:o(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&o(this,e)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}({exports:{}});const e=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,n=t=>null==t,r=t=>null!=t,i=function(t){const n=typeof t;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"string"===n:"string"===n||e(t,"String")},s=t=>Array.isArray?Array.isArray(t):e(t,"Array"),o=function(t){const n=typeof t;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"number"===n:"number"===n||e(t,"Number")},a=t=>o(t)&&Number.isFinite(t);function h(t){let n;if(!r(t)||"object"!=typeof t)return t;const a=s(t),l=t.length;n=a?new Array(l):"object"==typeof t?{}:function(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"boolean"==typeof t:!0===t||!1===t||e(t,"Boolean")}(t)||o(t)||i(t)?t:(t=>e(t,"Date"))(t)?new Date(+t):void 0;const c=a?void 0:Object.keys(Object(t));let u=-1;if(n)for(;++u<(c||t).length;){const e=c?c[u]:u,r=t[e];n[e]=h(r)}return n}function l(t,e,n){r(e)||(e=t,t=0),r(n)||(n=1);let i=-1;const s=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(s);for(;++i<s;)o[i]=t+i*n;return o}function c(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function u(t){return Number(t)}function g(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:u;const r=t.length;if(!r)return;if(e<=0||r<2)return n(t[0],0,t);if(e>=1)return n(t[r-1],r-1,t);const i=(r-1)*e,s=Math.floor(i),o=n(t[s],s,t);return o+(n(t[s+1],s+1,t)-o)*(i-s)}function d(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;for(n(i)&&(i=t.length);r<i;){const n=r+i>>>1;c(t[n],e)>0?i=n:r=n+1}return r}const f=Math.sqrt(50),m=Math.sqrt(10),_=Math.sqrt(2);function p(t,e,n){const r=Math.abs(e-t)/Math.max(0,n);let i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10));const s=r/i;return s>=f?i*=10:s>=m?i*=5:s>=_&&(i*=2),e<t?-i:i}const M=1e-10,w=1e-10;function b(t,e){const n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:M,r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:w)*Math.max(t,e);return Math.abs(t-e)<=Math.max(n,r)}function y(t,e,n,r){return t>e&&!b(t,e,n,r)}function v(t,e,n,r){return t<e&&!b(t,e,n,r)}const x=t=>{let e=null,n=null;return function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return e&&i.every(((t,n)=>t===e[n]))||(e=i,n=t(...i)),n}},k=function(t){let e="",n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)-1;for(;n>=0;)e=`${e}${t}`,n-=1;return e},S=function(t,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"right";const r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:" ",i=t+"",s=e-i.length;return s<=0?i:"left"===n?k(r,s)+i:"center"===n?k(r,Math.floor(s/2))+i+k(r,Math.ceil(s/2)):i+k(r,s)};function T(t,e){let n;return t>e&&(n=t,t=e,e=n),n=>Math.max(t,Math.min(e,n))}let N=!1;try{N="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){N=!1}function D(t,e){return n=>t*(1-n)+e*n}function C(t,e){return function(n){return Math.round(t*(1-n)+e*n)}}N=!1;const U=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;function A(t){if(t instanceof Date)return t;if(i(t)){const e=U.exec(t);if(!e)return new Date(NaN);if(!e[8])return new Date(+e[1],+(e[2]||1)-1,+e[3]||1,+e[4]||0,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0);let n=+e[4]||0;return"Z"!==e[8].toUpperCase()&&(n-=+e[8].slice(0,3)),new Date(Date.UTC(+e[1],+(e[2]||1)-1,+e[3]||1,n,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0))}return n(t)?new Date(NaN):new Date(Math.round(t))}function F(t,e,n){e/=100,n/=100;const r=(1-Math.abs(2*n-1))*e,i=r*(1-Math.abs(t/60%2-1)),s=n-r/2;let o=0,a=0,h=0;return 0<=t&&t<60?(o=r,a=i,h=0):60<=t&&t<120?(o=i,a=r,h=0):120<=t&&t<180?(o=0,a=r,h=i):180<=t&&t<240?(o=0,a=i,h=r):240<=t&&t<300?(o=i,a=0,h=r):300<=t&&t<360&&(o=r,a=0,h=i),o=Math.round(255*(o+s)),a=Math.round(255*(a+s)),h=Math.round(255*(h+s)),{r:o,g:a,b:h}}function E(t,e,n){t/=255,e/=255,n/=255;const r=Math.min(t,e,n),i=Math.max(t,e,n),s=i-r;let o=0,a=0,h=0;return o=0===s?0:i===t?(e-n)/s%6:i===e?(n-t)/s+2:(t-e)/s+4,o=Math.round(60*o),o<0&&(o+=360),h=(i+r)/2,a=0===s?0:s/(1-Math.abs(2*h-1)),a=+(100*a).toFixed(1),h=+(100*h).toFixed(1),{h:o,s:a,l:h}}const O=/^#([0-9a-f]{3,8})$/,H={transparent:4294967040},R={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function I(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function L(t){return o(t)?new B(t>>16,t>>8&255,255&t,1):s(t)?new B(t[0],t[1],t[2]):new B(255,255,255)}class Y{static Brighter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new Y(t).brighter(e).toRGBA()}static SetOpacity(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new Y(t).setOpacity(e).toRGBA()}static getColorBrightness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hsl";const n=t instanceof Y?t:new Y(t);switch(e){case"hsv":default:return n.getHSVBrightness();case"hsl":return n.getHSLBrightness();case"lum":return n.getLuminance();case"lum2":return n.getLuminance2();case"lum3":return n.getLuminance3()}}static parseColorString(t){if(r(H[t]))return function(t){return o(t)?new B(t>>>24,t>>>16&255,t>>>8&255,255&t):s(t)?new B(t[0],t[1],t[2],t[3]):new B(255,255,255,1)}(H[t]);if(r(R[t]))return L(R[t]);const e=`${t}`.trim().toLowerCase(),n=O.exec(e);if(n){const t=parseInt(n[1],16),e=n[1].length;return 3===e?new B((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?L(t):8===e?new B(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):void 0}if(/^(rgb|RGB|rgba|RGBA)/.test(e)){const t=e.replace(/(?:\(|\)|rgba|RGBA|rgb|RGB)*/g,"").split(",");return new B(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3]))}if(/^(hsl|HSL|hsla|HSLA)/.test(e)){const t=e.replace(/(?:\(|\)|hsla|HSLA|hsl|HSL)*/g,"").split(","),n=F(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new B(n.r,n.g,n.b,parseFloat(t[3]))}}constructor(t){const e=Y.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new B(255,255,255))}toRGBA(){return this.color.formatRgb()}toString(){return this.color.formatRgb()}toHex(){return this.color.formatHex()}toHsl(){return this.color.formatHsl()}setOpacity(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.color.opacity=t,this}brighter(t){const{r:e,g:n,b:r}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t))),this.color.g=Math.max(0,Math.min(255,Math.floor(n*t))),this.color.b=Math.max(0,Math.min(255,Math.floor(r*t))),this}getHSVBrightness(){return Math.max(this.color.r,this.color.g,this.color.b)/255}getHSLBrightness(){return.5*(Math.max(this.color.r,this.color.g,this.color.b)/255+Math.min(this.color.r,this.color.g,this.color.b)/255)}setHsl(t,e,r){const i=this.color.opacity,s=E(this.color.r,this.color.g,this.color.b),o=F(n(t)?s.h:(l=360,(a=t)<(h=0)?h:a>l?l:a),n(e)?s.s:e>=0&&e<=1?100*e:e,n(r)?s.l:r<=1&&r>=0?100*r:r);var a,h,l;return this.color=new B(o.r,o.g,o.b,i),this}getLuminance(){return(.2126*this.color.r+.7152*this.color.g+.0722*this.color.b)/255}getLuminance2(){return(.2627*this.color.r+.678*this.color.g+.0593*this.color.b)/255}getLuminance3(){return(.299*this.color.r+.587*this.color.g+.114*this.color.b)/255}}class B{constructor(t,e,n,i){this.r=isNaN(+t)?255:Math.max(0,Math.min(255,+t)),this.g=isNaN(+e)?255:Math.max(0,Math.min(255,+e)),this.b=isNaN(+n)?255:Math.max(0,Math.min(255,+n)),r(i)?this.opacity=isNaN(+i)?1:Math.max(0,Math.min(1,+i)):this.opacity=1}formatHex(){return`#${I(this.r)+I(this.g)+I(this.b)+(1===this.opacity?"":I(255*this.opacity))}`}formatRgb(){const t=this.opacity;return`${1===t?"rgb(":"rgba("}${this.r},${this.g},${this.b}${1===t?")":`,${t})`}`}formatHsl(){const t=this.opacity,{h:e,s:n,l:r}=E(this.r,this.g,this.b);return`${1===t?"hsl(":"hsla("}${e},${n}%,${r}%${1===t?")":`,${t})`}`}toString(){return this.formatHex()}}var q,$,V=Object.freeze({__proto__:null,Color:Y,DEFAULT_COLORS:R,RGB:B,hexToRgb:function(t){let e="",n="",r="";const i="#"===t[0]?1:0;for(let s=i;s<t.length;s++)"#"!==t[s]&&(s<i+2?e+=t[s]:s<i+4?n+=t[s]:s<i+6&&(r+=t[s]));return[parseInt(e,16),parseInt(n,16),parseInt(r,16)]},hslToRgb:F,interpolateRgb:function(t,e){const n=t.r,r=e.r,i=t.g,s=e.g,o=t.b,a=e.b,h=t.opacity,l=e.opacity;return t=>{const e=Math.round(n*(1-t)+r*t),c=Math.round(i*(1-t)+s*t),u=Math.round(o*(1-t)+a*t);return new B(e,c,u,h*(1-t)+l*t)}},rgbToHex:function(t,e,n){return Number((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)},rgbToHsl:E});function j(t){return t?"getUTCFullYear":"getFullYear"}function P(t){return t?"getUTCMonth":"getMonth"}function z(t){return t?"getUTCDate":"getDate"}function Q(t){return t?"getUTCHours":"getHours"}function G(t){return t?"getUTCMinutes":"getMinutes"}function X(t){return t?"getUTCSeconds":"getSeconds"}function W(t){return t?"getUTCMilliseconds":"getMilliseconds"}function Z(t){return t?"setUTCFullYear":"setFullYear"}function J(t,e){return n=>{const r=A(n),i=r[j(e)](),s=r[P(e)]()+1,o=Math.floor((s-1)/3)+1,a=r[z(e)](),h=r["get"+(e?"UTC":"")+"Day"](),l=r[Q(e)](),c=(l-1)%12+1,u=r[G(e)](),g=r[X(e)](),d=r[W(e)]();return(t||"").replace(/YYYY/g,S(i+"",4,"0","left")).replace(/yyyy/g,i+"").replace(/yy/g,i%100+"").replace(/Q/g,o+"").replace(/MM/g,S(s,2,"0","left")).replace(/M/g,s+"").replace(/dd/g,S(a,2,"0","left")).replace(/d/g,a+"").replace(/e/g,h+"").replace(/HH/g,S(l,2,"0","left")).replace(/H/g,l+"").replace(/hh/g,S(c+"",2,"0","left")).replace(/h/g,c+"").replace(/mm/g,S(u,2,"0","left")).replace(/m/g,u+"").replace(/ss/g,S(g,2,"0","left")).replace(/s/g,g+"").replace(/SSS/g,S(d,3,"0","left")).replace(/S/g,d+"")}}!function(t){t[t.NONE=0]="NONE",t[t.BBOX1=1]="BBOX1",t[t.BBOX2=2]="BBOX2"}(q||(q={})),function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Info=3]="Info",t[t.Debug=4]="Debug"}($||($={}));const K=1e3,tt=6e4,et=36e5,nt=24*et,rt=31*nt,it=365*nt,st=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),ot=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),at=(t,e)=>e.getFullYear()-t.getFullYear(),ht=t=>t.getFullYear(),lt=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),ct=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),ut=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),gt=t=>t.getUTCFullYear(),dt=t=>(t.setDate(1),t.setHours(0,0,0,0),t),ft=(t,e)=>(t.setMonth(t.getMonth()+e),t),mt=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),_t=t=>t.getMonth(),pt=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),Mt=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),wt=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),bt=t=>t.getUTCMonth(),yt=t=>(t.setHours(0,0,0,0),t),vt=(t,e)=>(t.setDate(t.getDate()+e),t),xt=(t,e)=>(+e-+t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/nt,kt=t=>t.getDate()-1,St=t=>(t.setUTCHours(0,0,0,0),t),Tt=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),Nt=(t,e)=>(+e-+t)/nt,Dt=t=>t.getUTCDate()-1,Ct=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes()),t),Ut=(t,e)=>(t.setHours(t.getHours()+e),t),At=(t,e)=>(+e-+t)/et,Ft=t=>t.getHours(),Et=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()-6e4*t.getUTCMinutes()),t),Ot=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),Ht=t=>t.getUTCHours(),Rt=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()),t),It=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),Lt=(t,e)=>(+e-+t)/6e4,Yt=t=>t.getMinutes(),Bt=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()),t),qt=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),$t=t=>t.getUTCMinutes(),Vt=t=>(t.setTime(+t-t.getMilliseconds()),t),jt=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),Pt=(t,e)=>(+e-+t)/1e3,zt=t=>t.getSeconds(),Qt=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),Gt=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),Xt=t=>t.getUTCSeconds(),Wt=t=>t,Zt=(t,e)=>(t.setTime(+t+e),t),Jt=(t,e)=>+e-+t,Kt=(t,e)=>n=>{const r=new Date(+n-1);return e(r,1),t(r),r},te=(t,e)=>{let{floor:n,offset:r,field:i,count:s}=e;const o=Math.floor(t);if(!Number.isFinite(o)||o<=0)return null;if(o<=1)return{floor:n,offset:r,ceil:Kt(n,r)};const a=((t,e)=>(n,r)=>{const i=new Date,s=new Date;return i.setTime(+n),s.setTime(+r),t(i),t(s),Math.floor(e(i,s))})(n,s),h=i?t=>i(t)%o==0:t=>a(0,t)%o==0,l=t=>{if(!Number.isNaN(+t))for(n(t);!h(t);)t.setTime(+t-1),n(t);return t},c=(t,e)=>{if(!Number.isNaN(+t))if(o<0)for(;++e<=0;)for(r(t,-1);!h(t);)r(t,-1);else for(;--e>=0;)for(r(t,1);!h(t);)r(t,1);return t};return{floor:l,offset:c,ceil:Kt(l,c)}};var ee;t.ScaleEnum=void 0,(ee=t.ScaleEnum||(t.ScaleEnum={})).Linear="linear",ee.Log="log",ee.Pow="pow",ee.Sqrt="sqrt",ee.Symlog="symlog",ee.Time="time",ee.Quantile="quantile",ee.Quantize="quantize",ee.Threshold="threshold",ee.Ordinal="ordinal",ee.Point="point",ee.Band="band";class ne{_wholeRange;_rangeFactor;_unknown;_calculateRange(t){if(this._wholeRange)return this._wholeRange;if(this._rangeFactor&&2===t.length){const e=(t[1]-t[0])/(this._rangeFactor[1]-this._rangeFactor[0]),n=t[0]-e*this._rangeFactor[0],r=n,i=e+n;return this._wholeRange=[r,i],this._wholeRange}return t}rangeFactor(t,e){return t?(2===t.length&&t.every((t=>t>=0&&t<=1))&&(this._wholeRange=null,this._rangeFactor=t),this):this._rangeFactor}unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}}const re=Symbol("implicit");class ie extends ne{type=t.ScaleEnum.Ordinal;_index;_domain;_ordinalRange;_specified;specified(t){return t?(this._specified=Object.assign(this._specified??{},t),this):Object.assign({},this._specified)}_getSpecifiedValue(t){if(this._specified)return this._specified[t]}constructor(){super(),this._index=new Map,this._domain=[],this._ordinalRange=[],this._unknown=re}clone(){return(new ie).domain(this._domain).range(this._ordinalRange).unknown(this._unknown)}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this._domain}scale(t){const e=`${t}`,n=this._getSpecifiedValue(e);if(void 0!==n)return n;let r=this._index.get(e);if(!r){if(this._unknown!==re)return this._unknown;r=this._domain.push(t),this._index.set(e,r)}return this._ordinalRange[(r-1)%this._ordinalRange.length]}invert(t){let e=0;for(;e<this._ordinalRange.length&&this._ordinalRange[e]!==t;)e++;return this._domain[(e-1)%this._domain.length]}domain(t){if(!t)return this._domain.slice();this._domain=[],this._index=new Map;for(const e of t){const t=`${e}`;this._index.has(t)||this._index.set(t,this._domain.push(e))}return this}range(t){if(!t)return this._ordinalRange.slice();const e=Array.from(t);return this._ordinalRange=e,this}}function se(t){return t}const oe=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t),ae=t=>t<0?-Math.sqrt(-t):Math.sqrt(t),he=t=>t<0?-t*t:t*t,le=t=>-Math.log(-t),ce=t=>-Math.exp(-t),ue=t=>isFinite(t)?Math.pow(10,t):t<0?0:t,ge=t=>10===t?ue:t===Math.E?Math.exp:e=>Math.pow(t,e),de=t=>t===Math.E?Math.log:10===t?Math.log10:2===t?Math.log2:(t=Math.log(t),e=>Math.log(e)/t),fe=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),me=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t;function _e(t,e){if(t=Number(t),e=Number(e),e-=t)return n=>(n-t)/e;const n=Number.isNaN(e)?NaN:.5;return()=>n}function pe(t,e,n){const r=t[0],i=t[1],s=e[0],o=e[1];let a,h;return i<r?(a=_e(i,r),h=n(o,s)):(a=_e(r,i),h=n(s,o)),t=>h(a(t))}function Me(t,e,n){const r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r);let o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=_e(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(e){const n=d(t,e,1,r)-1;return s[n](i[n](e))}}const we=(t,e)=>{const n=t.slice();let r=0,i=n.length-1,s=n[r],o=n[i];return o<s&&([r,i]=[i,r],[s,o]=[o,s]),n[r]=e.floor(s),n[i]=e.ceil(o),n};function be(t,e,n,r){let i;const s=[];let o;if(e=Math.floor(+e),t=Math.floor(+t),!(n=Math.floor(+n)))return[];if(t===e)return[t];if(i=e<t){const n=t;t=e,e=n}let a=T(1,e-t+1)(n);if(o=Math.floor((e-t+1)/a),!r)for(;Math.ceil((e-t+1)/o)>n&&a>1;)a-=1,o=Math.floor((e-t)/a);let h=t;for(;h<=e;)s.push(h),h+=o;return i&&s.reverse(),s}class ye extends ie{type=t.ScaleEnum.Band;_step;_bandwidth;_round;_paddingInner;_paddingOuter;_align;_range;constructor(t){super(),this._range=[0,1],this._step=void 0,this._bandwidth=void 0,this._round=!1,this._paddingInner=0,this._paddingOuter=0,this._align=.5,this._unknown=void 0,delete this.unknown,this.rescale(t)}rescale(t){if(t)return this;this._wholeRange=null;const e=this._calculateRange(this._range),n=super.domain().length,r=e[1]<e[0];let i=e[Number(r)-0];const s=e[1-Number(r)],o=function(t,e,n){let r;return r=1===t?t+2*n:t-e+2*n,t?r>0?r:1:0}(n,this._paddingInner,this._paddingOuter);this._step=(s-i)/Math.max(1,o||1),this._round&&(this._step=Math.floor(this._step)),i+=(s-i-this._step*(n-this._paddingInner))*this._align,this._bandwidth=this._step*(1-this._paddingInner),this._round&&(i=Math.round(i),this._bandwidth=Math.round(this._bandwidth));const a=l(n).map((t=>i+this._step*t));return super.range(r?a.reverse():a),this}calculateVisibleDomain(t){const e=this._domain;if(this._rangeFactor&&e.length){const n=this._getInvertIndex(t[0]),r=this._getInvertIndex(t[1]);return e.slice(Math.min(n,r),Math.max(n,r)+1)}return e}domain(t,e){return t?(super.domain(t),this.rescale(e)):super.domain()}range(t,e){return t?(this._range=[u(t[0]),u(t[1])],this.rescale(e)):this._range.slice()}rangeRound(t,e){return this._range=[u(t[0]),u(t[1])],this._round=!0,this.rescale(e)}ticks(t=10){const e=this.calculateVisibleDomain(this._range);if(-1===t)return e.slice();return be(0,e.length-1,t,!1).map((t=>e[t]))}tickData(t=10){return this.ticks(t).map(((t,e)=>({index:e,tick:t,value:(this.scale(t)-this._range[0]+this._bandwidth/2)/(this._range[1]-this._range[0])})))}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return be(0,e.length-1,t,!0).filter((t=>t<e.length)).map((t=>e[t]))}stepTicks(t){const e=this.calculateVisibleDomain(this._range),n=function(t,e,n){const r=[];let i;if(n=T(1,(e=Math.floor(+e))-(t=Math.floor(+t))+1)(Math.floor(+n)),i=e<t){const n=t;t=e,e=n}let s=t;for(;s<=e;)r.push(s),s+=n;return i&&r.reverse(),r}(0,e.length-1,t);return n.map((t=>e[t]))}_getInvertIndex(t){let e=0;const n=this.step()/2,r=this.bandwidth()/2,i=this._domain.length,s=this.range(),o=s[0]>s[s.length-1];for(e=0;e<i;e++){const s=this.scale(this._domain[e])+r;if(0===e&&(!o&&!y(t,s+n)||o&&!v(t,s-n)))break;if(e===i-1)break;if(!v(t,s-n)&&!y(t,s+n))break}return e>=0&&e<=i-1?e:i-1}invert(t){return this._domain[this._getInvertIndex(t)]}padding(t,e){return void 0!==t?(this._paddingOuter=Math.max(0,Math.min(Array.isArray(t)?Math.min.apply(null,t):t)),this._paddingInner=this._paddingOuter,this.rescale(e)):this._paddingInner}paddingInner(t,e){return void 0!==t?(this._paddingInner=Math.max(0,Math.min(1,t)),this.rescale(e)):this._paddingInner}paddingOuter(t,e){return void 0!==t?(this._paddingOuter=Math.max(0,Math.min(1,t)),this.rescale(e)):this._paddingOuter}bandwidth(){return this._bandwidth}step(){return this._step}round(t,e){return void 0!==t?(this._round=t,this.rescale(e)):this._round}align(t,e){return void 0!==t?(this._align=Math.max(0,Math.min(1,t)),this.rescale(e)):this._align}rangeFactor(t,e){return t?(super.rangeFactor(t),this.rescale(e)):super.rangeFactor()}clone(){return new ye(!0).domain(this._domain,!0).range(this._range,!0).round(this._round,!0).paddingInner(this._paddingInner,!0).paddingOuter(this._paddingOuter,!0).align(this._align)}}const{interpolateRgb:ve}=V;function xe(t,e){const r=typeof e;let i;if(n(e)||"boolean"===r)return()=>e;if("number"===r)return D(t,e);if("string"===r){if(i=Y.parseColorString(e)){const e=ve(Y.parseColorString(t),i);return t=>e(t).formatRgb()}return D(Number(t),Number(e))}return e instanceof B?ve(t,e):e instanceof Y?ve(t.color,e.color):e instanceof Date?function(t,e){const n=t.valueOf(),r=e.valueOf(),i=new Date;return t=>(i.setTime(n*(1-t)+r*t),i)}(t,e):D(Number(t),Number(e))}class ke extends ne{type;transformer;untransformer;_niceDomain;_domain;_range;_unknown=void 0;_forceAlign;_output;_input;_interpolate;_piecewise;_clamp;constructor(t=se,e=se){super(),this.transformer=t,this.untransformer=e,this._forceAlign=!0,this._domain=[0,1],this._range=[0,1],this._clamp=se,this._piecewise=pe,this._interpolate=xe}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this._niceDomain??this._domain}scale(t){return t=Number(t),Number.isNaN(t)?this._unknown:(this._output||(this._output=this._piecewise((this._niceDomain??this._domain).map(this.transformer),this._calculateRange(this._range),this._interpolate)),this._output(this.transformer(this._clamp(t))))}invert(t){return this._input||(this._input=this._piecewise(this._calculateRange(this._range),this._domain.map(this.transformer),D)),this._clamp(this.untransformer(this._input(t)))}domain(t,e){if(!t)return(this._niceDomain??this._domain).slice();const n=Array.from(t,u);return this._domain=n,this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return this._range=n,this.rescale(e)}rangeRound(t,e){const n=Array.from(t);return this._range=n,this._interpolate=C,this.rescale(e)}rescale(t){if(t)return this;const e=this._niceDomain??this._domain,n=e.length,r=this._range.length;let i=Math.min(n,r);if(n&&n<r&&this._forceAlign){const t=r-n+1,s=e[n-1],o=n>=2?(s-e[n-2])/t:0;for(let r=1;r<=t;r++)e[n-2+r]=s-o*(t-r);i=r}return void 0===this._clamp&&(this._clamp=T(e[0],e[i-1])),this._piecewise=i>2?Me:pe,this._output=this._input=null,this._wholeRange=null,this}clamp(t,e,n){return arguments.length?(this._clamp=e||(t?void 0:se),this.rescale(n)):this._clamp!==se}interpolate(t,e){return arguments.length?(this._interpolate=t,this.rescale(e)):this._interpolate}ticks(t=10){return[]}tickData(t=10){return(this.ticks(t)??[]).map(((t,e)=>({index:e,tick:t,value:(this.scale(t)-this._range[0])/(this._range[1]-this._range[0])})))}rangeFactor(t,e){return t?(super.rangeFactor(t),this._output=this._input=null,this):super.rangeFactor()}forceAlignDomainRange(t){return arguments.length?(this._forceAlign=t,this):this._forceAlign}}const Se=Math.sqrt(50),Te=Math.sqrt(10),Ne=Math.sqrt(2),De=[1,2,5,10],Ce=(t,e,n)=>{let r=1,i=t;const s=Math.floor((e-1)/2),o=Math.abs(t);return t>=0&&t<=Number.MIN_VALUE?i=0:t<0&&t>=-Number.MIN_VALUE?i=-(e-1):!n&&o<1?r=Ee(o).step:(n||o>1)&&(i=Math.floor(t)-s*r),r>0?(t>0?i=Math.max(i,0):t<0&&(i=Math.min(i,-(e-1)*r)),l(0,e).map((t=>i+t*r))):t>0?Ae(0,-(e-1)/r,r):Ae((e-1)/r,0,r)},Ue=x(((t,e,n,r)=>{let i,s,o,a,h=-1;if(n=+n,(t=+t)===(e=+e))return[t];if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return[t];if((i=e<t)&&(s=t,t=e,e=s),a=Oe(t,e,n).step,!isFinite(a))return[];if(a>0){let n=Math.round(t/a),r=Math.round(e/a);for(n*a<t&&++n,r*a>e&&--r,o=new Array(s=r-n+1);++h<s;)o[h]=(n+h)*a}else if(a<0&&r?.noDecimals){a=1;const n=Math.ceil(t),r=Math.floor(e);if(!(n<=r))return[];for(o=new Array(s=r-n+1);++h<s;)o[h]=n+h}else{a=-a;let n=Math.round(t*a),r=Math.round(e*a);for(n/a<t&&++n,r/a>e&&--r,o=new Array(s=r-n+1);++h<s;)o[h]=(n+h)/a}return i&&o.reverse(),o})),Ae=(t,e,n)=>{let r,i,s=-1;if(n>0){let o=Math.floor(t/n),a=Math.ceil(e/n);for((o+1)*n<t&&++o,(a-1)*n>e&&--a,i=new Array(r=a-o+1);++s<r;)i[s]=(o+s)*n}else{n=-n;let o=Math.floor(t*n),a=Math.ceil(e*n);for((o+1)/n<t&&++o,(a-1)/n>e&&--a,i=new Array(r=a-o+1);++s<r;)i[s]=(o+s)/n}return i},Fe=x(((t,e,n,r)=>{let i,s,o;if(n=+n,(t=+t)===(e=+e))return Ce(t,n,r?.noDecimals);if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return Ce(t,n,r?.noDecimals);(i=e<t)&&(o=t,t=e,e=o);const a=Oe(t,e,n);let h=a.step;if(!isFinite(h))return[];if(h>0){let r=1;const{power:i,gap:o}=a,l=10===o?2*10**i:1*10**i;for(;r<=5&&(s=Ae(t,e,h),s.length>n)&&n>2;)h+=l,r+=1;s.length<n&&(s=((t,e,n)=>{let r;const i=t[0],s=t[t.length-1],o=e-t.length;if(s<=0){const e=[];for(r=o;r>=1;r--)e.push(i-r*n);return e.concat(t)}if(i>=0){for(r=1;r<=o;r++)t.push(s+r*n);return t}let a=[];const h=[];for(r=1;r<=o;r++)r%2==0?a=[i-Math.floor(r/2)*n].concat(a):h.push(s+Math.ceil(r/2)*n);return a.concat(t).concat(h)})(s,n,h))}else r?.noDecimals&&h<0&&(h=1),s=Ae(t,e,h);return i&&s.reverse(),s})),Ee=t=>{const e=Math.floor(Math.log(t)/Math.LN10),n=t/10**e;let r=De[0];return n>=Se?r=De[3]:n>=Te?r=De[2]:n>=Ne&&(r=De[1]),e>=0?{step:r*10**e,gap:r,power:e}:{step:-(10**-e)/r,gap:r,power:e}};function Oe(t,e,n){const r=(e-t)/Math.max(0,n);return Ee(r)}function He(t,e,n){let r;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if(n<=0||0===(r=function(t,e,n){const r=(e-t)/Math.max(1,n-1);return r}(t,e,n))||!isFinite(r))return[];const i=new Array(n);for(let e=0;e<n;e++)i[e]=t+e*r;return i}function Re(t,e,n){let r,i,s=-1;if(n=+n,(i=(e=+e)<(t=+t))&&(r=t,t=e,e=r),!isFinite(n)||e-t<=n)return[t];const o=Math.floor((e-t)/n+1),a=new Array(o);for(;++s<o;)a[s]=t+s*n;return i&&a.reverse(),a}function Ie(t,e=10){let n,r,i=0,s=t.length-1,o=t[i],a=t[s],h=10;for(a<o&&(r=o,o=a,a=r,r=i,i=s,s=r);h-- >0;){if(r=Oe(o,a,e).step,r===n)return t[i]=o,t[s]=a,t;if(r>0)o=Math.floor(o/r)*r,a=Math.ceil(a/r)*r;else{if(!(r<0))break;o=Math.ceil(o*r)/r,a=Math.floor(a*r)/r}n=r}}class Le extends ke{type=t.ScaleEnum.Linear;_needNiceMin;_needNiceMax;_needNice;clone(){return(new Le).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}tickFormat(){return()=>{}}domain(t,e){if(!t)return(this._niceDomain??this._domain).slice();this._needNice=!1,this._needNiceMax=!1,this._needNiceMin=!1,this._niceDomain=null;const n=Array.from(t,u);return this._domain=n,this.rescale(e)}d3Ticks(t=10,e){const n=this.calculateVisibleDomain(this._range);return Ue(n[0],n[n.length-1],t,e)}ticks(t=10,e){if(this._rangeFactor&&(this._rangeFactor[0]>0||this._rangeFactor[1]<1)&&2===this._range.length||!this._needNice&&!this._needNiceMin&&!this._needNiceMax)return this.d3Ticks(t,e);const n=this._domain,r=n[0],i=n[n.length-1];let s=Fe(r,i,t,e);if(s.length&&(s[0]!==r&&(this._needNice||this._needNiceMin)||s[s.length-1]!==i&&(this._needNice||this._needNiceMax))){const t=n.slice();if((this._needNice||this._needNiceMin)&&(t[0]=s[0]),(this._needNice||this._needNiceMax)&&(t[t.length-1]=s[s.length-1]),this._niceDomain=t,this.rescale(),!this._needNice){const e=Math.min(t[0],t[t.length-1]),n=Math.max(t[0],t[t.length-1]);s=s.filter((t=>t>=e&&t<=n))}}return s}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return He(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return Re(e[0],e[e.length-1],t)}nice(t=10){this._needNice=!0;const e=Ie(this.domain(),t);return e&&(this._niceDomain=e,this.rescale()),this}niceMin(t=10){this._needNiceMin=!0;const e=this._domain[this._domain.length-1],n=Ie(this.domain(),t);return n&&(n[n.length-1]=e,this._niceDomain=n,this.rescale()),this}niceMax(t=10){this._needNiceMax=!0;const e=this._domain[0],n=Ie(this.domain(),t);return n&&(n[0]=e,this._niceDomain=n,this.rescale()),this}}function Ye(t){return e=>-t(-e)}class Be extends ke{type=t.ScaleEnum.Log;_base;_logs;_pows;constructor(){super(de(10),ge(10)),this._logs=this.transformer,this._pows=this.untransformer,this._domain=[1,10],this._base=10}clone(){return(new Be).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).base(this._base)}rescale(t){if(t)return this;super.rescale();const e=de(this._base),n=ge(this._base);return this._domain[0]<0?(this._logs=Ye(e),this._pows=Ye(n),this.transformer=le,this.untransformer=ce):(this._logs=e,this._pows=n,this.transformer=e,this.untransformer=n),this}base(t,e){return arguments.length?(this._base=t,this.rescale(e)):this._base}tickFormat(){return se}d3Ticks(t=10){const e=this.domain();let n=e[0],r=e[e.length-1];const i=r<n;i&&([n,r]=[r,n]);let s,o,a=this._logs(n),h=this._logs(r),l=[];if(!(this._base%1)&&h-a<t){if(a=Math.floor(a),h=Math.ceil(h),n>0){for(;a<=h;++a)for(s=1;s<this._base;++s)if(o=a<0?s/this._pows(-a):s*this._pows(a),!(o<n)){if(o>r)break;l.push(o)}}else for(;a<=h;++a)for(s=this._base-1;s>=1;--s)if(o=a>0?s/this._pows(-a):s*this._pows(a),!(o<n)){if(o>r)break;l.push(o)}2*l.length<t&&(l=Fe(n,r,t))}else l=Fe(a,h,Math.min(h-a,t)).map(this._pows);return i?l.reverse():l}ticks(t=10){return this.d3Ticks(t)}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return He(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return Re(e[0],e[e.length-1],t)}nice(){return this.domain(we(this.domain(),{floor:t=>this._pows(Math.floor(this._logs(t))),ceil:t=>this._pows(Math.ceil(this._logs(t)))}))}niceMin(){const t=this._domain[this._domain.length-1];this.nice();const e=h(this._domain);return this._domain&&(e[e.length-1]=t,this.domain(e)),this}niceMax(){const t=this._domain[0];this.nice();const e=h(this._domain);return this._domain&&(e[0]=t,this.domain(e)),this}}class qe extends Le{type=t.ScaleEnum.Pow;_exponent;constructor(){super(),this._exponent=1}clone(){return(new qe).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).exponent(this._exponent)}rescale(t){return t||(1===this._exponent?(this.transformer=se,this.untransformer=se):.5===this._exponent?(this.transformer=ae,this.untransformer=he):(this.transformer=oe(this._exponent),this.untransformer=oe(1/this._exponent)),super.rescale()),this}exponent(t,e){return arguments.length?(this._exponent=t,this.rescale(e)):this._exponent}}function $e(t,e){return t.length===e.length&&t.every(((t,n)=>t===e[n]))}class Ve{type=t.ScaleEnum.Quantile;_range=[];_domain=[];_thresholds=[];_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}rescale(t){if(t)return this;let e=0;const n=Math.max(1,this._range.length);for(this._thresholds=new Array(n-1);++e<n;)this._thresholds[e-1]=g(this._domain,e/n);return this}scale(t){return a(t)?this._range[d(this._thresholds,t)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return e<0?[NaN,NaN]:[e>0?this._thresholds[e-1]:this._domain[0],e<this._thresholds.length?this._thresholds[e]:this._domain[this._domain.length-1]]}quantiles(){return this._thresholds.slice()}domain(t,e){if(!t)return this._domain.slice();this._domain=[];for(const e of t)n(e)||Number.isNaN(+e)||this._domain.push(+e);return this._domain.sort(c),this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return $e(this._range,n)?this:(this._range=n,this.rescale(e))}clone(){return(new Ve).domain(this._domain,!0).range(this._range).unknown(this._unknown)}}class je{type=t.ScaleEnum.Quantile;_range=[0,1];_domain=[.5];x0=0;x1=1;n=1;_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}rescale(t){if(t)return this;let e=-1;for(this._domain=new Array(this.n);++e<this.n;)this._domain[e]=((e+1)*this.x1-(e-this.n)*this.x0)/(this.n+1);return this}scale(t){return a(t)?this._range[d(this._domain,t,0,this.n)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return e<0?[NaN,NaN]:e<1?[this.x0,this._domain[0]]:e>=this.n?[this._domain[this.n-1],this.x1]:[this._domain[e-1],this._domain[e]]}thresholds(){return this._domain.slice()}domain(t,e){if(!t)return[this.x0,this.x1];const n=Array.from(t);return this.x0=+n[0],this.x1=+n[1],this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return $e(this._range,n)?this:(this.n=n.length-1,this._range=n,this.rescale(e))}clone(){return(new je).domain([this.x0,this.x1],!0).range(this._range).unknown(this._unknown)}ticks(t=10){const e=this.domain();return Fe(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.domain();return He(e[0],e[e.length-1],t)}stepTicks(t){const e=this.domain();return Re(e[0],e[e.length-1],t)}nice(t=10){const e=Ie(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=Ie(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=Ie(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}class Pe extends Le{type=t.ScaleEnum.Sqrt;constructor(){super(ae,he)}clone(){return(new Pe).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}}class ze extends Le{type=t.ScaleEnum.Symlog;_const;constructor(){super(fe(1),me(1)),this._const=1}clone(){return(new ze).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).constant(this._const)}constant(t,e){return arguments.length?(this._const=t,this.transformer=fe(t),this.untransformer=me(t),this.rescale(e)):this._const}}class Qe{type=t.ScaleEnum.Threshold;_range=[0,1];_domain=[.5];n=1;_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}scale(t){return!n(t)&&a(+t)?this._range[d(this._domain,t,0,this.n)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return[this._domain[e-1],this._domain[e]]}domain(t){return t?(this._domain=Array.from(t),this.n=Math.min(this._domain.length,this._range.length-1),this):this._domain.slice()}range(t){return t?(this._range=Array.from(t),this.n=Math.min(this._domain.length,this._range.length-1),this):this._range.slice()}clone(){return(new Qe).domain(this._domain).range(this._range).unknown(this._unknown)}}const Ge=[["second",1,K],["second",5,5e3],["second",10,1e4],["second",30,3e4],["minute",1,tt],["minute",5,3e5],["minute",10,6e5],["minute",30,18e5],["hour",1,et],["hour",3,3*et],["hour",6,6*et],["hour",12,12*et],["day",1,nt],["day",2,2*nt],["day",7,7*nt],["month",1,rt],["month",3,3*rt],["month",6,6*rt],["year",1,365*nt]];function Xe(t){return+A(t)}function We(t,e,n,r){const i=(+e-+t)/n,s=d(Ge.map((t=>t[2])),i);if(s===Ge.length){const i=Math.max(p(+t/it,+e/it,n),1),s=t=>(t[Z(r)](Math.floor(t[j(r)]()/i)*i),t[function(t){return t?"setUTCMonth":"setMonth"}(r)](0,1),t[function(t){return t?"setUTCHours":"setHours"}(r)](0,0,0,0),t),o=(t,e)=>(t[Z(r)](t[j(r)]()+e*i),t);return{floor:s,offset:o,ceil:Kt(s,o)}}if(0===s){const r=Math.max(p(+t,+e,n),1),i=t=>(t.setTime(Math.floor(+t/r)*r),t),s=(t,e)=>(t.setTime(+t+e*r),t);return{floor:i,offset:s,ceil:Kt(i,s)}}const[o,a]=Ge[i/Ge[s-1][2]<Ge[s][2]/i?s-1:s],h=((t,e)=>"year"===t&&e?{floor:lt,offset:ct,count:ut,field:gt}:"month"===t&&e?{floor:pt,offset:Mt,count:wt,field:bt}:"day"===t&&e?{floor:St,offset:Tt,count:Nt,field:Dt}:"hour"===t&&e?{floor:Et,offset:Ot,count:At,field:Ht}:"minute"===t&&e?{floor:Bt,offset:qt,count:Lt,field:$t}:"second"===t&&e?{floor:Qt,offset:Gt,count:Pt,field:Xt}:"year"===t?{floor:st,offset:ot,count:at,field:ht}:"month"===t?{floor:dt,offset:ft,count:mt,field:_t}:"day"===t?{floor:yt,offset:vt,count:xt,field:kt}:"hour"===t?{floor:Ct,offset:Ut,count:At,field:Ft}:"minute"===t?{floor:Rt,offset:It,count:Lt,field:Yt}:"second"===t?{floor:Vt,offset:jt,count:Pt,field:zt}:{floor:Wt,offset:Zt,count:Jt})(o,r);return te(a,h)}class Ze extends ke{type=t.ScaleEnum.Time;_isUtc;constructor(t=!1){super(),this._domain=t?[Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]:[+new Date(2e3,0,1),+new Date(2e3,0,2)],this._isUtc=t}invert(t){return new Date(super.invert(t))}domain(t,e){if(!t)return this._domain.map(A);const n=Array.from(t,Xe);return this._domain=n,this.rescale(e)}ticks(t){const e=this.domain();let r=e[0],i=e[e.length-1];const s=i<r;s&&([r,i]=[i,r]);let a=t;(o(t)||n(t))&&(a=We(r,i,n(t)?10:t,this._isUtc)),r=a.ceil(r);const h=[];let l=+r,c=0;for(;l<=+i&&c<100;)h.push(new Date(l)),l=+a.offset(new Date(l),1),c++;return s?h.reverse():h}tickFormat(t,e){return J(null==e?function(t,e){const n=A(t),r=n[P(e)]()+1,i=n[z(e)](),s=n[Q(e)](),o=n[G(e)](),a=n[X(e)](),h=0===n[W(e)](),l=h&&0===a,c=l&&0===o,u=c&&0===s,g=u&&1===i;return g&&1===r?"YYYY":g?"YYYY-MM":u?"YYYY-MM-DD":c?"HH":l?"HH:mm":h?"HH:mm:ss":"HH:mm:ss SSS"}(this._domain[0],this._isUtc):e,this._isUtc)}clone(){return new Ze(this._isUtc).domain(this.domain(),!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}nice(t){const e=this.domain();let r=t;return(o(t)||n(t))&&(r=We(e[0],e[e.length-1],n(t)?10:t,this._isUtc)),r&&this.domain(we(e,r)),this}utc(){return this._isUtc}}t.BandScale=ye,t.ContinuousScale=ke,t.LinearScale=Le,t.LogScale=Be,t.OrdinalScale=ie,t.PointScale=class extends ye{type=t.ScaleEnum.Point;_padding=0;constructor(t){super(!1),this.paddingInner(1,t),this.padding=this.paddingOuter,this.paddingInner=void 0,this.paddingOuter=void 0}},t.PowScale=qe,t.QuantileScale=Ve,t.QuantizeScale=je,t.SqrtScale=Pe,t.SymlogScale=ze,t.ThresholdScale=Qe,t.TimeScale=Ze,t.isContinuous=function(e){switch(e){case t.ScaleEnum.Linear:case t.ScaleEnum.Log:case t.ScaleEnum.Pow:case t.ScaleEnum.Sqrt:case t.ScaleEnum.Symlog:case t.ScaleEnum.Time:return!0;default:return!1}},t.isDiscrete=function(e){switch(e){case t.ScaleEnum.Ordinal:case t.ScaleEnum.Point:case t.ScaleEnum.Band:return!0;default:return!1}},t.isDiscretizing=function(e){switch(e){case t.ScaleEnum.Quantile:case t.ScaleEnum.Quantize:case t.ScaleEnum.Threshold:return!0;default:return!1}},t.isValidScaleType=function(e){switch(e){case t.ScaleEnum.Linear:case t.ScaleEnum.Log:case t.ScaleEnum.Pow:case t.ScaleEnum.Sqrt:case t.ScaleEnum.Symlog:case t.ScaleEnum.Time:case t.ScaleEnum.Ordinal:case t.ScaleEnum.Point:case t.ScaleEnum.Band:return!0;default:return!1}}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VScale={})}(this,(function(t){"use strict";!function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,i,s,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new r(i,s||t,o),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,o=new Array(s);r<s;r++)o[r]=i[r].fn;return o},a.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},a.prototype.emit=function(t,e,i,r,s,o){var a=n?n+t:t;if(!this._events[a])return!1;var h,l,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,r),!0;case 5:return c.fn.call(c.context,e,i,r,s),!0;case 6:return c.fn.call(c.context,e,i,r,s,o),!0}for(l=1,h=new Array(u-1);l<u;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var g,d=c.length;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,i);break;case 4:c[l].fn.call(c[l].context,e,i,r);break;default:if(!h)for(g=1,h=new Array(u-1);g<u;g++)h[g-1]=arguments[g];c[l].fn.apply(c[l].context,h)}}return!0},a.prototype.on=function(t,e,n){return s(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return s(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,i,r){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||r&&!a.once||i&&a.context!==i||o(this,s);else{for(var h=0,l=[],c=a.length;h<c;h++)(a[h].fn!==e||r&&!a[h].once||i&&a[h].context!==i)&&l.push(a[h]);l.length?this._events[s]=1===l.length?l[0]:l:o(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&o(this,e)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}({exports:{}});const e=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,n=t=>null==t,i=t=>null!=t,r=function(t){const n=typeof t;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"string"===n:"string"===n||e(t,"String")},s=t=>Array.isArray?Array.isArray(t):e(t,"Array"),o=function(t){const n=typeof t;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"number"===n:"number"===n||e(t,"Number")},a=t=>o(t)&&Number.isFinite(t);function h(t,e,n){i(e)||(e=t,t=0),i(n)||(n=1);let r=-1;const s=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(s);for(;++r<s;)o[r]=t+r*n;return o}function l(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function c(t){return Number(t)}function u(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c;const i=t.length;if(!i)return;if(e<=0||i<2)return n(t[0],0,t);if(e>=1)return n(t[i-1],i-1,t);const r=(i-1)*e,s=Math.floor(r),o=n(t[s],s,t);return o+(n(t[s+1],s+1,t)-o)*(r-s)}function g(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0;for(n(r)&&(r=t.length);i<r;){const n=i+r>>>1;l(t[n],e)>0?r=n:i=n+1}return i}const d=Math.sqrt(50),m=Math.sqrt(10),f=Math.sqrt(2);function _(t,e,n){const i=Math.abs(e-t)/Math.max(0,n);let r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10));const s=i/r;return s>=d?r*=10:s>=m?r*=5:s>=f&&(r*=2),e<t?-r:r}const p=1e-10,M=1e-10;function w(t,e){const n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:p,i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:M)*Math.max(t,e);return Math.abs(t-e)<=Math.max(n,i)}function b(t,e,n,i){return t>e&&!w(t,e,n,i)}function y(t,e,n,i){return t<e&&!w(t,e,n,i)}const x=t=>{let e=null,n=null;return function(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return e&&r.every(((t,n)=>t===e[n]))||(e=r,n=t(...r)),n}},v=function(t){let e="",n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)-1;for(;n>=0;)e=`${e}${t}`,n-=1;return e},k=function(t,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"right";const i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:" ",r=t+"",s=e-r.length;return s<=0?r:"left"===n?v(i,s)+r:"center"===n?v(i,Math.floor(s/2))+r+v(i,Math.ceil(s/2)):r+v(i,s)};function T(t,e){let n;return t>e&&(n=t,t=e,e=n),n=>Math.max(t,Math.min(e,n))}let S=!1;try{S="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){S=!1}function D(t,e){return n=>t*(1-n)+e*n}function N(t,e){return function(n){return Math.round(t*(1-n)+e*n)}}S=!1;const C=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;function U(t){if(t instanceof Date)return t;if(r(t)){const e=C.exec(t);if(!e)return new Date(NaN);if(!e[8])return new Date(+e[1],+(e[2]||1)-1,+e[3]||1,+e[4]||0,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0);let n=+e[4]||0;return"Z"!==e[8].toUpperCase()&&(n-=+e[8].slice(0,3)),new Date(Date.UTC(+e[1],+(e[2]||1)-1,+e[3]||1,n,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0))}return n(t)?new Date(NaN):new Date(Math.round(t))}function F(t,e,n){e/=100,n/=100;const i=(1-Math.abs(2*n-1))*e,r=i*(1-Math.abs(t/60%2-1)),s=n-i/2;let o=0,a=0,h=0;return 0<=t&&t<60?(o=i,a=r,h=0):60<=t&&t<120?(o=r,a=i,h=0):120<=t&&t<180?(o=0,a=i,h=r):180<=t&&t<240?(o=0,a=r,h=i):240<=t&&t<300?(o=r,a=0,h=i):300<=t&&t<360&&(o=i,a=0,h=r),o=Math.round(255*(o+s)),a=Math.round(255*(a+s)),h=Math.round(255*(h+s)),{r:o,g:a,b:h}}function A(t,e,n){t/=255,e/=255,n/=255;const i=Math.min(t,e,n),r=Math.max(t,e,n),s=r-i;let o=0,a=0,h=0;return o=0===s?0:r===t?(e-n)/s%6:r===e?(n-t)/s+2:(t-e)/s+4,o=Math.round(60*o),o<0&&(o+=360),h=(r+i)/2,a=0===s?0:s/(1-Math.abs(2*h-1)),a=+(100*a).toFixed(1),h=+(100*h).toFixed(1),{h:o,s:a,l:h}}const E=/^#([0-9a-f]{3,8})$/,O={transparent:4294967040},H={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function R(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function I(t){return o(t)?new Y(t>>16,t>>8&255,255&t,1):s(t)?new Y(t[0],t[1],t[2]):new Y(255,255,255)}class L{static Brighter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new L(t).brighter(e).toRGBA()}static SetOpacity(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new L(t).setOpacity(e).toRGBA()}static getColorBrightness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hsl";const n=t instanceof L?t:new L(t);switch(e){case"hsv":default:return n.getHSVBrightness();case"hsl":return n.getHSLBrightness();case"lum":return n.getLuminance();case"lum2":return n.getLuminance2();case"lum3":return n.getLuminance3()}}static parseColorString(t){if(i(O[t]))return function(t){return o(t)?new Y(t>>>24,t>>>16&255,t>>>8&255,255&t):s(t)?new Y(t[0],t[1],t[2],t[3]):new Y(255,255,255,1)}(O[t]);if(i(H[t]))return I(H[t]);const e=`${t}`.trim().toLowerCase(),n=E.exec(e);if(n){const t=parseInt(n[1],16),e=n[1].length;return 3===e?new Y((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?I(t):8===e?new Y(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):void 0}if(/^(rgb|RGB|rgba|RGBA)/.test(e)){const t=e.replace(/(?:\(|\)|rgba|RGBA|rgb|RGB)*/g,"").split(",");return new Y(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3]))}if(/^(hsl|HSL|hsla|HSLA)/.test(e)){const t=e.replace(/(?:\(|\)|hsla|HSLA|hsl|HSL)*/g,"").split(","),n=F(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new Y(n.r,n.g,n.b,parseFloat(t[3]))}}constructor(t){const e=L.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new Y(255,255,255))}toRGBA(){return this.color.formatRgb()}toString(){return this.color.formatRgb()}toHex(){return this.color.formatHex()}toHsl(){return this.color.formatHsl()}setOpacity(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.color.opacity=t,this}brighter(t){const{r:e,g:n,b:i}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t))),this.color.g=Math.max(0,Math.min(255,Math.floor(n*t))),this.color.b=Math.max(0,Math.min(255,Math.floor(i*t))),this}getHSVBrightness(){return Math.max(this.color.r,this.color.g,this.color.b)/255}getHSLBrightness(){return.5*(Math.max(this.color.r,this.color.g,this.color.b)/255+Math.min(this.color.r,this.color.g,this.color.b)/255)}setHsl(t,e,i){const r=this.color.opacity,s=A(this.color.r,this.color.g,this.color.b),o=F(n(t)?s.h:(l=360,(a=t)<(h=0)?h:a>l?l:a),n(e)?s.s:e>=0&&e<=1?100*e:e,n(i)?s.l:i<=1&&i>=0?100*i:i);var a,h,l;return this.color=new Y(o.r,o.g,o.b,r),this}getLuminance(){return(.2126*this.color.r+.7152*this.color.g+.0722*this.color.b)/255}getLuminance2(){return(.2627*this.color.r+.678*this.color.g+.0593*this.color.b)/255}getLuminance3(){return(.299*this.color.r+.587*this.color.g+.114*this.color.b)/255}}class Y{constructor(t,e,n,r){this.r=isNaN(+t)?255:Math.max(0,Math.min(255,+t)),this.g=isNaN(+e)?255:Math.max(0,Math.min(255,+e)),this.b=isNaN(+n)?255:Math.max(0,Math.min(255,+n)),i(r)?this.opacity=isNaN(+r)?1:Math.max(0,Math.min(1,+r)):this.opacity=1}formatHex(){return`#${R(this.r)+R(this.g)+R(this.b)+(1===this.opacity?"":R(255*this.opacity))}`}formatRgb(){const t=this.opacity;return`${1===t?"rgb(":"rgba("}${this.r},${this.g},${this.b}${1===t?")":`,${t})`}`}formatHsl(){const t=this.opacity,{h:e,s:n,l:i}=A(this.r,this.g,this.b);return`${1===t?"hsl(":"hsla("}${e},${n}%,${i}%${1===t?")":`,${t})`}`}toString(){return this.formatHex()}}var V,q,B=Object.freeze({__proto__:null,Color:L,DEFAULT_COLORS:H,RGB:Y,hexToRgb:function(t){let e="",n="",i="";const r="#"===t[0]?1:0;for(let s=r;s<t.length;s++)"#"!==t[s]&&(s<r+2?e+=t[s]:s<r+4?n+=t[s]:s<r+6&&(i+=t[s]));return[parseInt(e,16),parseInt(n,16),parseInt(i,16)]},hslToRgb:F,interpolateRgb:function(t,e){const n=t.r,i=e.r,r=t.g,s=e.g,o=t.b,a=e.b,h=t.opacity,l=e.opacity;return t=>{const e=Math.round(n*(1-t)+i*t),c=Math.round(r*(1-t)+s*t),u=Math.round(o*(1-t)+a*t);return new Y(e,c,u,h*(1-t)+l*t)}},rgbToHex:function(t,e,n){return Number((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)},rgbToHsl:A});function $(t){return t?"getUTCFullYear":"getFullYear"}function P(t){return t?"getUTCMonth":"getMonth"}function j(t){return t?"getUTCDate":"getDate"}function z(t){return t?"getUTCHours":"getHours"}function Q(t){return t?"getUTCMinutes":"getMinutes"}function G(t){return t?"getUTCSeconds":"getSeconds"}function X(t){return t?"getUTCMilliseconds":"getMilliseconds"}function W(t){return t?"setUTCFullYear":"setFullYear"}function Z(t,e){return n=>{const i=U(n),r=i[$(e)](),s=i[P(e)]()+1,o=Math.floor((s-1)/3)+1,a=i[j(e)](),h=i["get"+(e?"UTC":"")+"Day"](),l=i[z(e)](),c=(l-1)%12+1,u=i[Q(e)](),g=i[G(e)](),d=i[X(e)]();return(t||"").replace(/YYYY/g,k(r+"",4,"0","left")).replace(/yyyy/g,r+"").replace(/yy/g,r%100+"").replace(/Q/g,o+"").replace(/MM/g,k(s,2,"0","left")).replace(/M/g,s+"").replace(/dd/g,k(a,2,"0","left")).replace(/d/g,a+"").replace(/e/g,h+"").replace(/HH/g,k(l,2,"0","left")).replace(/H/g,l+"").replace(/hh/g,k(c+"",2,"0","left")).replace(/h/g,c+"").replace(/mm/g,k(u,2,"0","left")).replace(/m/g,u+"").replace(/ss/g,k(g,2,"0","left")).replace(/s/g,g+"").replace(/SSS/g,k(d,3,"0","left")).replace(/S/g,d+"")}}!function(t){t[t.NONE=0]="NONE",t[t.BBOX1=1]="BBOX1",t[t.BBOX2=2]="BBOX2"}(V||(V={})),function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Info=3]="Info",t[t.Debug=4]="Debug"}(q||(q={}));const J=1e3,K=6e4,tt=36e5,et=24*tt,nt=31*et,it=365*et,rt=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),st=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),ot=(t,e)=>e.getFullYear()-t.getFullYear(),at=t=>t.getFullYear(),ht=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),lt=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),ct=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),ut=t=>t.getUTCFullYear(),gt=t=>(t.setDate(1),t.setHours(0,0,0,0),t),dt=(t,e)=>(t.setMonth(t.getMonth()+e),t),mt=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),ft=t=>t.getMonth(),_t=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),pt=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),Mt=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),wt=t=>t.getUTCMonth(),bt=t=>(t.setHours(0,0,0,0),t),yt=(t,e)=>(t.setDate(t.getDate()+e),t),xt=(t,e)=>(+e-+t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/et,vt=t=>t.getDate()-1,kt=t=>(t.setUTCHours(0,0,0,0),t),Tt=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),St=(t,e)=>(+e-+t)/et,Dt=t=>t.getUTCDate()-1,Nt=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes()),t),Ct=(t,e)=>(t.setHours(t.getHours()+e),t),Ut=(t,e)=>(+e-+t)/tt,Ft=t=>t.getHours(),At=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()-6e4*t.getUTCMinutes()),t),Et=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),Ot=t=>t.getUTCHours(),Ht=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()),t),Rt=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),It=(t,e)=>(+e-+t)/6e4,Lt=t=>t.getMinutes(),Yt=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()),t),Vt=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),qt=t=>t.getUTCMinutes(),Bt=t=>(t.setTime(+t-t.getMilliseconds()),t),$t=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),Pt=(t,e)=>(+e-+t)/1e3,jt=t=>t.getSeconds(),zt=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),Qt=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),Gt=t=>t.getUTCSeconds(),Xt=t=>t,Wt=(t,e)=>(t.setTime(+t+e),t),Zt=(t,e)=>+e-+t,Jt=(t,e)=>n=>{const i=new Date(+n-1);return e(i,1),t(i),i},Kt=(t,e)=>{let{floor:n,offset:i,field:r,count:s}=e;const o=Math.floor(t);if(!Number.isFinite(o)||o<=0)return null;if(o<=1)return{floor:n,offset:i,ceil:Jt(n,i)};const a=((t,e)=>(n,i)=>{const r=new Date,s=new Date;return r.setTime(+n),s.setTime(+i),t(r),t(s),Math.floor(e(r,s))})(n,s),h=r?t=>r(t)%o==0:t=>a(0,t)%o==0,l=t=>{if(!Number.isNaN(+t))for(n(t);!h(t);)t.setTime(+t-1),n(t);return t},c=(t,e)=>{if(!Number.isNaN(+t))if(o<0)for(;++e<=0;)for(i(t,-1);!h(t);)i(t,-1);else for(;--e>=0;)for(i(t,1);!h(t);)i(t,1);return t};return{floor:l,offset:c,ceil:Jt(l,c)}};var te;t.ScaleEnum=void 0,(te=t.ScaleEnum||(t.ScaleEnum={})).Linear="linear",te.Log="log",te.Pow="pow",te.Sqrt="sqrt",te.Symlog="symlog",te.Time="time",te.Quantile="quantile",te.Quantize="quantize",te.Threshold="threshold",te.Ordinal="ordinal",te.Point="point",te.Band="band";class ee{_wholeRange;_rangeFactor;_unknown;_calculateRange(t){if(this._wholeRange)return this._wholeRange;if(this._rangeFactor&&2===t.length){const e=(t[1]-t[0])/(this._rangeFactor[1]-this._rangeFactor[0]),n=t[0]-e*this._rangeFactor[0],i=n,r=e+n;return this._wholeRange=[i,r],this._wholeRange}return t}rangeFactor(t,e){return t?(2===t.length&&t.every((t=>t>=0&&t<=1))&&(this._wholeRange=null,this._rangeFactor=t),this):this._rangeFactor}unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}}const ne=Symbol("implicit");class ie extends ee{type=t.ScaleEnum.Ordinal;_index;_domain;_ordinalRange;_specified;specified(t){return t?(this._specified=Object.assign(this._specified??{},t),this):Object.assign({},this._specified)}_getSpecifiedValue(t){if(this._specified)return this._specified[t]}constructor(){super(),this._index=new Map,this._domain=[],this._ordinalRange=[],this._unknown=ne}clone(){return(new ie).domain(this._domain).range(this._ordinalRange).unknown(this._unknown)}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this._domain}scale(t){const e=`${t}`,n=this._getSpecifiedValue(e);if(void 0!==n)return n;let i=this._index.get(e);if(!i){if(this._unknown!==ne)return this._unknown;i=this._domain.push(t),this._index.set(e,i)}return this._ordinalRange[(i-1)%this._ordinalRange.length]}invert(t){let e=0;for(;e<this._ordinalRange.length&&this._ordinalRange[e]!==t;)e++;return this._domain[(e-1)%this._domain.length]}domain(t){if(!t)return this._domain.slice();this._domain=[],this._index=new Map;for(const e of t){const t=`${e}`;this._index.has(t)||this._index.set(t,this._domain.push(e))}return this}range(t){if(!t)return this._ordinalRange.slice();const e=Array.from(t);return this._ordinalRange=e,this}}function re(t){return t}const se=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t),oe=t=>t<0?-Math.sqrt(-t):Math.sqrt(t),ae=t=>t<0?-t*t:t*t,he=t=>-Math.log(-t),le=t=>-Math.exp(-t),ce=t=>isFinite(t)?Math.pow(10,t):t<0?0:t,ue=t=>10===t?ce:t===Math.E?Math.exp:e=>Math.pow(t,e),ge=t=>t===Math.E?Math.log:10===t?Math.log10:2===t?Math.log2:(t=Math.log(t),e=>Math.log(e)/t),de=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),me=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t;function fe(t,e){if(t=Number(t),e=Number(e),e-=t)return n=>(n-t)/e;const n=Number.isNaN(e)?NaN:.5;return()=>n}function _e(t,e,n){const i=t[0],r=t[1],s=e[0],o=e[1];let a,h;return r<i?(a=fe(r,i),h=n(o,s)):(a=fe(i,r),h=n(s,o)),t=>h(a(t))}function pe(t,e,n){const i=Math.min(t.length,e.length)-1,r=new Array(i),s=new Array(i);let o=-1;for(t[i]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<i;)r[o]=fe(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(e){const n=g(t,e,1,i)-1;return s[n](r[n](e))}}const Me=(t,e)=>{const n=t.slice();let i=0,r=n.length-1,s=n[i],o=n[r];return o<s&&([i,r]=[r,i],[s,o]=[o,s]),n[i]=e.floor(s),n[r]=e.ceil(o),n};function we(t,e,n,i){let r;const s=[];let o;if(e=Math.floor(+e),t=Math.floor(+t),!(n=Math.floor(+n)))return[];if(t===e)return[t];if(r=e<t){const n=t;t=e,e=n}let a=T(1,e-t+1)(n);if(o=Math.floor((e-t+1)/a),!i)for(;Math.ceil((e-t+1)/o)>n&&a>1;)a-=1,o=Math.floor((e-t)/a);let h=t;for(;h<=e;)s.push(h),h+=o;return r&&s.reverse(),s}class be extends ie{type=t.ScaleEnum.Band;_step;_bandwidth;_round;_paddingInner;_paddingOuter;_align;_range;constructor(t){super(),this._range=[0,1],this._step=void 0,this._bandwidth=void 0,this._round=!1,this._paddingInner=0,this._paddingOuter=0,this._align=.5,this._unknown=void 0,delete this.unknown,this.rescale(t)}rescale(t){if(t)return this;this._wholeRange=null;const e=this._calculateRange(this._range),n=super.domain().length,i=e[1]<e[0];let r=e[Number(i)-0];const s=e[1-Number(i)],o=function(t,e,n){let i;return i=1===t?t+2*n:t-e+2*n,t?i>0?i:1:0}(n,this._paddingInner,this._paddingOuter);this._step=(s-r)/Math.max(1,o||1),this._round&&(this._step=Math.floor(this._step)),r+=(s-r-this._step*(n-this._paddingInner))*this._align,this._bandwidth=this._step*(1-this._paddingInner),this._round&&(r=Math.round(r),this._bandwidth=Math.round(this._bandwidth));const a=h(n).map((t=>r+this._step*t));return super.range(i?a.reverse():a),this}calculateVisibleDomain(t){const e=this._domain;if(this._rangeFactor&&e.length){const n=this._getInvertIndex(t[0]),i=this._getInvertIndex(t[1]);return e.slice(Math.min(n,i),Math.max(n,i)+1)}return e}domain(t,e){return t?(super.domain(t),this.rescale(e)):super.domain()}range(t,e){return t?(this._range=[c(t[0]),c(t[1])],this.rescale(e)):this._range.slice()}rangeRound(t,e){return this._range=[c(t[0]),c(t[1])],this._round=!0,this.rescale(e)}ticks(t=10){const e=this.calculateVisibleDomain(this._range);if(-1===t)return e.slice();return we(0,e.length-1,t,!1).map((t=>e[t]))}tickData(t=10){return this.ticks(t).map(((t,e)=>({index:e,tick:t,value:(this.scale(t)-this._range[0]+this._bandwidth/2)/(this._range[1]-this._range[0])})))}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return we(0,e.length-1,t,!0).filter((t=>t<e.length)).map((t=>e[t]))}stepTicks(t){const e=this.calculateVisibleDomain(this._range),n=function(t,e,n){const i=[];let r;if(n=T(1,(e=Math.floor(+e))-(t=Math.floor(+t))+1)(Math.floor(+n)),r=e<t){const n=t;t=e,e=n}let s=t;for(;s<=e;)i.push(s),s+=n;return r&&i.reverse(),i}(0,e.length-1,t);return n.map((t=>e[t]))}_getInvertIndex(t){let e=0;const n=this.step()/2,i=this.bandwidth()/2,r=this._domain.length,s=this.range(),o=s[0]>s[s.length-1];for(e=0;e<r;e++){const s=this.scale(this._domain[e])+i;if(0===e&&(!o&&!b(t,s+n)||o&&!y(t,s-n)))break;if(e===r-1)break;if(!y(t,s-n)&&!b(t,s+n))break}return e>=0&&e<=r-1?e:r-1}invert(t){return this._domain[this._getInvertIndex(t)]}padding(t,e){return void 0!==t?(this._paddingOuter=Math.max(0,Math.min(Array.isArray(t)?Math.min.apply(null,t):t)),this._paddingInner=this._paddingOuter,this.rescale(e)):this._paddingInner}paddingInner(t,e){return void 0!==t?(this._paddingInner=Math.max(0,Math.min(1,t)),this.rescale(e)):this._paddingInner}paddingOuter(t,e){return void 0!==t?(this._paddingOuter=Math.max(0,Math.min(1,t)),this.rescale(e)):this._paddingOuter}bandwidth(){return this._bandwidth}step(){return this._step}round(t,e){return void 0!==t?(this._round=t,this.rescale(e)):this._round}align(t,e){return void 0!==t?(this._align=Math.max(0,Math.min(1,t)),this.rescale(e)):this._align}rangeFactor(t,e){return t?(super.rangeFactor(t),this.rescale(e)):super.rangeFactor()}clone(){return new be(!0).domain(this._domain,!0).range(this._range,!0).round(this._round,!0).paddingInner(this._paddingInner,!0).paddingOuter(this._paddingOuter,!0).align(this._align)}}const{interpolateRgb:ye}=B;function xe(t,e){const i=typeof e;let r;if(n(e)||"boolean"===i)return()=>e;if("number"===i)return D(t,e);if("string"===i){if(r=L.parseColorString(e)){const e=ye(L.parseColorString(t),r);return t=>e(t).formatRgb()}return D(Number(t),Number(e))}return e instanceof Y?ye(t,e):e instanceof L?ye(t.color,e.color):e instanceof Date?function(t,e){const n=t.valueOf(),i=e.valueOf(),r=new Date;return t=>(r.setTime(n*(1-t)+i*t),r)}(t,e):D(Number(t),Number(e))}class ve extends ee{type;transformer;untransformer;_niceDomain;_niceType;_domain;_range;_unknown=void 0;_forceAlign;_output;_input;_interpolate;_piecewise;_domainValidator;_clamp;constructor(t=re,e=re){super(),this.transformer=t,this.untransformer=e,this._forceAlign=!0,this._domain=[0,1],this._range=[0,1],this._clamp=re,this._piecewise=_e,this._interpolate=xe}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this._niceDomain??this._domain}scale(t){return t=Number(t),Number.isNaN(t)||this._domainValidator&&!this._domainValidator(t)?this._unknown:(this._output||(this._output=this._piecewise((this._niceDomain??this._domain).map(this.transformer),this._calculateRange(this._range),this._interpolate)),this._output(this.transformer(this._clamp(t))))}invert(t){return this._input||(this._input=this._piecewise(this._calculateRange(this._range),(this._niceDomain??this._domain).map(this.transformer),D)),this._clamp(this.untransformer(this._input(t)))}domain(t,e){if(!t)return(this._niceDomain??this._domain).slice();this._domainValidator=null,this._niceType=null,this._niceDomain=null;const n=Array.from(t,c);return this._domain=n,this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return this._range=n,this.rescale(e)}rangeRound(t,e){const n=Array.from(t);return this._range=n,this._interpolate=N,this.rescale(e)}rescale(t){if(t)return this;const e=this._niceDomain??this._domain,n=e.length,i=this._range.length;let r=Math.min(n,i);if(n&&n<i&&this._forceAlign){const t=i-n+1,s=e[n-1],o=n>=2?(s-e[n-2])/t:0;for(let i=1;i<=t;i++)e[n-2+i]=s-o*(t-i);r=i}return void 0===this._clamp&&(this._clamp=T(e[0],e[r-1])),this._piecewise=r>2?pe:_e,this._output=this._input=null,this._wholeRange=null,this}clamp(t,e,n){return arguments.length?(this._clamp=e||(t?void 0:re),this.rescale(n)):this._clamp!==re}interpolate(t,e){return arguments.length?(this._interpolate=t,this.rescale(e)):this._interpolate}ticks(t=10){return[]}tickData(t=10){return(this.ticks(t)??[]).map(((t,e)=>({index:e,tick:t,value:(this.scale(t)-this._range[0])/(this._range[1]-this._range[0])})))}rangeFactor(t,e){return t?(super.rangeFactor(t),this._output=this._input=null,this):super.rangeFactor()}forceAlignDomainRange(t){return arguments.length?(this._forceAlign=t,this):this._forceAlign}}const ke=Math.sqrt(50),Te=Math.sqrt(10),Se=Math.sqrt(2),De=[1,2,5,10],Ne=(t,e,n)=>{let i=1,r=t;const s=Math.floor((e-1)/2),o=Math.abs(t);return t>=0&&t<=Number.MIN_VALUE?r=0:t<0&&t>=-Number.MIN_VALUE?r=-(e-1):!n&&o<1?i=Ae(o).step:(n||o>1)&&(r=Math.floor(t)-s*i),i>0?(t>0?r=Math.max(r,0):t<0&&(r=Math.min(r,-(e-1)*i)),h(0,e).map((t=>r+t*i))):t>0?Ue(0,-(e-1)/i,i):Ue((e-1)/i,0,i)},Ce=x(((t,e,n,i)=>{let r,s,o,a,h=-1;if(n=+n,(t=+t)===(e=+e))return[t];if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return[t];if((r=e<t)&&(s=t,t=e,e=s),a=Ee(t,e,n).step,!isFinite(a))return[];if(a>0){let n=Math.round(t/a),i=Math.round(e/a);for(n*a<t&&++n,i*a>e&&--i,o=new Array(s=i-n+1);++h<s;)o[h]=(n+h)*a}else if(a<0&&i?.noDecimals){a=1;const n=Math.ceil(t),i=Math.floor(e);if(!(n<=i))return[];for(o=new Array(s=i-n+1);++h<s;)o[h]=n+h}else{a=-a;let n=Math.round(t*a),i=Math.round(e*a);for(n/a<t&&++n,i/a>e&&--i,o=new Array(s=i-n+1);++h<s;)o[h]=(n+h)/a}return r&&o.reverse(),o})),Ue=(t,e,n)=>{let i,r,s=-1;if(n>0){let o=Math.floor(t/n),a=Math.ceil(e/n);for((o+1)*n<t&&++o,(a-1)*n>e&&--a,r=new Array(i=a-o+1);++s<i;)r[s]=(o+s)*n}else{n=-n;let o=Math.floor(t*n),a=Math.ceil(e*n);for((o+1)/n<t&&++o,(a-1)/n>e&&--a,r=new Array(i=a-o+1);++s<i;)r[s]=(o+s)/n}return r},Fe=x(((t,e,n,i)=>{let r,s,o;if(n=+n,(t=+t)===(e=+e))return Ne(t,n,i?.noDecimals);if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return Ne(t,n,i?.noDecimals);(r=e<t)&&(o=t,t=e,e=o);const a=Ee(t,e,n);let h=a.step;if(!isFinite(h))return[];if(h>0){let i=1;const{power:r,gap:o}=a,l=10===o?2*10**r:1*10**r;for(;i<=5&&(s=Ue(t,e,h),s.length>n+1)&&n>2;)h+=l,i+=1;n>2&&s.length<n-1&&(s=((t,e,n)=>{let i;const r=t[0],s=t[t.length-1],o=e-t.length;if(s<=0){const e=[];for(i=o;i>=1;i--)e.push(r-i*n);return e.concat(t)}if(r>=0){for(i=1;i<=o;i++)t.push(s+i*n);return t}let a=[];const h=[];for(i=1;i<=o;i++)i%2==0?a=[r-Math.floor(i/2)*n].concat(a):h.push(s+Math.ceil(i/2)*n);return a.concat(t).concat(h)})(s,n,h))}else i?.noDecimals&&h<0&&(h=1),s=Ue(t,e,h);return r&&s.reverse(),s})),Ae=t=>{const e=Math.floor(Math.log(t)/Math.LN10),n=t/10**e;let i=De[0];return n>=ke?i=De[3]:n>=Te?i=De[2]:n>=Se&&(i=De[1]),e>=0?{step:i*10**e,gap:i,power:e}:{step:-(10**-e)/i,gap:i,power:e}};function Ee(t,e,n){const i=(e-t)/Math.max(0,n);return Ae(i)}function Oe(t,e,n){let i;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if(n<=0||0===(i=function(t,e,n){const i=(e-t)/Math.max(1,n-1);return i}(t,e,n))||!isFinite(i))return[];const r=new Array(n);for(let e=0;e<n;e++)r[e]=t+e*i;return r}function He(t,e,n){let i,r,s=-1;if(n=+n,(r=(e=+e)<(t=+t))&&(i=t,t=e,e=i),!isFinite(n)||e-t<=n)return[t];const o=Math.floor((e-t)/n+1),a=new Array(o);for(;++s<o;)a[s]=t+s*n;return r&&a.reverse(),a}function Re(t,e=10){let n,i,r=0,s=t.length-1,o=t[r],a=t[s],h=10;for(a<o&&(i=o,o=a,a=i,i=r,r=s,s=i);h-- >0;){if(i=Ee(o,a,e).step,i===n)return t[r]=o,t[s]=a,t;if(i>0)o=Math.floor(o/i)*i,a=Math.ceil(a/i)*i;else{if(!(i<0))break;o=Math.ceil(o*i)/i,a=Math.floor(a*i)/i}n=i}}function Ie(t,e){const n=o(e.forceMin),i=o(e.forceMax);let r=null;const s=[];let a=null;const h=n&&i?t=>t>=e.forceMin&&t<=e.forceMax:n?t=>t>=e.forceMin:i?t=>t<=e.forceMax:null;return n?s[0]=e.forceMin:o(e.min)&&e.min<=Math.min(t[0],t[t.length-1])&&(s[0]=e.min),i?s[1]=e.forceMax:o(e.max)&&e.max>=Math.max(t[0],t[t.length-1])&&(s[1]=e.max),o(s[0])&&o(s[1])?(a=t.slice(),a[0]=s[0],a[a.length-1]=s[1]):r=o(s[0])||o(s[1])?o(s[0])?"max":"min":"all",{niceType:r,niceDomain:a,niceMinMax:s,domainValidator:h}}class Le extends ve{type=t.ScaleEnum.Linear;clone(){return(new Le).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}tickFormat(){return()=>{}}d3Ticks(t=10,e){const n=this.calculateVisibleDomain(this._range);return Ce(n[0],n[n.length-1],t,e)}ticks(t=10,e){if(this._rangeFactor&&(this._rangeFactor[0]>0||this._rangeFactor[1]<1)&&2===this._range.length||!this._niceType)return this.d3Ticks(t,e);const n=this._niceDomain??this._domain,i=this._domain,r=n[0],s=n[n.length-1];let o=Fe(i[0],i[i.length-1],t,e);if(!o.length)return o;if(o[0]!==r&&"max"===this._niceType||o[o.length-1]!==s&&"min"===this._niceType){const t=n.slice();"min"===this._niceType?t[0]=o[0]:t[t.length-1]=o[o.length-1],this._niceDomain=t,this.rescale();const e=Math.min(t[0],t[t.length-1]),i=Math.max(t[0],t[t.length-1]);o=o.filter((t=>t>=e&&t<=i))}else if("all"!==this._niceType||o[0]===r&&o[o.length-1]===s)this._domainValidator&&(o=o.filter(this._domainValidator));else{const t=n.slice();t[0]=o[0],t[t.length-1]=o[o.length-1],this._niceDomain=t,this.rescale()}return o}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return Oe(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return He(e[0],e[e.length-1],t)}nice(t=10,e){const n=this._domain;let i=[];if(e){const t=Ie(n,e);if(i=t.niceMinMax,this._domainValidator=t.domainValidator,this._niceType=t.niceType,t.niceDomain)return this._niceDomain=t.niceDomain,this.rescale(),this}else this._niceType="all";if(this._niceType){const e=Re(n.slice(),t);"min"===this._niceType?e[e.length-1]=i[1]??e[e.length-1]:"max"===this._niceType&&(e[0]=i[0]??e[0]),this._niceDomain=e,this.rescale()}return this}niceMin(t=10){this._niceType="min";const e=this._domain[this._domain.length-1],n=Re(this.domain(),t);return n&&(n[n.length-1]=e,this._niceDomain=n,this.rescale()),this}niceMax(t=10){this._niceType="max";const e=this._domain[0],n=Re(this._domain.slice(),t);return n&&(n[0]=e,this._niceDomain=n,this.rescale()),this}}function Ye(t){return e=>-t(-e)}class Ve extends ve{type=t.ScaleEnum.Log;_base;_logs;_pows;constructor(){super(ge(10),ue(10)),this._logs=this.transformer,this._pows=this.untransformer,this._domain=[1,10],this._base=10}clone(){return(new Ve).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).base(this._base)}rescale(t){if(t)return this;super.rescale();const e=ge(this._base),n=ue(this._base);return(this._niceDomain??this._domain)[0]<0?(this._logs=Ye(e),this._pows=Ye(n),this.transformer=he,this.untransformer=le):(this._logs=e,this._pows=n,this.transformer=e,this.untransformer=n),this}base(t,e){return arguments.length?(this._base=t,this.rescale(e)):this._base}tickFormat(){return re}d3Ticks(t=10){const e=this.domain();let n=e[0],i=e[e.length-1];const r=i<n;r&&([n,i]=[i,n]);let s,o,a=this._logs(n),h=this._logs(i),l=[];if(!(this._base%1)&&h-a<t){if(a=Math.floor(a),h=Math.ceil(h),n>0){for(;a<=h;++a)for(s=1;s<this._base;++s)if(o=a<0?s/this._pows(-a):s*this._pows(a),!(o<n)){if(o>i)break;l.push(o)}}else for(;a<=h;++a)for(s=this._base-1;s>=1;--s)if(o=a>0?s/this._pows(-a):s*this._pows(a),!(o<n)){if(o>i)break;l.push(o)}2*l.length<t&&(l=Fe(n,i,t))}else l=Fe(a,h,Math.min(h-a,t)).map(this._pows);return r?l.reverse():l}ticks(t=10){return this.d3Ticks(t)}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return Oe(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return He(e[0],e[e.length-1],t)}nice(t=10,e){const n=this._domain;let i=[],r=null;if(e){const t=Ie(n,e);if(i=t.niceMinMax,this._domainValidator=t.domainValidator,r=t.niceType,t.niceDomain)return this._niceDomain=t.niceDomain,this.rescale(),this}else r="all";if(r){const t=Me(n.slice(),{floor:t=>this._pows(Math.floor(this._logs(t))),ceil:t=>this._pows(Math.ceil(this._logs(t)))});return"min"===r?t[t.length-1]=i[1]??t[t.length-1]:"max"===r&&(t[0]=i[0]??t[0]),this._niceDomain=t,this.rescale(),this}return this}niceMin(){const t=this._domain[this._domain.length-1];this.nice();const e=this._domain.slice();return this._domain&&(e[e.length-1]=t,this.domain(e)),this}niceMax(){const t=this._domain[0];this.nice();const e=this._domain.slice();return this._domain&&(e[0]=t,this.domain(e)),this}}class qe extends Le{type=t.ScaleEnum.Pow;_exponent;constructor(){super(),this._exponent=1}clone(){return(new qe).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).exponent(this._exponent)}rescale(t){return t||(1===this._exponent?(this.transformer=re,this.untransformer=re):.5===this._exponent?(this.transformer=oe,this.untransformer=ae):(this.transformer=se(this._exponent),this.untransformer=se(1/this._exponent)),super.rescale()),this}exponent(t,e){return arguments.length?(this._exponent=t,this.rescale(e)):this._exponent}}function Be(t,e){return t.length===e.length&&t.every(((t,n)=>t===e[n]))}class $e{type=t.ScaleEnum.Quantile;_range=[];_domain=[];_thresholds=[];_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}rescale(t){if(t)return this;let e=0;const n=Math.max(1,this._range.length);for(this._thresholds=new Array(n-1);++e<n;)this._thresholds[e-1]=u(this._domain,e/n);return this}scale(t){return a(t)?this._range[g(this._thresholds,t)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return e<0?[NaN,NaN]:[e>0?this._thresholds[e-1]:this._domain[0],e<this._thresholds.length?this._thresholds[e]:this._domain[this._domain.length-1]]}quantiles(){return this._thresholds.slice()}domain(t,e){if(!t)return this._domain.slice();this._domain=[];for(const e of t)n(e)||Number.isNaN(+e)||this._domain.push(+e);return this._domain.sort(l),this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return Be(this._range,n)?this:(this._range=n,this.rescale(e))}clone(){return(new $e).domain(this._domain,!0).range(this._range).unknown(this._unknown)}}class Pe{type=t.ScaleEnum.Quantile;_range=[0,1];_domain=[.5];x0=0;x1=1;n=1;_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}rescale(t){if(t)return this;let e=-1;for(this._domain=new Array(this.n);++e<this.n;)this._domain[e]=((e+1)*this.x1-(e-this.n)*this.x0)/(this.n+1);return this}scale(t){return a(t)?this._range[g(this._domain,t,0,this.n)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return e<0?[NaN,NaN]:e<1?[this.x0,this._domain[0]]:e>=this.n?[this._domain[this.n-1],this.x1]:[this._domain[e-1],this._domain[e]]}thresholds(){return this._domain.slice()}domain(t,e){if(!t)return[this.x0,this.x1];const n=Array.from(t);return this.x0=+n[0],this.x1=+n[1],this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return Be(this._range,n)?this:(this.n=n.length-1,this._range=n,this.rescale(e))}clone(){return(new Pe).domain([this.x0,this.x1],!0).range(this._range).unknown(this._unknown)}ticks(t=10){const e=this.domain();return Fe(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.domain();return Oe(e[0],e[e.length-1],t)}stepTicks(t){const e=this.domain();return He(e[0],e[e.length-1],t)}nice(t=10){const e=Re(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=Re(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=Re(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}class je extends Le{type=t.ScaleEnum.Sqrt;constructor(){super(oe,ae)}clone(){return(new je).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}}class ze extends Le{type=t.ScaleEnum.Symlog;_const;constructor(){super(de(1),me(1)),this._const=1}clone(){return(new ze).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate,!0).constant(this._const)}constant(t,e){return arguments.length?(this._const=t,this.transformer=de(t),this.untransformer=me(t),this.rescale(e)):this._const}}class Qe{type=t.ScaleEnum.Threshold;_range=[0,1];_domain=[.5];n=1;_unknown;unknown(t){return arguments.length?(this._unknown=t,this):this._unknown}scale(t){return!n(t)&&a(+t)?this._range[g(this._domain,t,0,this.n)]:this._unknown}invertExtent(t){const e=this._range.indexOf(t);return[this._domain[e-1],this._domain[e]]}domain(t){return t?(this._domain=Array.from(t),this.n=Math.min(this._domain.length,this._range.length-1),this):this._domain.slice()}range(t){return t?(this._range=Array.from(t),this.n=Math.min(this._domain.length,this._range.length-1),this):this._range.slice()}clone(){return(new Qe).domain(this._domain).range(this._range).unknown(this._unknown)}}const Ge=[["second",1,J],["second",5,5e3],["second",10,1e4],["second",30,3e4],["minute",1,K],["minute",5,3e5],["minute",10,6e5],["minute",30,18e5],["hour",1,tt],["hour",3,3*tt],["hour",6,6*tt],["hour",12,12*tt],["day",1,et],["day",2,2*et],["day",7,7*et],["month",1,nt],["month",3,3*nt],["month",6,6*nt],["year",1,365*et]];function Xe(t){return+U(t)}function We(t,e,n,i){const r=(+e-+t)/n,s=g(Ge.map((t=>t[2])),r);if(s===Ge.length){const r=Math.max(_(+t/it,+e/it,n),1),s=t=>(t[W(i)](Math.floor(t[$(i)]()/r)*r),t[function(t){return t?"setUTCMonth":"setMonth"}(i)](0,1),t[function(t){return t?"setUTCHours":"setHours"}(i)](0,0,0,0),t),o=(t,e)=>(t[W(i)](t[$(i)]()+e*r),t);return{floor:s,offset:o,ceil:Jt(s,o)}}if(0===s){const i=Math.max(_(+t,+e,n),1),r=t=>(t.setTime(Math.floor(+t/i)*i),t),s=(t,e)=>(t.setTime(+t+e*i),t);return{floor:r,offset:s,ceil:Jt(r,s)}}const[o,a]=Ge[r/Ge[s-1][2]<Ge[s][2]/r?s-1:s],h=((t,e)=>"year"===t&&e?{floor:ht,offset:lt,count:ct,field:ut}:"month"===t&&e?{floor:_t,offset:pt,count:Mt,field:wt}:"day"===t&&e?{floor:kt,offset:Tt,count:St,field:Dt}:"hour"===t&&e?{floor:At,offset:Et,count:Ut,field:Ot}:"minute"===t&&e?{floor:Yt,offset:Vt,count:It,field:qt}:"second"===t&&e?{floor:zt,offset:Qt,count:Pt,field:Gt}:"year"===t?{floor:rt,offset:st,count:ot,field:at}:"month"===t?{floor:gt,offset:dt,count:mt,field:ft}:"day"===t?{floor:bt,offset:yt,count:xt,field:vt}:"hour"===t?{floor:Nt,offset:Ct,count:Ut,field:Ft}:"minute"===t?{floor:Ht,offset:Rt,count:It,field:Lt}:"second"===t?{floor:Bt,offset:$t,count:Pt,field:jt}:{floor:Xt,offset:Wt,count:Zt})(o,i);return Kt(a,h)}class Ze extends ve{type=t.ScaleEnum.Time;_isUtc;constructor(t=!1){super(),this._domain=t?[Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]:[+new Date(2e3,0,1),+new Date(2e3,0,2)],this._isUtc=t}invert(t){return new Date(super.invert(t))}domain(t,e){if(!t)return this._domain.map(U);const n=Array.from(t,Xe);return this._domain=n,this.rescale(e)}ticks(t){const e=this.domain();let i=e[0],r=e[e.length-1];const s=r<i;s&&([i,r]=[r,i]);let a=t;(o(t)||n(t))&&(a=We(i,r,n(t)?10:t,this._isUtc)),i=a.ceil(i);const h=[];let l=+i,c=0;for(;l<=+r&&c<100;)h.push(new Date(l)),l=+a.offset(new Date(l),1),c++;return s?h.reverse():h}tickFormat(t,e){return Z(null==e?function(t,e){const n=U(t),i=n[P(e)]()+1,r=n[j(e)](),s=n[z(e)](),o=n[Q(e)](),a=n[G(e)](),h=0===n[X(e)](),l=h&&0===a,c=l&&0===o,u=c&&0===s,g=u&&1===r;return g&&1===i?"YYYY":g?"YYYY-MM":u?"YYYY-MM-DD":c?"HH":l?"HH:mm":h?"HH:mm:ss":"HH:mm:ss SSS"}(this._domain[0],this._isUtc):e,this._isUtc)}clone(){return new Ze(this._isUtc).domain(this.domain(),!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}nice(t){const e=this.domain();let i=t;return(o(t)||n(t))&&(i=We(e[0],e[e.length-1],n(t)?10:t,this._isUtc)),i&&this.domain(Me(e,i)),this}utc(){return this._isUtc}}t.BandScale=be,t.ContinuousScale=ve,t.LinearScale=Le,t.LogScale=Ve,t.OrdinalScale=ie,t.PointScale=class extends be{type=t.ScaleEnum.Point;_padding=0;constructor(t){super(!1),this.paddingInner(1,t),this.padding=this.paddingOuter,this.paddingInner=void 0,this.paddingOuter=void 0}},t.PowScale=qe,t.QuantileScale=$e,t.QuantizeScale=Pe,t.SqrtScale=je,t.SymlogScale=ze,t.ThresholdScale=Qe,t.TimeScale=Ze,t.isContinuous=function(e){switch(e){case t.ScaleEnum.Linear:case t.ScaleEnum.Log:case t.ScaleEnum.Pow:case t.ScaleEnum.Sqrt:case t.ScaleEnum.Symlog:case t.ScaleEnum.Time:return!0;default:return!1}},t.isDiscrete=function(e){switch(e){case t.ScaleEnum.Ordinal:case t.ScaleEnum.Point:case t.ScaleEnum.Band:return!0;default:return!1}},t.isDiscretizing=function(e){switch(e){case t.ScaleEnum.Quantile:case t.ScaleEnum.Quantize:case t.ScaleEnum.Threshold:return!0;default:return!1}},t.isValidScaleType=function(e){switch(e){case t.ScaleEnum.Linear:case t.ScaleEnum.Log:case t.ScaleEnum.Pow:case t.ScaleEnum.Sqrt:case t.ScaleEnum.Symlog:case t.ScaleEnum.Time:case t.ScaleEnum.Ordinal:case t.ScaleEnum.Point:case t.ScaleEnum.Band:return!0;default:return!1}}}));
import { BaseScale } from './base-scale';
import type { BimapType, InterpolateType, PolymapType, TransformType, IContinuousScale, ContinuousScaleType, TickData } from './interface';
import type { BimapType, InterpolateType, PolymapType, TransformType, IContinuousScale, ContinuousScaleType, TickData, NiceType } from './interface';
export declare class ContinuousScale extends BaseScale implements IContinuousScale {

@@ -8,2 +8,3 @@ readonly type: ContinuousScaleType;

protected _niceDomain: number[];
protected _niceType?: NiceType;
protected _domain: number[];

@@ -17,2 +18,3 @@ protected _range: any[];

protected _piecewise: BimapType<any> | PolymapType<any>;
protected _domainValidator?: (val: number) => boolean;
_clamp?: (x: number) => number;

@@ -19,0 +21,0 @@ constructor(transformer?: TransformType, untransformer?: TransformType);

@@ -24,7 +24,8 @@ import { BaseScale } from "./base-scale";

var _a;
return x = Number(x), Number.isNaN(x) ? this._unknown : (this._output || (this._output = this._piecewise((null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), this._calculateRange(this._range), this._interpolate)),
return x = Number(x), Number.isNaN(x) || this._domainValidator && !this._domainValidator(x) ? this._unknown : (this._output || (this._output = this._piecewise((null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), this._calculateRange(this._range), this._interpolate)),
this._output(this.transformer(this._clamp(x))));
}
invert(y) {
return this._input || (this._input = this._piecewise(this._calculateRange(this._range), this._domain.map(this.transformer), interpolateNumber)),
var _a;
return this._input || (this._input = this._piecewise(this._calculateRange(this._range), (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this.transformer), interpolateNumber)),
this._clamp(this.untransformer(this._input(y)));

@@ -35,2 +36,3 @@ }

if (!_) return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).slice();
this._domainValidator = null, this._niceType = null, this._niceDomain = null;
const nextDomain = Array.from(_, toNumber);

@@ -37,0 +39,0 @@ return this._domain = nextDomain, this.rescale(slience);

@@ -111,1 +111,8 @@ import type { ScaleEnum } from './type';

}) => number[];
export interface NiceOptions {
forceMin?: number;
forceMax?: number;
min?: number;
max?: number;
}
export type NiceType = 'all' | 'min' | 'max';
import { ContinuousScale } from './continuous-scale';
import type { ContinuousScaleType } from './interface';
import type { ContinuousScaleType, NiceOptions } from './interface';
export declare class LinearScale extends ContinuousScale {
readonly type: ContinuousScaleType;
protected _needNiceMin?: boolean;
protected _needNiceMax?: boolean;
protected _needNice?: boolean;
clone(): LinearScale;
tickFormat(): () => void;
domain(): any[];
domain(_: any[], slience?: boolean): this;
d3Ticks(count?: number, options?: {

@@ -20,5 +15,5 @@ noDecimals?: boolean;

stepTicks(step: number): any[];
nice(count?: number): this;
nice(count?: number, option?: NiceOptions): this;
niceMin(count?: number): this;
niceMax(count?: number): this;
}
import { ScaleEnum } from "./type";
import { d3Ticks, forceTicks, niceLinear, stepTicks, ticks } from "./utils/tick-sample";
import { d3Ticks, forceTicks, niceLinear, parseNiceOptions, stepTicks, ticks } from "./utils/tick-sample";
import { ContinuousScale } from "./continuous-scale";
import { toNumber } from "@visactor/vutils";
export class LinearScale extends ContinuousScale {

@@ -19,9 +17,2 @@ constructor() {

}
domain(_, slience) {
var _a;
if (!_) return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).slice();
this._needNice = !1, this._needNiceMax = !1, this._needNiceMin = !1, this._niceDomain = null;
const nextDomain = Array.from(_, toNumber);
return this._domain = nextDomain, this.rescale(slience);
}
d3Ticks(count = 10, options) {

@@ -32,13 +23,17 @@ const d = this.calculateVisibleDomain(this._range);

ticks(count = 10, options) {
if (this._rangeFactor && (this._rangeFactor[0] > 0 || this._rangeFactor[1] < 1) && 2 === this._range.length || !this._needNice && !this._needNiceMin && !this._needNiceMax) return this.d3Ticks(count, options);
const domain = this._domain, start = domain[0], stop = domain[domain.length - 1];
let ticksResult = ticks(start, stop, count, options);
if (ticksResult.length && (ticksResult[0] !== start && (this._needNice || this._needNiceMin) || ticksResult[ticksResult.length - 1] !== stop && (this._needNice || this._needNiceMax))) {
const newNiceDomain = domain.slice();
if ((this._needNice || this._needNiceMin) && (newNiceDomain[0] = ticksResult[0]),
(this._needNice || this._needNiceMax) && (newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1]),
this._niceDomain = newNiceDomain, this.rescale(), !this._needNice) {
const min = Math.min(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]), max = Math.max(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]);
ticksResult = ticksResult.filter((entry => entry >= min && entry <= max));
}
var _a;
if (this._rangeFactor && (this._rangeFactor[0] > 0 || this._rangeFactor[1] < 1) && 2 === this._range.length || !this._niceType) return this.d3Ticks(count, options);
const curNiceDomain = null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain, originalDomain = this._domain, start = curNiceDomain[0], stop = curNiceDomain[curNiceDomain.length - 1];
let ticksResult = ticks(originalDomain[0], originalDomain[originalDomain.length - 1], count, options);
if (!ticksResult.length) return ticksResult;
if (ticksResult[0] !== start && "max" === this._niceType || ticksResult[ticksResult.length - 1] !== stop && "min" === this._niceType) {
const newNiceDomain = curNiceDomain.slice();
"min" === this._niceType ? newNiceDomain[0] = ticksResult[0] : newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1],
this._niceDomain = newNiceDomain, this.rescale();
const min = Math.min(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]), max = Math.max(newNiceDomain[0], newNiceDomain[newNiceDomain.length - 1]);
ticksResult = ticksResult.filter((entry => entry >= min && entry <= max));
} else if ("all" !== this._niceType || ticksResult[0] === start && ticksResult[ticksResult.length - 1] === stop) this._domainValidator && (ticksResult = ticksResult.filter(this._domainValidator)); else {
const newNiceDomain = curNiceDomain.slice();
newNiceDomain[0] = ticksResult[0], newNiceDomain[newNiceDomain.length - 1] = ticksResult[ticksResult.length - 1],
this._niceDomain = newNiceDomain, this.rescale();
}

@@ -55,9 +50,20 @@ return ticksResult;

}
nice(count = 10) {
this._needNice = !0;
const niceDomain = niceLinear(this.domain(), count);
return niceDomain && (this._niceDomain = niceDomain, this.rescale()), this;
nice(count = 10, option) {
var _a, _b;
const originalDomain = this._domain;
let niceMinMax = [];
if (option) {
const res = parseNiceOptions(originalDomain, option);
if (niceMinMax = res.niceMinMax, this._domainValidator = res.domainValidator, this._niceType = res.niceType,
res.niceDomain) return this._niceDomain = res.niceDomain, this.rescale(), this;
} else this._niceType = "all";
if (this._niceType) {
const niceDomain = niceLinear(originalDomain.slice(), count);
"min" === this._niceType ? niceDomain[niceDomain.length - 1] = null !== (_a = niceMinMax[1]) && void 0 !== _a ? _a : niceDomain[niceDomain.length - 1] : "max" === this._niceType && (niceDomain[0] = null !== (_b = niceMinMax[0]) && void 0 !== _b ? _b : niceDomain[0]),
this._niceDomain = niceDomain, this.rescale();
}
return this;
}
niceMin(count = 10) {
this._needNiceMin = !0;
this._niceType = "min";
const maxD = this._domain[this._domain.length - 1], niceDomain = niceLinear(this.domain(), count);

@@ -68,4 +74,4 @@ return niceDomain && (niceDomain[niceDomain.length - 1] = maxD, this._niceDomain = niceDomain,

niceMax(count = 10) {
this._needNiceMax = !0;
const minD = this._domain[0], niceDomain = niceLinear(this.domain(), count);
this._niceType = "max";
const minD = this._domain[0], niceDomain = niceLinear(this._domain.slice(), count);
return niceDomain && (niceDomain[0] = minD, this._niceDomain = niceDomain, this.rescale()),

@@ -72,0 +78,0 @@ this;

import { ContinuousScale } from './continuous-scale';
import { identity } from './utils/utils';
import type { ContinuousScaleType } from './interface';
import type { ContinuousScaleType, NiceOptions } from './interface';
export declare class LogScale extends ContinuousScale {

@@ -19,5 +19,5 @@ readonly type: ContinuousScaleType;

stepTicks(step: number): any[];
nice(): this;
nice(count?: number, option?: NiceOptions): this;
niceMin(): this;
niceMax(): this;
}

@@ -1,2 +0,2 @@

import { ticks, forceTicks, stepTicks } from "./utils/tick-sample";
import { ticks, forceTicks, stepTicks, parseNiceOptions } from "./utils/tick-sample";

@@ -9,4 +9,2 @@ import { ContinuousScale } from "./continuous-scale";

import { cloneDeep } from "@visactor/vutils";
function reflect(f) {

@@ -25,7 +23,8 @@ return x => -f(-x);

rescale(slience) {
var _a;
if (slience) return this;
super.rescale();
const logs = logp(this._base), pows = powp(this._base);
return this._domain[0] < 0 ? (this._logs = reflect(logs), this._pows = reflect(pows),
this.transformer = logNegative, this.untransformer = expNegative) : (this._logs = logs,
return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain)[0] < 0 ? (this._logs = reflect(logs),
this._pows = reflect(pows), this.transformer = logNegative, this.untransformer = expNegative) : (this._logs = logs,
this._pows = pows, this.transformer = logs, this.untransformer = pows), this;

@@ -72,7 +71,20 @@ }

}
nice() {
return this.domain(nice(this.domain(), {
floor: x => this._pows(Math.floor(this._logs(x))),
ceil: x => this._pows(Math.ceil(this._logs(x)))
}));
nice(count = 10, option) {
var _a, _b;
const originalDomain = this._domain;
let niceMinMax = [], niceType = null;
if (option) {
const res = parseNiceOptions(originalDomain, option);
if (niceMinMax = res.niceMinMax, this._domainValidator = res.domainValidator, niceType = res.niceType,
res.niceDomain) return this._niceDomain = res.niceDomain, this.rescale(), this;
} else niceType = "all";
if (niceType) {
const niceDomain = nice(originalDomain.slice(), {
floor: x => this._pows(Math.floor(this._logs(x))),
ceil: x => this._pows(Math.ceil(this._logs(x)))
});
return "min" === niceType ? niceDomain[niceDomain.length - 1] = null !== (_a = niceMinMax[1]) && void 0 !== _a ? _a : niceDomain[niceDomain.length - 1] : "max" === niceType && (niceDomain[0] = null !== (_b = niceMinMax[0]) && void 0 !== _b ? _b : niceDomain[0]),
this._niceDomain = niceDomain, this.rescale(), this;
}
return this;
}

@@ -82,3 +94,3 @@ niceMin() {

this.nice();
const niceDomain = cloneDeep(this._domain);
const niceDomain = this._domain.slice();
return this._domain && (niceDomain[niceDomain.length - 1] = maxD, this.domain(niceDomain)),

@@ -90,3 +102,3 @@ this;

this.nice();
const niceDomain = cloneDeep(this._domain);
const niceDomain = this._domain.slice();
return this._domain && (niceDomain[0] = minD, this.domain(niceDomain)), this;

@@ -93,0 +105,0 @@ }

@@ -1,2 +0,2 @@

import type { ContinuousTicksFunc } from '../interface';
import type { ContinuousTicksFunc, NiceOptions, NiceType } from '../interface';
export declare const calculateTicksOfSingleValue: (value: number, tickCount: number, noDecimals?: boolean) => any[];

@@ -15,1 +15,7 @@ export declare const d3Ticks: ContinuousTicksFunc;

export declare function niceLinear(d: number[], count?: number): number[];
export declare function parseNiceOptions(originalDomain: number[], option: NiceOptions): {
niceType: NiceType;
niceDomain: number[];
niceMinMax: number[];
domainValidator: (x: number) => boolean;
};

@@ -1,2 +0,2 @@

import { range, memoize } from "@visactor/vutils";
import { range, memoize, isNumber } from "@visactor/vutils";

@@ -77,5 +77,5 @@ const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2), niceNumbers = [ 1, 2, 5, 10 ];

const {power: power, gap: gap} = stepRes, delatStep = 10 === gap ? 2 * 10 ** power : 1 * 10 ** power;
for (;cur <= 5 && (ticks = calculateTicksByStep(start, stop, step), ticks.length > count) && count > 2; ) step += delatStep,
for (;cur <= 5 && (ticks = calculateTicksByStep(start, stop, step), ticks.length > count + 1) && count > 2; ) step += delatStep,
cur += 1;
ticks.length < count && (ticks = appendTicksToCount(ticks, count, step));
count > 2 && ticks.length < count - 1 && (ticks = appendTicksToCount(ticks, count, step));
} else (null == options ? void 0 : options.noDecimals) && step < 0 && (step = 1),

@@ -141,2 +141,20 @@ ticks = calculateTicksByStep(start, stop, step);

}
export function parseNiceOptions(originalDomain, option) {
const hasForceMin = isNumber(option.forceMin), hasForceMax = isNumber(option.forceMax);
let niceType = null;
const niceMinMax = [];
let niceDomain = null;
const domainValidator = hasForceMin && hasForceMax ? x => x >= option.forceMin && x <= option.forceMax : hasForceMin ? x => x >= option.forceMin : hasForceMax ? x => x <= option.forceMax : null;
return hasForceMin ? niceMinMax[0] = option.forceMin : isNumber(option.min) && option.min <= Math.min(originalDomain[0], originalDomain[originalDomain.length - 1]) && (niceMinMax[0] = option.min),
hasForceMax ? niceMinMax[1] = option.forceMax : isNumber(option.max) && option.max >= Math.max(originalDomain[0], originalDomain[originalDomain.length - 1]) && (niceMinMax[1] = option.max),
isNumber(niceMinMax[0]) && isNumber(niceMinMax[1]) ? (niceDomain = originalDomain.slice(),
niceDomain[0] = niceMinMax[0], niceDomain[niceDomain.length - 1] = niceMinMax[1]) : niceType = isNumber(niceMinMax[0]) || isNumber(niceMinMax[1]) ? isNumber(niceMinMax[0]) ? "max" : "min" : "all",
{
niceType: niceType,
niceDomain: niceDomain,
niceMinMax: niceMinMax,
domainValidator: domainValidator
};
}
//# sourceMappingURL=tick-sample.js.map
{
"name": "@visactor/vscale",
"version": "0.15.2",
"version": "0.15.3",
"description": "Scales for visual encoding, used in VGrammar, VTable",

@@ -27,3 +27,3 @@ "keywords": [

"dependencies": {
"@visactor/vutils": "0.15.2"
"@visactor/vutils": "0.15.3"
},

@@ -30,0 +30,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc