@visactor/vscale
Advanced tools
Comparing version 0.13.3 to 0.13.4
@@ -16,3 +16,7 @@ import { ContinuousScale } from './continuous-scale'; | ||
ticks(count?: number): any[]; | ||
forceTicks(count?: number): any[]; | ||
stepTicks(step: number): any[]; | ||
nice(): 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"); | ||
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"); | ||
@@ -59,2 +59,10 @@ function reflect(f) { | ||
} | ||
forceTicks(count = 10) { | ||
const d = this.calculateVisibleDomain(this._range); | ||
return (0, tick_sample_1.forceTicks)(d[0], d[d.length - 1], count); | ||
} | ||
stepTicks(step) { | ||
const d = this.calculateVisibleDomain(this._range); | ||
return (0, tick_sample_1.stepTicks)(d[0], d[d.length - 1], step); | ||
} | ||
nice() { | ||
@@ -66,2 +74,15 @@ return this.domain((0, utils_1.nice)(this.domain(), { | ||
} | ||
niceMin() { | ||
const maxD = this._domain[this._domain.length - 1]; | ||
this.nice(); | ||
const niceDomain = (0, vutils_1.cloneDeep)(this._domain); | ||
return this._domain && (niceDomain[niceDomain.length - 1] = maxD, this.domain(niceDomain)), | ||
this; | ||
} | ||
niceMax() { | ||
const minD = this._domain[0]; | ||
this.nice(); | ||
const niceDomain = (0, vutils_1.cloneDeep)(this._domain); | ||
return this._domain && (niceDomain[0] = minD, this.domain(niceDomain)), this; | ||
} | ||
} | ||
@@ -68,0 +89,0 @@ |
@@ -12,3 +12,3 @@ import type { DiscreteScaleType, IBaseScale } from './interface'; | ||
specified(_: Record<string, unknown>): this; | ||
protected _getSpecifiedValue(input: any): undefined | any; | ||
protected _getSpecifiedValue(input: string): undefined | any; | ||
constructor(); | ||
@@ -15,0 +15,0 @@ clone(): IBaseScale; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const vutils_1 = require("@visactor/vutils"), type_1 = require("./type"), base_scale_1 = require("./base-scale"); | ||
const type_1 = require("./type"), base_scale_1 = require("./base-scale"); | ||
@@ -29,5 +29,4 @@ exports.implicit = Symbol("implicit"); | ||
scale(d) { | ||
const special = this._getSpecifiedValue(d); | ||
if (!(0, vutils_1.isNil)(special)) return special; | ||
const key = `${d}`; | ||
const key = `${d}`, special = this._getSpecifiedValue(key); | ||
if (void 0 !== special) return special; | ||
let i = this._index.get(key); | ||
@@ -34,0 +33,0 @@ if (!i) { |
@@ -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,u=this._events[a],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,i),!0;case 5:return u.fn.call(u.context,e,r,i,s),!0;case 6:return u.fn.call(u.context,e,r,i,s,o),!0}for(l=1,h=new Array(c-1);l<c;l++)h[l-1]=arguments[l];u.fn.apply(u.context,h)}else{var g,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(t,u[l].fn,void 0,!0),c){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,e);break;case 3:u[l].fn.call(u[l].context,e,r);break;case 4:u[l].fn.call(u[l].context,e,r,i);break;default:if(!h)for(g=1,h=new Array(c-1);g<c;g++)h[g-1]=arguments[g];u[l].fn.apply(u[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=[],u=a.length;h<u;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,e){return t<e?-1:t>e?1:t>=e?0:NaN}function l(t){return Number(t)}function u(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l;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 c(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;h(t[n],e)>0?i=n:r=n+1}return r}const g=Math.sqrt(50),d=Math.sqrt(10),f=Math.sqrt(2);function m(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>=g?i*=10:s>=d?i*=5:s>=f&&(i*=2),e<t?-i:i}const _=1e-10,p=1e-10;function w(t,e){const n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:_,r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:p)*Math.max(t,e);return Math.abs(t-e)<=Math.max(n,r)}function M(t,e,n,r){return t>e&&!w(t,e,n,r)}function b(t,e,n,r){return t<e&&!w(t,e,n,r)}const y=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},v=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?y(r,s)+i:"center"===n?y(r,Math.floor(s/2))+i+y(r,Math.ceil(s/2)):i+y(r,s)};function x(t,e){let n;return t>e&&(n=t,t=e,e=n),n=>Math.max(t,Math.min(e,n))}let k=!1;try{k="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){k=!1}function S(t,e){return n=>t*(1-n)+e*n}function T(t,e){return function(n){return Math.round(t*(1-n)+e*n)}}k=!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 N(t){if(t instanceof Date)return t;if(i(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 U(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 F=/^#([0-9a-f]{3,8})$/,D={transparent:4294967040},A={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 O(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function H(t){return o(t)?new I(t>>16,t>>8&255,255&t,1):s(t)?new I(t[0],t[1],t[2]):new I(255,255,255)}class R{static Brighter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new R(t).brighter(e).toRGBA()}static SetOpacity(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new R(t).setOpacity(e).toRGBA()}static getColorBrightness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hsl";const n=t instanceof R?t:new R(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(D[t]))return function(t){return o(t)?new I(t>>>24,t>>>16&255,t>>>8&255,255&t):s(t)?new I(t[0],t[1],t[2],t[3]):new I(255,255,255,1)}(D[t]);if(r(A[t]))return H(A[t]);const e=`${t}`.trim().toLowerCase(),n=F.exec(e);if(n){const t=parseInt(n[1],16),e=n[1].length;return 3===e?new I((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?H(t):8===e?new I(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 I(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=U(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new I(n.r,n.g,n.b,parseFloat(t[3]))}}constructor(t){const e=R.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new I(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=U(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 I(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 I{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`#${O(this.r)+O(this.g)+O(this.b)+(1===this.opacity?"":O(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 L,Y,q=Object.freeze({__proto__:null,Color:R,DEFAULT_COLORS:A,RGB:I,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:U,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),u=Math.round(i*(1-t)+s*t),c=Math.round(o*(1-t)+a*t);return new I(e,u,c,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 B(t){return t?"getUTCFullYear":"getFullYear"}function $(t){return t?"getUTCMonth":"getMonth"}function V(t){return t?"getUTCDate":"getDate"}function P(t){return t?"getUTCHours":"getHours"}function j(t){return t?"getUTCMinutes":"getMinutes"}function z(t){return t?"getUTCSeconds":"getSeconds"}function Q(t){return t?"getUTCMilliseconds":"getMilliseconds"}function G(t){return t?"setUTCFullYear":"setFullYear"}function X(t,e){return n=>{const r=N(n),i=r[B(e)](),s=r[$(e)]()+1,o=Math.floor((s-1)/3)+1,a=r[V(e)](),h=r["get"+(e?"UTC":"")+"Day"](),l=r[P(e)](),u=(l-1)%12+1,c=r[j(e)](),g=r[z(e)](),d=r[Q(e)]();return(t||"").replace(/YYYY/g,v(i+"",4,"0","left")).replace(/yyyy/g,i+"").replace(/yy/g,i%100+"").replace(/Q/g,o+"").replace(/MM/g,v(s,2,"0","left")).replace(/M/g,s+"").replace(/dd/g,v(a,2,"0","left")).replace(/d/g,a+"").replace(/e/g,h+"").replace(/HH/g,v(l,2,"0","left")).replace(/H/g,l+"").replace(/hh/g,v(u+"",2,"0","left")).replace(/h/g,u+"").replace(/mm/g,v(c,2,"0","left")).replace(/m/g,c+"").replace(/ss/g,v(g,2,"0","left")).replace(/s/g,g+"").replace(/SSS/g,v(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"}(L||(L={})),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"}(Y||(Y={}));const W=1e3,Z=6e4,J=36e5,K=24*J,tt=31*K,et=365*K,nt=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),rt=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),it=(t,e)=>e.getFullYear()-t.getFullYear(),st=t=>t.getFullYear(),ot=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),at=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),ht=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),lt=t=>t.getUTCFullYear(),ut=t=>(t.setDate(1),t.setHours(0,0,0,0),t),ct=(t,e)=>(t.setMonth(t.getMonth()+e),t),gt=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),dt=t=>t.getMonth(),ft=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),mt=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),_t=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),pt=t=>t.getUTCMonth(),wt=t=>(t.setHours(0,0,0,0),t),Mt=(t,e)=>(t.setDate(t.getDate()+e),t),bt=(t,e)=>(+e-+t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/K,yt=t=>t.getDate()-1,vt=t=>(t.setUTCHours(0,0,0,0),t),xt=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),kt=(t,e)=>(+e-+t)/K,St=t=>t.getUTCDate()-1,Tt=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes()),t),Ct=(t,e)=>(t.setHours(t.getHours()+e),t),Nt=(t,e)=>(+e-+t)/J,Ut=t=>t.getHours(),Et=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()-6e4*t.getUTCMinutes()),t),Ft=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),Dt=t=>t.getUTCHours(),At=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()),t),Ot=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),Ht=(t,e)=>(+e-+t)/6e4,Rt=t=>t.getMinutes(),It=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()),t),Lt=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),Yt=t=>t.getUTCMinutes(),qt=t=>(t.setTime(+t-t.getMilliseconds()),t),Bt=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),$t=(t,e)=>(+e-+t)/1e3,Vt=t=>t.getSeconds(),Pt=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),jt=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),zt=t=>t.getUTCSeconds(),Qt=t=>t,Gt=(t,e)=>(t.setTime(+t+e),t),Xt=(t,e)=>+e-+t,Wt=(t,e)=>n=>{const r=new Date(+n-1);return e(r,1),t(r),r},Zt=(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:Wt(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},u=(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:u,ceil:Wt(l,u)}};var Jt;t.ScaleEnum=void 0,(Jt=t.ScaleEnum||(t.ScaleEnum={})).Linear="linear",Jt.Log="log",Jt.Pow="pow",Jt.Sqrt="sqrt",Jt.Symlog="symlog",Jt.Time="time",Jt.Quantile="quantile",Jt.Quantize="quantize",Jt.Threshold="threshold",Jt.Ordinal="ordinal",Jt.Point="point",Jt.Band="band";class Kt{_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}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this.domain()}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 te=Symbol("implicit");class ee extends Kt{type=t.ScaleEnum.Ordinal;_index;_domain;_ordinalRange;_specified;specified(t){return t?(this._specified=Object.assign(this._specified??{},t),this):{...this._specified}}_getSpecifiedValue(t){if(this._specified)return this._specified[t]}constructor(){super(),this._index=new Map,this._domain=[],this._ordinalRange=[],this._unknown=te}clone(){return(new ee).domain(this._domain).range(this._ordinalRange).unknown(this._unknown)}scale(t){const e=this._getSpecifiedValue(t);if(!n(e))return e;const r=`${t}`;let i=this._index.get(r);if(!i){if(this._unknown!==te)return this._unknown;i=this._domain.push(t),this._index.set(r,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 ne(t){return t}const re=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t),ie=t=>t<0?-Math.sqrt(-t):Math.sqrt(t),se=t=>t<0?-t*t:t*t,oe=t=>-Math.log(-t),ae=t=>-Math.exp(-t),he=t=>isFinite(t)?Math.pow(10,t):t<0?0:t,le=t=>10===t?he:t===Math.E?Math.exp:e=>Math.pow(t,e),ue=t=>t===Math.E?Math.log:10===t?Math.log10:2===t?Math.log2:(t=Math.log(t),e=>Math.log(e)/t),ce=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),ge=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t;function de(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 fe(t,e,n){const r=t[0],i=t[1],s=e[0],o=e[1];let a,h;return i<r?(a=de(i,r),h=n(o,s)):(a=de(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]=de(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(e){const n=c(t,e,1,r)-1;return s[n](i[n](e))}}const _e=(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 pe(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=x(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 we extends ee{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 s=e[Number(i)-0];const o=e[1-Number(i)],a=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=(o-s)/Math.max(1,a||1),this._round&&(this._step=Math.floor(this._step)),s+=(o-s-this._step*(n-this._paddingInner))*this._align,this._bandwidth=this._step*(1-this._paddingInner),this._round&&(s=Math.round(s),this._bandwidth=Math.round(this._bandwidth));const h=function(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}(n).map((t=>s+this._step*t));return super.range(i?h.reverse():h),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=[l(t[0]),l(t[1])],this.rescale(e)):this._range.slice()}rangeRound(t,e){return this._range=[l(t[0]),l(t[1])],this._round=!0,this.rescale(e)}ticks(t=10){const e=this.calculateVisibleDomain(this._range);if(-1===t)return e;return pe(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 pe(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=x(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&&!M(t,s+n)||o&&!b(t,s-n)))break;if(e===i-1)break;if(!b(t,s-n)&&!M(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 we(!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:Me}=q;function be(t,e){const r=typeof e;let i;if(n(e)||"boolean"===r)return()=>e;if("number"===r)return S(t,e);if("string"===r){if(i=R.parseColorString(e)){const e=Me(R.parseColorString(t),i);return t=>e(t).formatRgb()}return S(Number(t),Number(e))}return e instanceof I?Me(t,e):e instanceof R?Me(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):S(Number(t),Number(e))}class ye extends Kt{type;transformer;untransformer;_domain;_range;_unknown=void 0;_forceAlign;_output;_input;_interpolate;_piecewise;_clamp;constructor(t=ne,e=ne){super(),this.transformer=t,this.untransformer=e,this._forceAlign=!0,this._domain=[0,1],this._range=[0,1],this._clamp=ne,this._piecewise=fe,this._interpolate=be}scale(t){return t=Number(t),Number.isNaN(t)?this._unknown:(this._output||(this._output=this._piecewise(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),S)),this._clamp(this.untransformer(this._input(t)))}domain(t,e){if(!t)return this._domain.slice();const n=Array.from(t,l);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=T,this.rescale(e)}rescale(t){if(t)return this;const e=this._domain.length,n=this._range.length;let r=Math.min(e,n);if(e&&e<n&&this._forceAlign){const t=n-e+1,i=this._domain[e-1],s=e>=2?(i-this._domain[e-2])/t:0;for(let n=1;n<=t;n++)this._domain[e-2+n]=i-s*(t-n);r=n}return void 0===this._clamp&&(this._clamp=x(this._domain[0],this._domain[r-1])),this._piecewise=r>2?me:fe,this._output=this._input=null,this._wholeRange=null,this}clamp(t,e,n){return arguments.length?(this._clamp=e||(t?void 0:ne),this.rescale(n)):this._clamp!==ne}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 ve=Math.sqrt(50),xe=Math.sqrt(10),ke=Math.sqrt(2);function Se(t,e,n){let r,i,s,o,a=-1;if(n=+n,(t=+t)===(e=+e))return[];if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return[t];if((r=e<t)&&(i=t,t=e,e=i),o=Te(t,e,n),!isFinite(o))return[];if(o>0){let n=Math.round(t/o),r=Math.round(e/o);for(n*o<t&&++n,r*o>e&&--r,s=new Array(i=r-n+1);++a<i;)s[a]=(n+a)*o}else{o=-o;let n=Math.round(t*o),r=Math.round(e*o);for(n/o<t&&++n,r/o>e&&--r,s=new Array(i=r-n+1);++a<i;)s[a]=(n+a)/o}return r&&s.reverse(),s}function Te(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),s=r/10**i;let o=1;return s>=ve?o=10:s>=xe?o=5:s>=ke&&(o=2),i>=0?o*10**i:-(10**-i)/o}function Ce(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 Ne(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 Ue(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=Te(o,a,e),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 Ee extends ye{type=t.ScaleEnum.Linear;clone(){return(new Ee).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}tickFormat(){return()=>{}}ticks(t=10){const e=this.calculateVisibleDomain(this._range);return Se(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return Ce(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return Ne(e[0],e[e.length-1],t)}nice(t=10){const e=Ue(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=Ue(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=Ue(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}function Fe(t){return e=>-t(-e)}class De extends ye{type=t.ScaleEnum.Log;_base;_logs;_pows;constructor(){super(ue(10),le(10)),this._logs=this.transformer,this._pows=this.untransformer,this._domain=[1,10],this._base=10}clone(){return(new De).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=ue(this._base),n=le(this._base);return this._domain[0]<0?(this._logs=Fe(e),this._pows=Fe(n),this.transformer=oe,this.untransformer=ae):(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 ne}ticks(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=Se(n,r,t))}else l=Se(a,h,Math.min(h-a,t)).map(this._pows);return i?l.reverse():l}nice(){return this.domain(_e(this.domain(),{floor:t=>this._pows(Math.floor(this._logs(t))),ceil:t=>this._pows(Math.ceil(this._logs(t)))}))}}class Ae extends Ee{type=t.ScaleEnum.Pow;_exponent;constructor(){super(),this._exponent=1}clone(){return(new Ae).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=ne,this.untransformer=ne):.5===this._exponent?(this.transformer=ie,this.untransformer=se):(this.transformer=re(this._exponent),this.untransformer=re(1/this._exponent)),super.rescale()),this}exponent(t,e){return arguments.length?(this._exponent=t,this.rescale(e)):this._exponent}}function Oe(t,e){return t.length===e.length&&t.every(((t,n)=>t===e[n]))}class He{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[c(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(h),this.rescale(e)}range(t,e){if(!t)return this._range.slice();const n=Array.from(t);return Oe(this._range,n)?this:(this._range=n,this.rescale(e))}clone(){return(new He).domain(this._domain,!0).range(this._range).unknown(this._unknown)}}class Re{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[c(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 Oe(this._range,n)?this:(this.n=n.length-1,this._range=n,this.rescale(e))}clone(){return(new Re).domain([this.x0,this.x1],!0).range(this._range).unknown(this._unknown)}ticks(t=10){const e=this.domain();return Se(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.domain();return Ce(e[0],e[e.length-1],t)}stepTicks(t){const e=this.domain();return Ne(e[0],e[e.length-1],t)}nice(t=10){const e=Ue(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=Ue(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=Ue(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}class Ie extends Ee{type=t.ScaleEnum.Sqrt;constructor(){super(ie,se)}clone(){return(new Ie).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}}class Le extends Ee{type=t.ScaleEnum.Symlog;_const;constructor(){super(ce(1),ge(1)),this._const=1}clone(){return(new Le).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=ce(t),this.untransformer=ge(t),this.rescale(e)):this._const}}class Ye{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[c(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 Ye).domain(this._domain).range(this._range).unknown(this._unknown)}}const qe=[["second",1,W],["second",5,5e3],["second",10,1e4],["second",30,3e4],["minute",1,Z],["minute",5,3e5],["minute",10,6e5],["minute",30,18e5],["hour",1,J],["hour",3,3*J],["hour",6,6*J],["hour",12,12*J],["day",1,K],["day",2,2*K],["day",7,7*K],["month",1,tt],["month",3,3*tt],["month",6,6*tt],["year",1,365*K]];function Be(t){return+N(t)}function $e(t,e,n,r){const i=(+e-+t)/n,s=c(qe.map((t=>t[2])),i);if(s===qe.length){const i=Math.max(m(+t/et,+e/et,n),1),s=t=>(t[G(r)](Math.floor(t[B(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[G(r)](t[B(r)]()+e*i),t);return{floor:s,offset:o,ceil:Wt(s,o)}}if(0===s){const r=Math.max(m(+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:Wt(i,s)}}const[o,a]=qe[i/qe[s-1][2]<qe[s][2]/i?s-1:s],h=((t,e)=>"year"===t&&e?{floor:ot,offset:at,count:ht,field:lt}:"month"===t&&e?{floor:ft,offset:mt,count:_t,field:pt}:"day"===t&&e?{floor:vt,offset:xt,count:kt,field:St}:"hour"===t&&e?{floor:Et,offset:Ft,count:Nt,field:Dt}:"minute"===t&&e?{floor:It,offset:Lt,count:Ht,field:Yt}:"second"===t&&e?{floor:Pt,offset:jt,count:$t,field:zt}:"year"===t?{floor:nt,offset:rt,count:it,field:st}:"month"===t?{floor:ut,offset:ct,count:gt,field:dt}:"day"===t?{floor:wt,offset:Mt,count:bt,field:yt}:"hour"===t?{floor:Tt,offset:Ct,count:Nt,field:Ut}:"minute"===t?{floor:At,offset:Ot,count:Ht,field:Rt}:"second"===t?{floor:qt,offset:Bt,count:$t,field:Vt}:{floor:Qt,offset:Gt,count:Xt})(o,r);return Zt(a,h)}class Ve extends ye{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(N);const n=Array.from(t,Be);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=$e(r,i,n(t)?10:t,this._isUtc)),r=a.ceil(r);const h=[];let l=+r,u=0;for(;l<=+i&&u<100;)h.push(new Date(l)),l=+a.offset(new Date(l),1),u++;return s?h.reverse():h}tickFormat(t,e){return X(null==e?function(t,e){const n=N(t),r=n[$(e)]()+1,i=n[V(e)](),s=n[P(e)](),o=n[j(e)](),a=n[z(e)](),h=0===n[Q(e)](),l=h&&0===a,u=l&&0===o,c=u&&0===s,g=c&&1===i;return g&&1===r?"YYYY":g?"YYYY-MM":c?"YYYY-MM-DD":u?"HH":l?"HH:mm":h?"HH:mm:ss":"HH:mm:ss SSS"}(this._domain[0],this._isUtc):e,this._isUtc)}clone(){return new Ve(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=$e(e[0],e[e.length-1],n(t)?10:t,this._isUtc)),r&&this.domain(_e(e,r)),this}utc(){return this._isUtc}}t.BandScale=we,t.ContinuousScale=ye,t.LinearScale=Ee,t.LogScale=De,t.OrdinalScale=ee,t.PointScale=class extends we{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=Ae,t.QuantileScale=He,t.QuantizeScale=Re,t.SqrtScale=Ie,t.SymlogScale=Le,t.ThresholdScale=Ye,t.TimeScale=Ve,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 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,u=this._events[a],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,i),!0;case 5:return u.fn.call(u.context,e,r,i,s),!0;case 6:return u.fn.call(u.context,e,r,i,s,o),!0}for(l=1,h=new Array(c-1);l<c;l++)h[l-1]=arguments[l];u.fn.apply(u.context,h)}else{var g,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(t,u[l].fn,void 0,!0),c){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,e);break;case 3:u[l].fn.call(u[l].context,e,r);break;case 4:u[l].fn.call(u[l].context,e,r,i);break;default:if(!h)for(g=1,h=new Array(c-1);g<c;g++)h[g-1]=arguments[g];u[l].fn.apply(u[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=[],u=a.length;h<u;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 u=a?void 0:Object.keys(Object(t));let c=-1;if(n)for(;++c<(u||t).length;){const e=u?u[c]:c,r=t[e];n[e]=h(r)}return n}function l(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function u(t){return Number(t)}function c(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 g(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;l(t[n],e)>0?i=n:r=n+1}return r}const d=Math.sqrt(50),f=Math.sqrt(10),m=Math.sqrt(2);function _(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>=d?i*=10:s>=f?i*=5:s>=m&&(i*=2),e<t?-i:i}const p=1e-10,w=1e-10;function M(t,e){const n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:p,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 b(t,e,n,r){return t>e&&!M(t,e,n,r)}function y(t,e,n,r){return t<e&&!M(t,e,n,r)}const 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},x=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?v(r,s)+i:"center"===n?v(r,Math.floor(s/2))+i+v(r,Math.ceil(s/2)):i+v(r,s)};function k(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 T(t,e){return n=>t*(1-n)+e*n}function C(t,e){return function(n){return Math.round(t*(1-n)+e*n)}}S=!1;const N=/^(?:(\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(i(t)){const e=N.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 D(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 F=/^#([0-9a-f]{3,8})$/,O={transparent:4294967040},A={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 H(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function R(t){return o(t)?new L(t>>16,t>>8&255,255&t,1):s(t)?new L(t[0],t[1],t[2]):new L(255,255,255)}class I{static Brighter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new I(t).brighter(e).toRGBA()}static SetOpacity(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return 1===e?t:new I(t).setOpacity(e).toRGBA()}static getColorBrightness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hsl";const n=t instanceof I?t:new I(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(O[t]))return function(t){return o(t)?new L(t>>>24,t>>>16&255,t>>>8&255,255&t):s(t)?new L(t[0],t[1],t[2],t[3]):new L(255,255,255,1)}(O[t]);if(r(A[t]))return R(A[t]);const e=`${t}`.trim().toLowerCase(),n=F.exec(e);if(n){const t=parseInt(n[1],16),e=n[1].length;return 3===e?new L((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?R(t):8===e?new L(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 L(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=D(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new L(n.r,n.g,n.b,parseFloat(t[3]))}}constructor(t){const e=I.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new L(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=D(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 L(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 L{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`#${H(this.r)+H(this.g)+H(this.b)+(1===this.opacity?"":H(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 Y,B,q=Object.freeze({__proto__:null,Color:I,DEFAULT_COLORS:A,RGB:L,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:D,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),u=Math.round(i*(1-t)+s*t),c=Math.round(o*(1-t)+a*t);return new L(e,u,c,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 $(t){return t?"getUTCFullYear":"getFullYear"}function V(t){return t?"getUTCMonth":"getMonth"}function j(t){return t?"getUTCDate":"getDate"}function P(t){return t?"getUTCHours":"getHours"}function z(t){return t?"getUTCMinutes":"getMinutes"}function Q(t){return t?"getUTCSeconds":"getSeconds"}function G(t){return t?"getUTCMilliseconds":"getMilliseconds"}function X(t){return t?"setUTCFullYear":"setFullYear"}function W(t,e){return n=>{const r=U(n),i=r[$(e)](),s=r[V(e)]()+1,o=Math.floor((s-1)/3)+1,a=r[j(e)](),h=r["get"+(e?"UTC":"")+"Day"](),l=r[P(e)](),u=(l-1)%12+1,c=r[z(e)](),g=r[Q(e)](),d=r[G(e)]();return(t||"").replace(/YYYY/g,x(i+"",4,"0","left")).replace(/yyyy/g,i+"").replace(/yy/g,i%100+"").replace(/Q/g,o+"").replace(/MM/g,x(s,2,"0","left")).replace(/M/g,s+"").replace(/dd/g,x(a,2,"0","left")).replace(/d/g,a+"").replace(/e/g,h+"").replace(/HH/g,x(l,2,"0","left")).replace(/H/g,l+"").replace(/hh/g,x(u+"",2,"0","left")).replace(/h/g,u+"").replace(/mm/g,x(c,2,"0","left")).replace(/m/g,c+"").replace(/ss/g,x(g,2,"0","left")).replace(/s/g,g+"").replace(/SSS/g,x(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"}(Y||(Y={})),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"}(B||(B={}));const Z=1e3,J=6e4,K=36e5,tt=24*K,et=31*tt,nt=365*tt,rt=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),it=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),st=(t,e)=>e.getFullYear()-t.getFullYear(),ot=t=>t.getFullYear(),at=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),ht=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),lt=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),ut=t=>t.getUTCFullYear(),ct=t=>(t.setDate(1),t.setHours(0,0,0,0),t),gt=(t,e)=>(t.setMonth(t.getMonth()+e),t),dt=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),ft=t=>t.getMonth(),mt=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),_t=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),pt=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),wt=t=>t.getUTCMonth(),Mt=t=>(t.setHours(0,0,0,0),t),bt=(t,e)=>(t.setDate(t.getDate()+e),t),yt=(t,e)=>(+e-+t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/tt,vt=t=>t.getDate()-1,xt=t=>(t.setUTCHours(0,0,0,0),t),kt=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),St=(t,e)=>(+e-+t)/tt,Tt=t=>t.getUTCDate()-1,Ct=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes()),t),Nt=(t,e)=>(t.setHours(t.getHours()+e),t),Ut=(t,e)=>(+e-+t)/K,Dt=t=>t.getHours(),Et=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()-6e4*t.getUTCMinutes()),t),Ft=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),Ot=t=>t.getUTCHours(),At=t=>(t.setTime(+t-t.getMilliseconds()-1e3*t.getSeconds()),t),Ht=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),Rt=(t,e)=>(+e-+t)/6e4,It=t=>t.getMinutes(),Lt=t=>(t.setTime(+t-t.getUTCMilliseconds()-1e3*t.getUTCSeconds()),t),Yt=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),Bt=t=>t.getUTCMinutes(),qt=t=>(t.setTime(+t-t.getMilliseconds()),t),$t=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),Vt=(t,e)=>(+e-+t)/1e3,jt=t=>t.getSeconds(),Pt=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),zt=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),Qt=t=>t.getUTCSeconds(),Gt=t=>t,Xt=(t,e)=>(t.setTime(+t+e),t),Wt=(t,e)=>+e-+t,Zt=(t,e)=>n=>{const r=new Date(+n-1);return e(r,1),t(r),r},Jt=(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:Zt(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},u=(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:u,ceil:Zt(l,u)}};var Kt;t.ScaleEnum=void 0,(Kt=t.ScaleEnum||(t.ScaleEnum={})).Linear="linear",Kt.Log="log",Kt.Pow="pow",Kt.Sqrt="sqrt",Kt.Symlog="symlog",Kt.Time="time",Kt.Quantile="quantile",Kt.Quantize="quantize",Kt.Threshold="threshold",Kt.Ordinal="ordinal",Kt.Point="point",Kt.Band="band";class te{_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}calculateVisibleDomain(t){if(this._rangeFactor&&2===t.length){return[this.invert(t[0]),this.invert(t[1])]}return this.domain()}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 ee=Symbol("implicit");class ne extends te{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=ee}clone(){return(new ne).domain(this._domain).range(this._ordinalRange).unknown(this._unknown)}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!==ee)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 re(t){return t}const ie=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t),se=t=>t<0?-Math.sqrt(-t):Math.sqrt(t),oe=t=>t<0?-t*t:t*t,ae=t=>-Math.log(-t),he=t=>-Math.exp(-t),le=t=>isFinite(t)?Math.pow(10,t):t<0?0:t,ue=t=>10===t?le:t===Math.E?Math.exp:e=>Math.pow(t,e),ce=t=>t===Math.E?Math.log:10===t?Math.log10:2===t?Math.log2:(t=Math.log(t),e=>Math.log(e)/t),ge=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),de=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 me(t,e,n){const r=t[0],i=t[1],s=e[0],o=e[1];let a,h;return i<r?(a=fe(i,r),h=n(o,s)):(a=fe(r,i),h=n(s,o)),t=>h(a(t))}function _e(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]=fe(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(e){const n=g(t,e,1,r)-1;return s[n](i[n](e))}}const pe=(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 we(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=k(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 Me extends ne{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 s=e[Number(i)-0];const o=e[1-Number(i)],a=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=(o-s)/Math.max(1,a||1),this._round&&(this._step=Math.floor(this._step)),s+=(o-s-this._step*(n-this._paddingInner))*this._align,this._bandwidth=this._step*(1-this._paddingInner),this._round&&(s=Math.round(s),this._bandwidth=Math.round(this._bandwidth));const h=function(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}(n).map((t=>s+this._step*t));return super.range(i?h.reverse():h),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;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 r=[];let i;if(n=k(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&&!b(t,s+n)||o&&!y(t,s-n)))break;if(e===i-1)break;if(!y(t,s-n)&&!b(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 Me(!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:be}=q;function ye(t,e){const r=typeof e;let i;if(n(e)||"boolean"===r)return()=>e;if("number"===r)return T(t,e);if("string"===r){if(i=I.parseColorString(e)){const e=be(I.parseColorString(t),i);return t=>e(t).formatRgb()}return T(Number(t),Number(e))}return e instanceof L?be(t,e):e instanceof I?be(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):T(Number(t),Number(e))}class ve extends te{type;transformer;untransformer;_domain;_range;_unknown=void 0;_forceAlign;_output;_input;_interpolate;_piecewise;_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=me,this._interpolate=ye}scale(t){return t=Number(t),Number.isNaN(t)?this._unknown:(this._output||(this._output=this._piecewise(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),T)),this._clamp(this.untransformer(this._input(t)))}domain(t,e){if(!t)return 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._domain.length,n=this._range.length;let r=Math.min(e,n);if(e&&e<n&&this._forceAlign){const t=n-e+1,i=this._domain[e-1],s=e>=2?(i-this._domain[e-2])/t:0;for(let n=1;n<=t;n++)this._domain[e-2+n]=i-s*(t-n);r=n}return void 0===this._clamp&&(this._clamp=k(this._domain[0],this._domain[r-1])),this._piecewise=r>2?_e:me,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 xe=Math.sqrt(50),ke=Math.sqrt(10),Se=Math.sqrt(2);function Te(t,e,n){let r,i,s,o,a=-1;if(n=+n,(t=+t)===(e=+e))return[];if(Math.abs(t-e)<=Number.MIN_VALUE&&n>0)return[t];if((r=e<t)&&(i=t,t=e,e=i),o=Ce(t,e,n),!isFinite(o))return[];if(o>0){let n=Math.round(t/o),r=Math.round(e/o);for(n*o<t&&++n,r*o>e&&--r,s=new Array(i=r-n+1);++a<i;)s[a]=(n+a)*o}else{o=-o;let n=Math.round(t*o),r=Math.round(e*o);for(n/o<t&&++n,r/o>e&&--r,s=new Array(i=r-n+1);++a<i;)s[a]=(n+a)/o}return r&&s.reverse(),s}function Ce(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),s=r/10**i;let o=1;return s>=xe?o=10:s>=ke?o=5:s>=Se&&(o=2),i>=0?o*10**i:-(10**-i)/o}function Ne(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 Ue(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 De(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=Ce(o,a,e),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 Ee extends ve{type=t.ScaleEnum.Linear;clone(){return(new Ee).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}tickFormat(){return()=>{}}ticks(t=10){const e=this.calculateVisibleDomain(this._range);return Te(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return Ne(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return Ue(e[0],e[e.length-1],t)}nice(t=10){const e=De(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=De(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=De(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}function Fe(t){return e=>-t(-e)}class Oe extends ve{type=t.ScaleEnum.Log;_base;_logs;_pows;constructor(){super(ce(10),ue(10)),this._logs=this.transformer,this._pows=this.untransformer,this._domain=[1,10],this._base=10}clone(){return(new Oe).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=ce(this._base),n=ue(this._base);return this._domain[0]<0?(this._logs=Fe(e),this._pows=Fe(n),this.transformer=ae,this.untransformer=he):(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}ticks(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=Te(n,r,t))}else l=Te(a,h,Math.min(h-a,t)).map(this._pows);return i?l.reverse():l}forceTicks(t=10){const e=this.calculateVisibleDomain(this._range);return Ne(e[0],e[e.length-1],t)}stepTicks(t){const e=this.calculateVisibleDomain(this._range);return Ue(e[0],e[e.length-1],t)}nice(){return this.domain(pe(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 Ae extends Ee{type=t.ScaleEnum.Pow;_exponent;constructor(){super(),this._exponent=1}clone(){return(new Ae).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=se,this.untransformer=oe):(this.transformer=ie(this._exponent),this.untransformer=ie(1/this._exponent)),super.rescale()),this}exponent(t,e){return arguments.length?(this._exponent=t,this.rescale(e)):this._exponent}}function He(t,e){return t.length===e.length&&t.every(((t,n)=>t===e[n]))}class Re{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]=c(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 He(this._range,n)?this:(this._range=n,this.rescale(e))}clone(){return(new Re).domain(this._domain,!0).range(this._range).unknown(this._unknown)}}class Ie{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 He(this._range,n)?this:(this.n=n.length-1,this._range=n,this.rescale(e))}clone(){return(new Ie).domain([this.x0,this.x1],!0).range(this._range).unknown(this._unknown)}ticks(t=10){const e=this.domain();return Te(e[0],e[e.length-1],t)}forceTicks(t=10){const e=this.domain();return Ne(e[0],e[e.length-1],t)}stepTicks(t){const e=this.domain();return Ue(e[0],e[e.length-1],t)}nice(t=10){const e=De(this.domain(),t);return e?this.domain(e):this}niceMin(t=10){const e=this._domain[this._domain.length-1],n=De(this.domain(),t);return n&&(n[n.length-1]=e,this.domain(n)),this}niceMax(t=10){const e=this._domain[0],n=De(this.domain(),t);return n&&(n[0]=e,this.domain(n)),this}}class Le extends Ee{type=t.ScaleEnum.Sqrt;constructor(){super(se,oe)}clone(){return(new Le).domain(this._domain,!0).range(this._range,!0).unknown(this._unknown).clamp(this.clamp(),null,!0).interpolate(this._interpolate)}}class Ye extends Ee{type=t.ScaleEnum.Symlog;_const;constructor(){super(ge(1),de(1)),this._const=1}clone(){return(new Ye).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=ge(t),this.untransformer=de(t),this.rescale(e)):this._const}}class Be{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 Be).domain(this._domain).range(this._range).unknown(this._unknown)}}const qe=[["second",1,Z],["second",5,5e3],["second",10,1e4],["second",30,3e4],["minute",1,J],["minute",5,3e5],["minute",10,6e5],["minute",30,18e5],["hour",1,K],["hour",3,3*K],["hour",6,6*K],["hour",12,12*K],["day",1,tt],["day",2,2*tt],["day",7,7*tt],["month",1,et],["month",3,3*et],["month",6,6*et],["year",1,365*tt]];function $e(t){return+U(t)}function Ve(t,e,n,r){const i=(+e-+t)/n,s=g(qe.map((t=>t[2])),i);if(s===qe.length){const i=Math.max(_(+t/nt,+e/nt,n),1),s=t=>(t[X(r)](Math.floor(t[$(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[X(r)](t[$(r)]()+e*i),t);return{floor:s,offset:o,ceil:Zt(s,o)}}if(0===s){const r=Math.max(_(+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:Zt(i,s)}}const[o,a]=qe[i/qe[s-1][2]<qe[s][2]/i?s-1:s],h=((t,e)=>"year"===t&&e?{floor:at,offset:ht,count:lt,field:ut}:"month"===t&&e?{floor:mt,offset:_t,count:pt,field:wt}:"day"===t&&e?{floor:xt,offset:kt,count:St,field:Tt}:"hour"===t&&e?{floor:Et,offset:Ft,count:Ut,field:Ot}:"minute"===t&&e?{floor:Lt,offset:Yt,count:Rt,field:Bt}:"second"===t&&e?{floor:Pt,offset:zt,count:Vt,field:Qt}:"year"===t?{floor:rt,offset:it,count:st,field:ot}:"month"===t?{floor:ct,offset:gt,count:dt,field:ft}:"day"===t?{floor:Mt,offset:bt,count:yt,field:vt}:"hour"===t?{floor:Ct,offset:Nt,count:Ut,field:Dt}:"minute"===t?{floor:At,offset:Ht,count:Rt,field:It}:"second"===t?{floor:qt,offset:$t,count:Vt,field:jt}:{floor:Gt,offset:Xt,count:Wt})(o,r);return Jt(a,h)}class je 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,$e);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=Ve(r,i,n(t)?10:t,this._isUtc)),r=a.ceil(r);const h=[];let l=+r,u=0;for(;l<=+i&&u<100;)h.push(new Date(l)),l=+a.offset(new Date(l),1),u++;return s?h.reverse():h}tickFormat(t,e){return W(null==e?function(t,e){const n=U(t),r=n[V(e)]()+1,i=n[j(e)](),s=n[P(e)](),o=n[z(e)](),a=n[Q(e)](),h=0===n[G(e)](),l=h&&0===a,u=l&&0===o,c=u&&0===s,g=c&&1===i;return g&&1===r?"YYYY":g?"YYYY-MM":c?"YYYY-MM-DD":u?"HH":l?"HH:mm":h?"HH:mm:ss":"HH:mm:ss SSS"}(this._domain[0],this._isUtc):e,this._isUtc)}clone(){return new je(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=Ve(e[0],e[e.length-1],n(t)?10:t,this._isUtc)),r&&this.domain(pe(e,r)),this}utc(){return this._isUtc}}t.BandScale=Me,t.ContinuousScale=ve,t.LinearScale=Ee,t.LogScale=Oe,t.OrdinalScale=ne,t.PointScale=class extends Me{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=Ae,t.QuantileScale=Re,t.QuantizeScale=Ie,t.SqrtScale=Le,t.SymlogScale=Ye,t.ThresholdScale=Be,t.TimeScale=je,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}}})); |
@@ -16,3 +16,7 @@ import { ContinuousScale } from './continuous-scale'; | ||
ticks(count?: number): any[]; | ||
forceTicks(count?: number): any[]; | ||
stepTicks(step: number): any[]; | ||
nice(): this; | ||
niceMin(): this; | ||
niceMax(): this; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { ticks } from "./utils/tick-sample"; | ||
import { ticks, forceTicks, stepTicks } from "./utils/tick-sample"; | ||
@@ -9,2 +9,4 @@ import { ContinuousScale } from "./continuous-scale"; | ||
import { cloneDeep } from "@visactor/vutils"; | ||
function reflect(f) { | ||
@@ -58,2 +60,10 @@ return x => -f(-x); | ||
} | ||
forceTicks(count = 10) { | ||
const d = this.calculateVisibleDomain(this._range); | ||
return forceTicks(d[0], d[d.length - 1], count); | ||
} | ||
stepTicks(step) { | ||
const d = this.calculateVisibleDomain(this._range); | ||
return stepTicks(d[0], d[d.length - 1], step); | ||
} | ||
nice() { | ||
@@ -65,3 +75,16 @@ return this.domain(nice(this.domain(), { | ||
} | ||
niceMin() { | ||
const maxD = this._domain[this._domain.length - 1]; | ||
this.nice(); | ||
const niceDomain = cloneDeep(this._domain); | ||
return this._domain && (niceDomain[niceDomain.length - 1] = maxD, this.domain(niceDomain)), | ||
this; | ||
} | ||
niceMax() { | ||
const minD = this._domain[0]; | ||
this.nice(); | ||
const niceDomain = cloneDeep(this._domain); | ||
return this._domain && (niceDomain[0] = minD, this.domain(niceDomain)), this; | ||
} | ||
} | ||
//# sourceMappingURL=log-scale.js.map |
@@ -12,3 +12,3 @@ import type { DiscreteScaleType, IBaseScale } from './interface'; | ||
specified(_: Record<string, unknown>): this; | ||
protected _getSpecifiedValue(input: any): undefined | any; | ||
protected _getSpecifiedValue(input: string): undefined | any; | ||
constructor(); | ||
@@ -15,0 +15,0 @@ clone(): IBaseScale; |
@@ -1,3 +0,1 @@ | ||
import { isNil } from "@visactor/vutils"; | ||
import { ScaleEnum } from "./type"; | ||
@@ -26,5 +24,4 @@ | ||
scale(d) { | ||
const special = this._getSpecifiedValue(d); | ||
if (!isNil(special)) return special; | ||
const key = `${d}`; | ||
const key = `${d}`, special = this._getSpecifiedValue(key); | ||
if (void 0 !== special) return special; | ||
let i = this._index.get(key); | ||
@@ -31,0 +28,0 @@ if (!i) { |
{ | ||
"name": "@visactor/vscale", | ||
"version": "0.13.3", | ||
"version": "0.13.4", | ||
"description": "Scales for visual encoding, used in VGrammar, VTable", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
494848
5504