@innoways/hooks 5.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/package.json +2 -2
- package/build-info/index.stats.html +0 -2648
|
@@ -1,2648 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!DOCTYPE html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
8
|
-
<title>hooks</title>
|
|
9
|
-
<style>
|
|
10
|
-
:root {
|
|
11
|
-
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
12
|
-
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
|
|
13
|
-
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
14
|
-
--background-color: #f7eedf;
|
|
15
|
-
--text-color: #333;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@media (prefers-color-scheme: dark) {
|
|
19
|
-
:root {
|
|
20
|
-
--background-color: #2b2d42;
|
|
21
|
-
--text-color: #edf2f4;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
html {
|
|
25
|
-
box-sizing: border-box;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
*,
|
|
29
|
-
*:before,
|
|
30
|
-
*:after {
|
|
31
|
-
box-sizing: inherit;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
html {
|
|
35
|
-
background-color: var(--background-color);
|
|
36
|
-
color: var(--text-color);
|
|
37
|
-
font-family: var(--font-family);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
body {
|
|
41
|
-
padding: 0;
|
|
42
|
-
margin: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
html,
|
|
46
|
-
body {
|
|
47
|
-
height: 100%;
|
|
48
|
-
width: 100%;
|
|
49
|
-
overflow: hidden;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
body {
|
|
53
|
-
display: flex;
|
|
54
|
-
flex-direction: column;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
svg {
|
|
58
|
-
vertical-align: middle;
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
max-height: 100vh;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
main {
|
|
65
|
-
flex-grow: 1;
|
|
66
|
-
height: 100vh;
|
|
67
|
-
padding: 20px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.tooltip {
|
|
71
|
-
position: absolute;
|
|
72
|
-
z-index: 1070;
|
|
73
|
-
border: 2px solid;
|
|
74
|
-
border-radius: 5px;
|
|
75
|
-
padding: 5px;
|
|
76
|
-
white-space: nowrap;
|
|
77
|
-
font-size: 0.875rem;
|
|
78
|
-
background-color: var(--background-color);
|
|
79
|
-
color: var(--text-color);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.tooltip-hidden {
|
|
83
|
-
visibility: hidden;
|
|
84
|
-
opacity: 0;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.sidebar {
|
|
88
|
-
position: fixed;
|
|
89
|
-
top: 0;
|
|
90
|
-
left: 0;
|
|
91
|
-
right: 0;
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: row;
|
|
94
|
-
font-size: 0.7rem;
|
|
95
|
-
align-items: center;
|
|
96
|
-
margin: 0 50px;
|
|
97
|
-
height: 20px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.size-selectors {
|
|
101
|
-
display: flex;
|
|
102
|
-
flex-direction: row;
|
|
103
|
-
align-items: center;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.size-selector {
|
|
107
|
-
display: flex;
|
|
108
|
-
flex-direction: row;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
margin-right: 1rem;
|
|
112
|
-
}
|
|
113
|
-
.size-selector input {
|
|
114
|
-
margin: 0 0.3rem 0 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.filters {
|
|
118
|
-
flex: 1;
|
|
119
|
-
display: flex;
|
|
120
|
-
flex-direction: row;
|
|
121
|
-
align-items: center;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.filter {
|
|
125
|
-
display: flex;
|
|
126
|
-
flex-direction: row;
|
|
127
|
-
align-items: center;
|
|
128
|
-
justify-content: center;
|
|
129
|
-
flex: 1;
|
|
130
|
-
}
|
|
131
|
-
.filter input {
|
|
132
|
-
flex: 1;
|
|
133
|
-
height: 1rem;
|
|
134
|
-
padding: 0.1rem;
|
|
135
|
-
font-size: 0.7rem;
|
|
136
|
-
margin-left: 0.3rem;
|
|
137
|
-
}
|
|
138
|
-
.filter + .filter {
|
|
139
|
-
margin-left: 0.5rem;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.details {
|
|
143
|
-
position: absolute;
|
|
144
|
-
display: flex;
|
|
145
|
-
flex-direction: column;
|
|
146
|
-
align-items: center;
|
|
147
|
-
justify-content: center;
|
|
148
|
-
top: calc(50% - 85px);
|
|
149
|
-
left: calc(50% - 85px);
|
|
150
|
-
width: 170px;
|
|
151
|
-
height: 170px;
|
|
152
|
-
font-size: 14px;
|
|
153
|
-
text-align: center;
|
|
154
|
-
color: var(--font-color);
|
|
155
|
-
z-index: 100;
|
|
156
|
-
overflow: hidden;
|
|
157
|
-
text-overflow: ellipsis;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.details-size {
|
|
161
|
-
font-size: 0.8em;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.details-name {
|
|
165
|
-
font-weight: bold;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.details-percentage {
|
|
169
|
-
margin: 0.4em 0em;
|
|
170
|
-
font-size: 2.4em;
|
|
171
|
-
line-height: 1em;
|
|
172
|
-
}
|
|
173
|
-
</style>
|
|
174
|
-
</head>
|
|
175
|
-
<body>
|
|
176
|
-
<main></main>
|
|
177
|
-
<script>
|
|
178
|
-
/*<!--*/
|
|
179
|
-
var drawChart = (function () {
|
|
180
|
-
'use strict';
|
|
181
|
-
|
|
182
|
-
var n$1,u$1,i$1,t$2,r$1={},f$1=[],e$2=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c$1(n,l){for(var u in l)n[u]=l[u];return n}function s(n){var l=n.parentNode;l&&l.removeChild(n);}function a$1(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return v$1(n,f,i,t,null)}function v$1(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n$1.__v:o};return null!=n$1.vnode&&n$1.vnode(r),r}function y$1(n){return n.children}function p$1(n,l){this.props=n,this.context=l;}function d$1(n,l){if(null==l)return n.__?d$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?d$1(n):null}function _(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return _(n)}}function k$1(l){(!l.__d&&(l.__d=!0)&&u$1.push(l)&&!b$1.__r++||t$2!==n$1.debounceRendering)&&((t$2=n$1.debounceRendering)||i$1)(b$1);}function b$1(){for(var n;b$1.__r=u$1.length;)n=u$1.sort(function(n,l){return n.__v.__b-l.__v.__b}),u$1=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=c$1({},t)).__v=t.__v+1,I(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?d$1(t):o,t.__h),T(u,t),t.__e!=o&&_(t)));});}function m$2(n,l,u,i,t,o,e,c,s,a){var h,p,_,k,b,m,w,A=i&&i.__k||f$1,P=A.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$1(null,k,null,null,k):Array.isArray(k)?v$1(y$1,{children:k},null,null,null):k.__b>0?v$1(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p<P;p++){if((_=A[p])&&k.key==_.key&&k.type===_.type){A[p]=void 0;break}_=null;}I(n,k,_=_||r$1,t,o,e,c,s,a),b=k.__e,(p=k.ref)&&_.ref!=p&&(w||(w=[]),_.ref&&w.push(_.ref,null,k),w.push(p,k.__c||b,k)),null!=b?(null==m&&(m=b),"function"==typeof k.type&&null!=k.__k&&k.__k===_.__k?k.__d=s=g$1(k,s,n):s=x$1(n,k,_,A,b,s),a||"option"!==u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&_.__e==s&&s.parentNode!=n&&(s=d$1(_));}for(u.__e=m,h=P;h--;)null!=A[h]&&("function"==typeof u.type&&null!=A[h].__e&&A[h].__e==u.__d&&(u.__d=d$1(i,h+1)),L(A[h],A[h]));if(w)for(h=0;h<w.length;h++)z(w[h],w[++h],w[++h]);}function g$1(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,l="function"==typeof t.type?g$1(t,l,u):x$1(u,t,t,n.__k,t.__e,l));return l}function x$1(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function A(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C(n,o,l[o],u[o],i);}function P(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||e$2.test(l)?u:u+"px";}function C(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?H:$,o):n.removeEventListener(l,o?H:$,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function $(l){this.l[l.type+!1](n$1.event?n$1.event(l):l);}function H(l){this.l[l.type+!0](n$1.event?n$1.event(l):l);}function I(l,u,i,t,o,r,f,e,s){var a,v,h,d,_,k,b,g,w,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(s=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n$1.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,w=(a=P.contextType)&&t[a.__c],x=a?w?w.props.value:a.__:t,i.__c?b=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new p$1(g,x),v.constructor=P,v.render=M),w&&w.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=c$1({},v.__s)),c$1(v.__s,P.getDerivedStateFromProps(g,v.__s))),d=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==d&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),v.__h.length&&f.push(v);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(d,_,k);});}v.context=x,v.props=g,v.state=v.__s,(a=n$1.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=c$1(c$1({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(d,_)),A=null!=a&&a.type===y$1&&null==a.key?a.props.children:a,m$2(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,s),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),b&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j$1(i.__e,u,i,t,o,r,f,s);(a=n$1.diffed)&&a(u);}catch(l){u.__v=null,(s||null!=r)&&(u.__e=e,u.__h=!!s,r[r.indexOf(e)]=null),n$1.__e(l,u,i);}}function T(l,u){n$1.__c&&n$1.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n$1.__e(l,u.__v);}});}function j$1(n,l,u,i,t,o,e,c){var a,v,h,y,p=u.props,d=l.props,_=l.type,k=0;if("svg"===_&&(t=!0),null!=o)for(;k<o.length;k++)if((a=o[k])&&(a===n||(_?a.localName==_:3==a.nodeType))){n=a,o[k]=null;break}if(null==n){if(null===_)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,d.is&&d),o=null,c=!1;}if(null===_)p===d||c&&n.data===d||(n.data=d);else {if(o=o&&f$1.slice.call(n.childNodes),v=(p=u.props||r$1).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}if(A(n,d,p,t,c),h)l.__k=[];else if(k=l.props.children,m$2(n,Array.isArray(k)?k:[k],l,u,i,t&&"foreignObject"!==_,o,e,n.firstChild,c),null!=o)for(k=o.length;k--;)null!=o[k]&&s(o[k]);c||("value"in d&&void 0!==(k=d.value)&&(k!==n.value||"progress"===_&&!k)&&C(n,"value",k,p.value,!1),"checked"in d&&void 0!==(k=d.checked)&&k!==n.checked&&C(n,"checked",k,p.checked,!1));}return n}function z(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n$1.__e(l,i);}}function L(l,u,i){var t,o,r;if(n$1.unmount&&n$1.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||z(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n$1.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L(t[r],u,i);null!=o&&s(o);}function M(n,l,u){return this.constructor(n,u)}function N(l,u,i){var t,o,e;n$1.__&&n$1.__(l,u),o=(t="function"==typeof i)?null:i&&i.__k||u.__k,e=[],I(u,l=(!t&&i||u).__k=a$1(y$1,null,[l]),o||r$1,r$1,void 0!==u.ownerSVGElement,!t&&i?[i]:o?null:u.firstChild?f$1.slice.call(u.childNodes):null,e,!t&&i?i:o?o.__e:u.firstChild,t),T(e,l);}n$1={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n},__v:0},p$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c$1({},this.state),"function"==typeof n&&(n=n(c$1({},u),this.props)),n&&c$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k$1(this));},p$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k$1(this));},p$1.prototype.render=y$1,u$1=[],i$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b$1.__r=0,0;
|
|
183
|
-
|
|
184
|
-
var t$1,u,r,o=0,i=[],c=n$1.__b,f=n$1.__r,e$1=n$1.diffed,a=n$1.__c,v=n$1.unmount;function m$1(t,r){n$1.__h&&n$1.__h(u,t,o||r),o=0;var i=u.__H||(u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function l(n){return o=1,p(w,n)}function p(n,r,o){var i=m$1(t$1++,2);return i.t=n,i.__c||(i.__=[o?o(r):w(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}));}],i.__c=u),i.__}function y(r,o){var i=m$1(t$1++,3);!n$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__H.__h.push(i));}function d(n,u){var r=m$1(t$1++,7);return k(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function x(){i.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j),t.__H.__h=[];}catch(u){t.__H.__h=[],n$1.__e(u,t.__v);}}),i=[];}n$1.__b=function(n){u=null,c&&c(n);},n$1.__r=function(n){f&&f(n),t$1=0;var r=(u=n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j),r.__h=[]);},n$1.diffed=function(t){e$1&&e$1(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===n$1.requestAnimationFrame||((r=n$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x)),u=void 0;},n$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n$1.__e(r,t.__v);}}),a&&a(t,u);},n$1.unmount=function(t){v&&v(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g);}catch(t){n$1.__e(t,u.__v);}};var b="function"==typeof requestAnimationFrame;function g(n){var t=u;"function"==typeof n.__c&&n.__c(),u=t;}function j(n){var t=u;n.__c=n.__(),u=t;}function k(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function w(n,t){return "function"==typeof t?t(n):t}
|
|
185
|
-
|
|
186
|
-
var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h<s.length;h++){var p=s[h++],a=s[h]?(s[0]|=p?1:2,r[s[h++]]):s[++h];3===p?e[0]=a:4===p?e[1]=Object.assign(e[1]||{},a):5===p?(e[1]=e[1]||{})[s[++h]]=a:6===p?e[1][s[++h]]+=a+"":p?(u=t.apply(a,n(t,a,r,["",null])),e.push(u),a[0]?s[0]|=2:(s[h-2]=0,s[h]=u)):e.push(a);}return e},t=new Map;function e(s){var r=t.get(this);return r||(r=new Map,t.set(this,r)),(r=n(this,r.get(s)||(r.set(s,r=function(n){for(var t,s,r=1,e="",u="",h=[0],p=function(n){1===r&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?h.push(0,n,e):3===r&&(n||e)?(h.push(3,n,e),r=2):2===r&&"..."===e&&n?h.push(4,n,0):2===r&&e&&!n?h.push(5,0,!0,e):r>=5&&((e||!n&&5===r)&&(h.push(r,0,e,s),r=6),n&&(h.push(r,n,0,s),r=6)),e="";},a=0;a<n.length;a++){a&&(1===r&&p(),p(a));for(var l=0;l<n[a].length;l++)t=n[a][l],1===r?"<"===t?(p(),h=[h],r=3):e+=t:4===r?"--"===e&&">"===t?(r=1,e=""):e=t+e[0]:u?t===u?u="":e+=t:'"'===t||"'"===t?u=t:">"===t?(p(),r=1):r&&("="===t?(r=5,s=e,e=""):"/"===t&&(r<5||">"===n[a][l+1])?(p(),3===r&&(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(p(),r=2):e+=t),3===r&&"!--"===e&&(r=4,h=h[0]);}return p(),h}(s)),r),arguments,[])).length>1?r:r[0]}
|
|
187
|
-
|
|
188
|
-
var m=e.bind(a$1);
|
|
189
|
-
|
|
190
|
-
/*!
|
|
191
|
-
* bytes
|
|
192
|
-
* Copyright(c) 2012-2014 TJ Holowaychuk
|
|
193
|
-
* Copyright(c) 2015 Jed Watson
|
|
194
|
-
* MIT Licensed
|
|
195
|
-
*/
|
|
196
|
-
var format_1 = format$1;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Module variables.
|
|
200
|
-
* @private
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
|
|
204
|
-
|
|
205
|
-
var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
|
|
206
|
-
|
|
207
|
-
var map$1 = {
|
|
208
|
-
b: 1,
|
|
209
|
-
kb: 1 << 10,
|
|
210
|
-
mb: 1 << 20,
|
|
211
|
-
gb: 1 << 30,
|
|
212
|
-
tb: Math.pow(1024, 4),
|
|
213
|
-
pb: Math.pow(1024, 5),
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Format the given value in bytes into a string.
|
|
218
|
-
*
|
|
219
|
-
* If the value is negative, it is kept as such. If it is a float,
|
|
220
|
-
* it is rounded.
|
|
221
|
-
*
|
|
222
|
-
* @param {number} value
|
|
223
|
-
* @param {object} [options]
|
|
224
|
-
* @param {number} [options.decimalPlaces=2]
|
|
225
|
-
* @param {number} [options.fixedDecimals=false]
|
|
226
|
-
* @param {string} [options.thousandsSeparator=]
|
|
227
|
-
* @param {string} [options.unit=]
|
|
228
|
-
* @param {string} [options.unitSeparator=]
|
|
229
|
-
*
|
|
230
|
-
* @returns {string|null}
|
|
231
|
-
* @public
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
function format$1(value, options) {
|
|
235
|
-
if (!Number.isFinite(value)) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
var mag = Math.abs(value);
|
|
240
|
-
var thousandsSeparator = (options && options.thousandsSeparator) || '';
|
|
241
|
-
var unitSeparator = (options && options.unitSeparator) || '';
|
|
242
|
-
var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
|
|
243
|
-
var fixedDecimals = Boolean(options && options.fixedDecimals);
|
|
244
|
-
var unit = (options && options.unit) || '';
|
|
245
|
-
|
|
246
|
-
if (!unit || !map$1[unit.toLowerCase()]) {
|
|
247
|
-
if (mag >= map$1.pb) {
|
|
248
|
-
unit = 'PB';
|
|
249
|
-
} else if (mag >= map$1.tb) {
|
|
250
|
-
unit = 'TB';
|
|
251
|
-
} else if (mag >= map$1.gb) {
|
|
252
|
-
unit = 'GB';
|
|
253
|
-
} else if (mag >= map$1.mb) {
|
|
254
|
-
unit = 'MB';
|
|
255
|
-
} else if (mag >= map$1.kb) {
|
|
256
|
-
unit = 'KB';
|
|
257
|
-
} else {
|
|
258
|
-
unit = 'B';
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
var val = value / map$1[unit.toLowerCase()];
|
|
263
|
-
var str = val.toFixed(decimalPlaces);
|
|
264
|
-
|
|
265
|
-
if (!fixedDecimals) {
|
|
266
|
-
str = str.replace(formatDecimalsRegExp, '$1');
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (thousandsSeparator) {
|
|
270
|
-
str = str.replace(formatThousandsRegExp, thousandsSeparator);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return str + unitSeparator + unit;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function count(node) {
|
|
277
|
-
var sum = 0,
|
|
278
|
-
children = node.children,
|
|
279
|
-
i = children && children.length;
|
|
280
|
-
if (!i) sum = 1;
|
|
281
|
-
else while (--i >= 0) sum += children[i].value;
|
|
282
|
-
node.value = sum;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function node_count() {
|
|
286
|
-
return this.eachAfter(count);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function node_each(callback, that) {
|
|
290
|
-
let index = -1;
|
|
291
|
-
for (const node of this) {
|
|
292
|
-
callback.call(that, node, ++index, this);
|
|
293
|
-
}
|
|
294
|
-
return this;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function node_eachBefore(callback, that) {
|
|
298
|
-
var node = this, nodes = [node], children, i, index = -1;
|
|
299
|
-
while (node = nodes.pop()) {
|
|
300
|
-
callback.call(that, node, ++index, this);
|
|
301
|
-
if (children = node.children) {
|
|
302
|
-
for (i = children.length - 1; i >= 0; --i) {
|
|
303
|
-
nodes.push(children[i]);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return this;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function node_eachAfter(callback, that) {
|
|
311
|
-
var node = this, nodes = [node], next = [], children, i, n, index = -1;
|
|
312
|
-
while (node = nodes.pop()) {
|
|
313
|
-
next.push(node);
|
|
314
|
-
if (children = node.children) {
|
|
315
|
-
for (i = 0, n = children.length; i < n; ++i) {
|
|
316
|
-
nodes.push(children[i]);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
while (node = next.pop()) {
|
|
321
|
-
callback.call(that, node, ++index, this);
|
|
322
|
-
}
|
|
323
|
-
return this;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function node_find(callback, that) {
|
|
327
|
-
let index = -1;
|
|
328
|
-
for (const node of this) {
|
|
329
|
-
if (callback.call(that, node, ++index, this)) {
|
|
330
|
-
return node;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function node_sum(value) {
|
|
336
|
-
return this.eachAfter(function(node) {
|
|
337
|
-
var sum = +value(node.data) || 0,
|
|
338
|
-
children = node.children,
|
|
339
|
-
i = children && children.length;
|
|
340
|
-
while (--i >= 0) sum += children[i].value;
|
|
341
|
-
node.value = sum;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function node_sort(compare) {
|
|
346
|
-
return this.eachBefore(function(node) {
|
|
347
|
-
if (node.children) {
|
|
348
|
-
node.children.sort(compare);
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function node_path(end) {
|
|
354
|
-
var start = this,
|
|
355
|
-
ancestor = leastCommonAncestor(start, end),
|
|
356
|
-
nodes = [start];
|
|
357
|
-
while (start !== ancestor) {
|
|
358
|
-
start = start.parent;
|
|
359
|
-
nodes.push(start);
|
|
360
|
-
}
|
|
361
|
-
var k = nodes.length;
|
|
362
|
-
while (end !== ancestor) {
|
|
363
|
-
nodes.splice(k, 0, end);
|
|
364
|
-
end = end.parent;
|
|
365
|
-
}
|
|
366
|
-
return nodes;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function leastCommonAncestor(a, b) {
|
|
370
|
-
if (a === b) return a;
|
|
371
|
-
var aNodes = a.ancestors(),
|
|
372
|
-
bNodes = b.ancestors(),
|
|
373
|
-
c = null;
|
|
374
|
-
a = aNodes.pop();
|
|
375
|
-
b = bNodes.pop();
|
|
376
|
-
while (a === b) {
|
|
377
|
-
c = a;
|
|
378
|
-
a = aNodes.pop();
|
|
379
|
-
b = bNodes.pop();
|
|
380
|
-
}
|
|
381
|
-
return c;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function node_ancestors() {
|
|
385
|
-
var node = this, nodes = [node];
|
|
386
|
-
while (node = node.parent) {
|
|
387
|
-
nodes.push(node);
|
|
388
|
-
}
|
|
389
|
-
return nodes;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function node_descendants() {
|
|
393
|
-
return Array.from(this);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function node_leaves() {
|
|
397
|
-
var leaves = [];
|
|
398
|
-
this.eachBefore(function(node) {
|
|
399
|
-
if (!node.children) {
|
|
400
|
-
leaves.push(node);
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
return leaves;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function node_links() {
|
|
407
|
-
var root = this, links = [];
|
|
408
|
-
root.each(function(node) {
|
|
409
|
-
if (node !== root) { // Don’t include the root’s parent, if any.
|
|
410
|
-
links.push({source: node.parent, target: node});
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
return links;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function* node_iterator() {
|
|
417
|
-
var node = this, current, next = [node], children, i, n;
|
|
418
|
-
do {
|
|
419
|
-
current = next.reverse(), next = [];
|
|
420
|
-
while (node = current.pop()) {
|
|
421
|
-
yield node;
|
|
422
|
-
if (children = node.children) {
|
|
423
|
-
for (i = 0, n = children.length; i < n; ++i) {
|
|
424
|
-
next.push(children[i]);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
} while (next.length);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function hierarchy(data, children) {
|
|
432
|
-
if (data instanceof Map) {
|
|
433
|
-
data = [undefined, data];
|
|
434
|
-
if (children === undefined) children = mapChildren;
|
|
435
|
-
} else if (children === undefined) {
|
|
436
|
-
children = objectChildren;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
var root = new Node$1(data),
|
|
440
|
-
node,
|
|
441
|
-
nodes = [root],
|
|
442
|
-
child,
|
|
443
|
-
childs,
|
|
444
|
-
i,
|
|
445
|
-
n;
|
|
446
|
-
|
|
447
|
-
while (node = nodes.pop()) {
|
|
448
|
-
if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
|
|
449
|
-
node.children = childs;
|
|
450
|
-
for (i = n - 1; i >= 0; --i) {
|
|
451
|
-
nodes.push(child = childs[i] = new Node$1(childs[i]));
|
|
452
|
-
child.parent = node;
|
|
453
|
-
child.depth = node.depth + 1;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return root.eachBefore(computeHeight);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function node_copy() {
|
|
462
|
-
return hierarchy(this).eachBefore(copyData);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function objectChildren(d) {
|
|
466
|
-
return d.children;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function mapChildren(d) {
|
|
470
|
-
return Array.isArray(d) ? d[1] : null;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function copyData(node) {
|
|
474
|
-
if (node.data.value !== undefined) node.value = node.data.value;
|
|
475
|
-
node.data = node.data.data;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
function computeHeight(node) {
|
|
479
|
-
var height = 0;
|
|
480
|
-
do node.height = height;
|
|
481
|
-
while ((node = node.parent) && (node.height < ++height));
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function Node$1(data) {
|
|
485
|
-
this.data = data;
|
|
486
|
-
this.depth =
|
|
487
|
-
this.height = 0;
|
|
488
|
-
this.parent = null;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
Node$1.prototype = hierarchy.prototype = {
|
|
492
|
-
constructor: Node$1,
|
|
493
|
-
count: node_count,
|
|
494
|
-
each: node_each,
|
|
495
|
-
eachAfter: node_eachAfter,
|
|
496
|
-
eachBefore: node_eachBefore,
|
|
497
|
-
find: node_find,
|
|
498
|
-
sum: node_sum,
|
|
499
|
-
sort: node_sort,
|
|
500
|
-
path: node_path,
|
|
501
|
-
ancestors: node_ancestors,
|
|
502
|
-
descendants: node_descendants,
|
|
503
|
-
leaves: node_leaves,
|
|
504
|
-
links: node_links,
|
|
505
|
-
copy: node_copy,
|
|
506
|
-
[Symbol.iterator]: node_iterator
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
function roundNode(node) {
|
|
510
|
-
node.x0 = Math.round(node.x0);
|
|
511
|
-
node.y0 = Math.round(node.y0);
|
|
512
|
-
node.x1 = Math.round(node.x1);
|
|
513
|
-
node.y1 = Math.round(node.y1);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function treemapDice(parent, x0, y0, x1, y1) {
|
|
517
|
-
var nodes = parent.children,
|
|
518
|
-
node,
|
|
519
|
-
i = -1,
|
|
520
|
-
n = nodes.length,
|
|
521
|
-
k = parent.value && (x1 - x0) / parent.value;
|
|
522
|
-
|
|
523
|
-
while (++i < n) {
|
|
524
|
-
node = nodes[i], node.y0 = y0, node.y1 = y1;
|
|
525
|
-
node.x0 = x0, node.x1 = x0 += node.value * k;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function d3partition() {
|
|
530
|
-
var dx = 1,
|
|
531
|
-
dy = 1,
|
|
532
|
-
padding = 0,
|
|
533
|
-
round = false;
|
|
534
|
-
|
|
535
|
-
function partition(root) {
|
|
536
|
-
var n = root.height + 1;
|
|
537
|
-
root.x0 =
|
|
538
|
-
root.y0 = padding;
|
|
539
|
-
root.x1 = dx;
|
|
540
|
-
root.y1 = dy / n;
|
|
541
|
-
root.eachBefore(positionNode(dy, n));
|
|
542
|
-
if (round) root.eachBefore(roundNode);
|
|
543
|
-
return root;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function positionNode(dy, n) {
|
|
547
|
-
return function(node) {
|
|
548
|
-
if (node.children) {
|
|
549
|
-
treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
|
|
550
|
-
}
|
|
551
|
-
var x0 = node.x0,
|
|
552
|
-
y0 = node.y0,
|
|
553
|
-
x1 = node.x1 - padding,
|
|
554
|
-
y1 = node.y1 - padding;
|
|
555
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
556
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
557
|
-
node.x0 = x0;
|
|
558
|
-
node.y0 = y0;
|
|
559
|
-
node.x1 = x1;
|
|
560
|
-
node.y1 = y1;
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
partition.round = function(x) {
|
|
565
|
-
return arguments.length ? (round = !!x, partition) : round;
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
partition.size = function(x) {
|
|
569
|
-
return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
partition.padding = function(x) {
|
|
573
|
-
return arguments.length ? (padding = +x, partition) : padding;
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
return partition;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
const pi$1 = Math.PI,
|
|
580
|
-
tau$1 = 2 * pi$1,
|
|
581
|
-
epsilon$1 = 1e-6,
|
|
582
|
-
tauEpsilon = tau$1 - epsilon$1;
|
|
583
|
-
|
|
584
|
-
function Path() {
|
|
585
|
-
this._x0 = this._y0 = // start of current subpath
|
|
586
|
-
this._x1 = this._y1 = null; // end of current subpath
|
|
587
|
-
this._ = "";
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function path() {
|
|
591
|
-
return new Path;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
Path.prototype = path.prototype = {
|
|
595
|
-
constructor: Path,
|
|
596
|
-
moveTo: function(x, y) {
|
|
597
|
-
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
|
|
598
|
-
},
|
|
599
|
-
closePath: function() {
|
|
600
|
-
if (this._x1 !== null) {
|
|
601
|
-
this._x1 = this._x0, this._y1 = this._y0;
|
|
602
|
-
this._ += "Z";
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
lineTo: function(x, y) {
|
|
606
|
-
this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
607
|
-
},
|
|
608
|
-
quadraticCurveTo: function(x1, y1, x, y) {
|
|
609
|
-
this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
610
|
-
},
|
|
611
|
-
bezierCurveTo: function(x1, y1, x2, y2, x, y) {
|
|
612
|
-
this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
613
|
-
},
|
|
614
|
-
arcTo: function(x1, y1, x2, y2, r) {
|
|
615
|
-
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
616
|
-
var x0 = this._x1,
|
|
617
|
-
y0 = this._y1,
|
|
618
|
-
x21 = x2 - x1,
|
|
619
|
-
y21 = y2 - y1,
|
|
620
|
-
x01 = x0 - x1,
|
|
621
|
-
y01 = y0 - y1,
|
|
622
|
-
l01_2 = x01 * x01 + y01 * y01;
|
|
623
|
-
|
|
624
|
-
// Is the radius negative? Error.
|
|
625
|
-
if (r < 0) throw new Error("negative radius: " + r);
|
|
626
|
-
|
|
627
|
-
// Is this path empty? Move to (x1,y1).
|
|
628
|
-
if (this._x1 === null) {
|
|
629
|
-
this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// Or, is (x1,y1) coincident with (x0,y0)? Do nothing.
|
|
633
|
-
else if (!(l01_2 > epsilon$1));
|
|
634
|
-
|
|
635
|
-
// Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?
|
|
636
|
-
// Equivalently, is (x1,y1) coincident with (x2,y2)?
|
|
637
|
-
// Or, is the radius zero? Line to (x1,y1).
|
|
638
|
-
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$1) || !r) {
|
|
639
|
-
this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// Otherwise, draw an arc!
|
|
643
|
-
else {
|
|
644
|
-
var x20 = x2 - x0,
|
|
645
|
-
y20 = y2 - y0,
|
|
646
|
-
l21_2 = x21 * x21 + y21 * y21,
|
|
647
|
-
l20_2 = x20 * x20 + y20 * y20,
|
|
648
|
-
l21 = Math.sqrt(l21_2),
|
|
649
|
-
l01 = Math.sqrt(l01_2),
|
|
650
|
-
l = r * Math.tan((pi$1 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
|
|
651
|
-
t01 = l / l01,
|
|
652
|
-
t21 = l / l21;
|
|
653
|
-
|
|
654
|
-
// If the start tangent is not coincident with (x0,y0), line to.
|
|
655
|
-
if (Math.abs(t01 - 1) > epsilon$1) {
|
|
656
|
-
this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
arc: function(x, y, r, a0, a1, ccw) {
|
|
663
|
-
x = +x, y = +y, r = +r, ccw = !!ccw;
|
|
664
|
-
var dx = r * Math.cos(a0),
|
|
665
|
-
dy = r * Math.sin(a0),
|
|
666
|
-
x0 = x + dx,
|
|
667
|
-
y0 = y + dy,
|
|
668
|
-
cw = 1 ^ ccw,
|
|
669
|
-
da = ccw ? a0 - a1 : a1 - a0;
|
|
670
|
-
|
|
671
|
-
// Is the radius negative? Error.
|
|
672
|
-
if (r < 0) throw new Error("negative radius: " + r);
|
|
673
|
-
|
|
674
|
-
// Is this path empty? Move to (x0,y0).
|
|
675
|
-
if (this._x1 === null) {
|
|
676
|
-
this._ += "M" + x0 + "," + y0;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).
|
|
680
|
-
else if (Math.abs(this._x1 - x0) > epsilon$1 || Math.abs(this._y1 - y0) > epsilon$1) {
|
|
681
|
-
this._ += "L" + x0 + "," + y0;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// Is this arc empty? We’re done.
|
|
685
|
-
if (!r) return;
|
|
686
|
-
|
|
687
|
-
// Does the angle go the wrong way? Flip the direction.
|
|
688
|
-
if (da < 0) da = da % tau$1 + tau$1;
|
|
689
|
-
|
|
690
|
-
// Is this a complete circle? Draw two arcs to complete the circle.
|
|
691
|
-
if (da > tauEpsilon) {
|
|
692
|
-
this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// Is this arc non-empty? Draw an arc!
|
|
696
|
-
else if (da > epsilon$1) {
|
|
697
|
-
this._ += "A" + r + "," + r + ",0," + (+(da >= pi$1)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
|
|
698
|
-
}
|
|
699
|
-
},
|
|
700
|
-
rect: function(x, y, w, h) {
|
|
701
|
-
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z";
|
|
702
|
-
},
|
|
703
|
-
toString: function() {
|
|
704
|
-
return this._;
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
|
|
708
|
-
function constant$1(x) {
|
|
709
|
-
return function constant() {
|
|
710
|
-
return x;
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
var abs = Math.abs;
|
|
715
|
-
var atan2 = Math.atan2;
|
|
716
|
-
var cos = Math.cos;
|
|
717
|
-
var max = Math.max;
|
|
718
|
-
var min = Math.min;
|
|
719
|
-
var sin = Math.sin;
|
|
720
|
-
var sqrt$1 = Math.sqrt;
|
|
721
|
-
|
|
722
|
-
var epsilon = 1e-12;
|
|
723
|
-
var pi = Math.PI;
|
|
724
|
-
var halfPi = pi / 2;
|
|
725
|
-
var tau = 2 * pi;
|
|
726
|
-
|
|
727
|
-
function acos(x) {
|
|
728
|
-
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
function asin(x) {
|
|
732
|
-
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function arcInnerRadius(d) {
|
|
736
|
-
return d.innerRadius;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
function arcOuterRadius(d) {
|
|
740
|
-
return d.outerRadius;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
function arcStartAngle(d) {
|
|
744
|
-
return d.startAngle;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
function arcEndAngle(d) {
|
|
748
|
-
return d.endAngle;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
function arcPadAngle(d) {
|
|
752
|
-
return d && d.padAngle; // Note: optional!
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
756
|
-
var x10 = x1 - x0, y10 = y1 - y0,
|
|
757
|
-
x32 = x3 - x2, y32 = y3 - y2,
|
|
758
|
-
t = y32 * x10 - x32 * y10;
|
|
759
|
-
if (t * t < epsilon) return;
|
|
760
|
-
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
761
|
-
return [x0 + t * x10, y0 + t * y10];
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// Compute perpendicular offset line of length rc.
|
|
765
|
-
// http://mathworld.wolfram.com/Circle-LineIntersection.html
|
|
766
|
-
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
767
|
-
var x01 = x0 - x1,
|
|
768
|
-
y01 = y0 - y1,
|
|
769
|
-
lo = (cw ? rc : -rc) / sqrt$1(x01 * x01 + y01 * y01),
|
|
770
|
-
ox = lo * y01,
|
|
771
|
-
oy = -lo * x01,
|
|
772
|
-
x11 = x0 + ox,
|
|
773
|
-
y11 = y0 + oy,
|
|
774
|
-
x10 = x1 + ox,
|
|
775
|
-
y10 = y1 + oy,
|
|
776
|
-
x00 = (x11 + x10) / 2,
|
|
777
|
-
y00 = (y11 + y10) / 2,
|
|
778
|
-
dx = x10 - x11,
|
|
779
|
-
dy = y10 - y11,
|
|
780
|
-
d2 = dx * dx + dy * dy,
|
|
781
|
-
r = r1 - rc,
|
|
782
|
-
D = x11 * y10 - x10 * y11,
|
|
783
|
-
d = (dy < 0 ? -1 : 1) * sqrt$1(max(0, r * r * d2 - D * D)),
|
|
784
|
-
cx0 = (D * dy - dx * d) / d2,
|
|
785
|
-
cy0 = (-D * dx - dy * d) / d2,
|
|
786
|
-
cx1 = (D * dy + dx * d) / d2,
|
|
787
|
-
cy1 = (-D * dx + dy * d) / d2,
|
|
788
|
-
dx0 = cx0 - x00,
|
|
789
|
-
dy0 = cy0 - y00,
|
|
790
|
-
dx1 = cx1 - x00,
|
|
791
|
-
dy1 = cy1 - y00;
|
|
792
|
-
|
|
793
|
-
// Pick the closer of the two intersection points.
|
|
794
|
-
// TODO Is there a faster way to determine which intersection to use?
|
|
795
|
-
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
796
|
-
|
|
797
|
-
return {
|
|
798
|
-
cx: cx0,
|
|
799
|
-
cy: cy0,
|
|
800
|
-
x01: -ox,
|
|
801
|
-
y01: -oy,
|
|
802
|
-
x11: cx0 * (r1 / r - 1),
|
|
803
|
-
y11: cy0 * (r1 / r - 1)
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function d3arc() {
|
|
808
|
-
var innerRadius = arcInnerRadius,
|
|
809
|
-
outerRadius = arcOuterRadius,
|
|
810
|
-
cornerRadius = constant$1(0),
|
|
811
|
-
padRadius = null,
|
|
812
|
-
startAngle = arcStartAngle,
|
|
813
|
-
endAngle = arcEndAngle,
|
|
814
|
-
padAngle = arcPadAngle,
|
|
815
|
-
context = null;
|
|
816
|
-
|
|
817
|
-
function arc() {
|
|
818
|
-
var buffer,
|
|
819
|
-
r,
|
|
820
|
-
r0 = +innerRadius.apply(this, arguments),
|
|
821
|
-
r1 = +outerRadius.apply(this, arguments),
|
|
822
|
-
a0 = startAngle.apply(this, arguments) - halfPi,
|
|
823
|
-
a1 = endAngle.apply(this, arguments) - halfPi,
|
|
824
|
-
da = abs(a1 - a0),
|
|
825
|
-
cw = a1 > a0;
|
|
826
|
-
|
|
827
|
-
if (!context) context = buffer = path();
|
|
828
|
-
|
|
829
|
-
// Ensure that the outer radius is always larger than the inner radius.
|
|
830
|
-
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
831
|
-
|
|
832
|
-
// Is it a point?
|
|
833
|
-
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
834
|
-
|
|
835
|
-
// Or is it a circle or annulus?
|
|
836
|
-
else if (da > tau - epsilon) {
|
|
837
|
-
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
838
|
-
context.arc(0, 0, r1, a0, a1, !cw);
|
|
839
|
-
if (r0 > epsilon) {
|
|
840
|
-
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
841
|
-
context.arc(0, 0, r0, a1, a0, cw);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// Or is it a circular or annular sector?
|
|
846
|
-
else {
|
|
847
|
-
var a01 = a0,
|
|
848
|
-
a11 = a1,
|
|
849
|
-
a00 = a0,
|
|
850
|
-
a10 = a1,
|
|
851
|
-
da0 = da,
|
|
852
|
-
da1 = da,
|
|
853
|
-
ap = padAngle.apply(this, arguments) / 2,
|
|
854
|
-
rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt$1(r0 * r0 + r1 * r1)),
|
|
855
|
-
rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
|
|
856
|
-
rc0 = rc,
|
|
857
|
-
rc1 = rc,
|
|
858
|
-
t0,
|
|
859
|
-
t1;
|
|
860
|
-
|
|
861
|
-
// Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
|
|
862
|
-
if (rp > epsilon) {
|
|
863
|
-
var p0 = asin(rp / r0 * sin(ap)),
|
|
864
|
-
p1 = asin(rp / r1 * sin(ap));
|
|
865
|
-
if ((da0 -= p0 * 2) > epsilon) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0;
|
|
866
|
-
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
867
|
-
if ((da1 -= p1 * 2) > epsilon) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1;
|
|
868
|
-
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
var x01 = r1 * cos(a01),
|
|
872
|
-
y01 = r1 * sin(a01),
|
|
873
|
-
x10 = r0 * cos(a10),
|
|
874
|
-
y10 = r0 * sin(a10);
|
|
875
|
-
|
|
876
|
-
// Apply rounded corners?
|
|
877
|
-
if (rc > epsilon) {
|
|
878
|
-
var x11 = r1 * cos(a11),
|
|
879
|
-
y11 = r1 * sin(a11),
|
|
880
|
-
x00 = r0 * cos(a00),
|
|
881
|
-
y00 = r0 * sin(a00),
|
|
882
|
-
oc;
|
|
883
|
-
|
|
884
|
-
// Restrict the corner radius according to the sector angle.
|
|
885
|
-
if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
|
|
886
|
-
var ax = x01 - oc[0],
|
|
887
|
-
ay = y01 - oc[1],
|
|
888
|
-
bx = x11 - oc[0],
|
|
889
|
-
by = y11 - oc[1],
|
|
890
|
-
kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt$1(ax * ax + ay * ay) * sqrt$1(bx * bx + by * by))) / 2),
|
|
891
|
-
lc = sqrt$1(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
892
|
-
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
893
|
-
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// Is the sector collapsed to a line?
|
|
898
|
-
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
899
|
-
|
|
900
|
-
// Does the sector’s outer ring have rounded corners?
|
|
901
|
-
else if (rc1 > epsilon) {
|
|
902
|
-
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
903
|
-
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
904
|
-
|
|
905
|
-
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
906
|
-
|
|
907
|
-
// Have the corners merged?
|
|
908
|
-
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
909
|
-
|
|
910
|
-
// Otherwise, draw the two corners and the ring.
|
|
911
|
-
else {
|
|
912
|
-
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
913
|
-
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
914
|
-
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// Or is the outer ring just a circular arc?
|
|
919
|
-
else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
920
|
-
|
|
921
|
-
// Is there no inner ring, and it’s a circular sector?
|
|
922
|
-
// Or perhaps it’s an annular sector collapsed due to padding?
|
|
923
|
-
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
924
|
-
|
|
925
|
-
// Does the sector’s inner ring (or point) have rounded corners?
|
|
926
|
-
else if (rc0 > epsilon) {
|
|
927
|
-
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
928
|
-
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
929
|
-
|
|
930
|
-
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
931
|
-
|
|
932
|
-
// Have the corners merged?
|
|
933
|
-
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
934
|
-
|
|
935
|
-
// Otherwise, draw the two corners and the ring.
|
|
936
|
-
else {
|
|
937
|
-
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
938
|
-
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
939
|
-
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// Or is the inner ring just a circular arc?
|
|
944
|
-
else context.arc(0, 0, r0, a10, a00, cw);
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
context.closePath();
|
|
948
|
-
|
|
949
|
-
if (buffer) return context = null, buffer + "" || null;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
arc.centroid = function() {
|
|
953
|
-
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
|
|
954
|
-
a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
955
|
-
return [cos(a) * r, sin(a) * r];
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
arc.innerRadius = function(_) {
|
|
959
|
-
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : innerRadius;
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
arc.outerRadius = function(_) {
|
|
963
|
-
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : outerRadius;
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
arc.cornerRadius = function(_) {
|
|
967
|
-
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : cornerRadius;
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
arc.padRadius = function(_) {
|
|
971
|
-
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), arc) : padRadius;
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
arc.startAngle = function(_) {
|
|
975
|
-
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : startAngle;
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
arc.endAngle = function(_) {
|
|
979
|
-
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : endAngle;
|
|
980
|
-
};
|
|
981
|
-
|
|
982
|
-
arc.padAngle = function(_) {
|
|
983
|
-
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : padAngle;
|
|
984
|
-
};
|
|
985
|
-
|
|
986
|
-
arc.context = function(_) {
|
|
987
|
-
return arguments.length ? ((context = _ == null ? null : _), arc) : context;
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
return arc;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
function ascending(a, b) {
|
|
994
|
-
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
function bisector(f) {
|
|
998
|
-
let delta = f;
|
|
999
|
-
let compare = f;
|
|
1000
|
-
|
|
1001
|
-
if (f.length === 1) {
|
|
1002
|
-
delta = (d, x) => f(d) - x;
|
|
1003
|
-
compare = ascendingComparator(f);
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
function left(a, x, lo, hi) {
|
|
1007
|
-
if (lo == null) lo = 0;
|
|
1008
|
-
if (hi == null) hi = a.length;
|
|
1009
|
-
while (lo < hi) {
|
|
1010
|
-
const mid = (lo + hi) >>> 1;
|
|
1011
|
-
if (compare(a[mid], x) < 0) lo = mid + 1;
|
|
1012
|
-
else hi = mid;
|
|
1013
|
-
}
|
|
1014
|
-
return lo;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
function right(a, x, lo, hi) {
|
|
1018
|
-
if (lo == null) lo = 0;
|
|
1019
|
-
if (hi == null) hi = a.length;
|
|
1020
|
-
while (lo < hi) {
|
|
1021
|
-
const mid = (lo + hi) >>> 1;
|
|
1022
|
-
if (compare(a[mid], x) > 0) hi = mid;
|
|
1023
|
-
else lo = mid + 1;
|
|
1024
|
-
}
|
|
1025
|
-
return lo;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
function center(a, x, lo, hi) {
|
|
1029
|
-
if (lo == null) lo = 0;
|
|
1030
|
-
if (hi == null) hi = a.length;
|
|
1031
|
-
const i = left(a, x, lo, hi - 1);
|
|
1032
|
-
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
return {left, center, right};
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
function ascendingComparator(f) {
|
|
1039
|
-
return (d, x) => ascending(f(d), x);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
function number$1(x) {
|
|
1043
|
-
return x === null ? NaN : +x;
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
const ascendingBisect = bisector(ascending);
|
|
1047
|
-
const bisectRight = ascendingBisect.right;
|
|
1048
|
-
bisector(number$1).center;
|
|
1049
|
-
|
|
1050
|
-
var e10 = Math.sqrt(50),
|
|
1051
|
-
e5 = Math.sqrt(10),
|
|
1052
|
-
e2 = Math.sqrt(2);
|
|
1053
|
-
|
|
1054
|
-
function ticks(start, stop, count) {
|
|
1055
|
-
var reverse,
|
|
1056
|
-
i = -1,
|
|
1057
|
-
n,
|
|
1058
|
-
ticks,
|
|
1059
|
-
step;
|
|
1060
|
-
|
|
1061
|
-
stop = +stop, start = +start, count = +count;
|
|
1062
|
-
if (start === stop && count > 0) return [start];
|
|
1063
|
-
if (reverse = stop < start) n = start, start = stop, stop = n;
|
|
1064
|
-
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
|
|
1065
|
-
|
|
1066
|
-
if (step > 0) {
|
|
1067
|
-
start = Math.ceil(start / step);
|
|
1068
|
-
stop = Math.floor(stop / step);
|
|
1069
|
-
ticks = new Array(n = Math.ceil(stop - start + 1));
|
|
1070
|
-
while (++i < n) ticks[i] = (start + i) * step;
|
|
1071
|
-
} else {
|
|
1072
|
-
step = -step;
|
|
1073
|
-
start = Math.ceil(start * step);
|
|
1074
|
-
stop = Math.floor(stop * step);
|
|
1075
|
-
ticks = new Array(n = Math.ceil(stop - start + 1));
|
|
1076
|
-
while (++i < n) ticks[i] = (start + i) / step;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
if (reverse) ticks.reverse();
|
|
1080
|
-
|
|
1081
|
-
return ticks;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
function tickIncrement(start, stop, count) {
|
|
1085
|
-
var step = (stop - start) / Math.max(0, count),
|
|
1086
|
-
power = Math.floor(Math.log(step) / Math.LN10),
|
|
1087
|
-
error = step / Math.pow(10, power);
|
|
1088
|
-
return power >= 0
|
|
1089
|
-
? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
|
|
1090
|
-
: -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
function tickStep(start, stop, count) {
|
|
1094
|
-
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
|
1095
|
-
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
|
1096
|
-
error = step0 / step1;
|
|
1097
|
-
if (error >= e10) step1 *= 10;
|
|
1098
|
-
else if (error >= e5) step1 *= 5;
|
|
1099
|
-
else if (error >= e2) step1 *= 2;
|
|
1100
|
-
return stop < start ? -step1 : step1;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
function initRange(domain, range) {
|
|
1104
|
-
switch (arguments.length) {
|
|
1105
|
-
case 0: break;
|
|
1106
|
-
case 1: this.range(domain); break;
|
|
1107
|
-
default: this.range(range).domain(domain); break;
|
|
1108
|
-
}
|
|
1109
|
-
return this;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
function define(constructor, factory, prototype) {
|
|
1113
|
-
constructor.prototype = factory.prototype = prototype;
|
|
1114
|
-
prototype.constructor = constructor;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
function extend(parent, definition) {
|
|
1118
|
-
var prototype = Object.create(parent.prototype);
|
|
1119
|
-
for (var key in definition) prototype[key] = definition[key];
|
|
1120
|
-
return prototype;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
function Color() {}
|
|
1124
|
-
|
|
1125
|
-
var darker = 0.7;
|
|
1126
|
-
var brighter = 1 / darker;
|
|
1127
|
-
|
|
1128
|
-
var reI = "\\s*([+-]?\\d+)\\s*",
|
|
1129
|
-
reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
|
|
1130
|
-
reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
|
|
1131
|
-
reHex = /^#([0-9a-f]{3,8})$/,
|
|
1132
|
-
reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
|
|
1133
|
-
reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
|
|
1134
|
-
reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
|
|
1135
|
-
reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
|
|
1136
|
-
reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
|
|
1137
|
-
reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
|
|
1138
|
-
|
|
1139
|
-
var named = {
|
|
1140
|
-
aliceblue: 0xf0f8ff,
|
|
1141
|
-
antiquewhite: 0xfaebd7,
|
|
1142
|
-
aqua: 0x00ffff,
|
|
1143
|
-
aquamarine: 0x7fffd4,
|
|
1144
|
-
azure: 0xf0ffff,
|
|
1145
|
-
beige: 0xf5f5dc,
|
|
1146
|
-
bisque: 0xffe4c4,
|
|
1147
|
-
black: 0x000000,
|
|
1148
|
-
blanchedalmond: 0xffebcd,
|
|
1149
|
-
blue: 0x0000ff,
|
|
1150
|
-
blueviolet: 0x8a2be2,
|
|
1151
|
-
brown: 0xa52a2a,
|
|
1152
|
-
burlywood: 0xdeb887,
|
|
1153
|
-
cadetblue: 0x5f9ea0,
|
|
1154
|
-
chartreuse: 0x7fff00,
|
|
1155
|
-
chocolate: 0xd2691e,
|
|
1156
|
-
coral: 0xff7f50,
|
|
1157
|
-
cornflowerblue: 0x6495ed,
|
|
1158
|
-
cornsilk: 0xfff8dc,
|
|
1159
|
-
crimson: 0xdc143c,
|
|
1160
|
-
cyan: 0x00ffff,
|
|
1161
|
-
darkblue: 0x00008b,
|
|
1162
|
-
darkcyan: 0x008b8b,
|
|
1163
|
-
darkgoldenrod: 0xb8860b,
|
|
1164
|
-
darkgray: 0xa9a9a9,
|
|
1165
|
-
darkgreen: 0x006400,
|
|
1166
|
-
darkgrey: 0xa9a9a9,
|
|
1167
|
-
darkkhaki: 0xbdb76b,
|
|
1168
|
-
darkmagenta: 0x8b008b,
|
|
1169
|
-
darkolivegreen: 0x556b2f,
|
|
1170
|
-
darkorange: 0xff8c00,
|
|
1171
|
-
darkorchid: 0x9932cc,
|
|
1172
|
-
darkred: 0x8b0000,
|
|
1173
|
-
darksalmon: 0xe9967a,
|
|
1174
|
-
darkseagreen: 0x8fbc8f,
|
|
1175
|
-
darkslateblue: 0x483d8b,
|
|
1176
|
-
darkslategray: 0x2f4f4f,
|
|
1177
|
-
darkslategrey: 0x2f4f4f,
|
|
1178
|
-
darkturquoise: 0x00ced1,
|
|
1179
|
-
darkviolet: 0x9400d3,
|
|
1180
|
-
deeppink: 0xff1493,
|
|
1181
|
-
deepskyblue: 0x00bfff,
|
|
1182
|
-
dimgray: 0x696969,
|
|
1183
|
-
dimgrey: 0x696969,
|
|
1184
|
-
dodgerblue: 0x1e90ff,
|
|
1185
|
-
firebrick: 0xb22222,
|
|
1186
|
-
floralwhite: 0xfffaf0,
|
|
1187
|
-
forestgreen: 0x228b22,
|
|
1188
|
-
fuchsia: 0xff00ff,
|
|
1189
|
-
gainsboro: 0xdcdcdc,
|
|
1190
|
-
ghostwhite: 0xf8f8ff,
|
|
1191
|
-
gold: 0xffd700,
|
|
1192
|
-
goldenrod: 0xdaa520,
|
|
1193
|
-
gray: 0x808080,
|
|
1194
|
-
green: 0x008000,
|
|
1195
|
-
greenyellow: 0xadff2f,
|
|
1196
|
-
grey: 0x808080,
|
|
1197
|
-
honeydew: 0xf0fff0,
|
|
1198
|
-
hotpink: 0xff69b4,
|
|
1199
|
-
indianred: 0xcd5c5c,
|
|
1200
|
-
indigo: 0x4b0082,
|
|
1201
|
-
ivory: 0xfffff0,
|
|
1202
|
-
khaki: 0xf0e68c,
|
|
1203
|
-
lavender: 0xe6e6fa,
|
|
1204
|
-
lavenderblush: 0xfff0f5,
|
|
1205
|
-
lawngreen: 0x7cfc00,
|
|
1206
|
-
lemonchiffon: 0xfffacd,
|
|
1207
|
-
lightblue: 0xadd8e6,
|
|
1208
|
-
lightcoral: 0xf08080,
|
|
1209
|
-
lightcyan: 0xe0ffff,
|
|
1210
|
-
lightgoldenrodyellow: 0xfafad2,
|
|
1211
|
-
lightgray: 0xd3d3d3,
|
|
1212
|
-
lightgreen: 0x90ee90,
|
|
1213
|
-
lightgrey: 0xd3d3d3,
|
|
1214
|
-
lightpink: 0xffb6c1,
|
|
1215
|
-
lightsalmon: 0xffa07a,
|
|
1216
|
-
lightseagreen: 0x20b2aa,
|
|
1217
|
-
lightskyblue: 0x87cefa,
|
|
1218
|
-
lightslategray: 0x778899,
|
|
1219
|
-
lightslategrey: 0x778899,
|
|
1220
|
-
lightsteelblue: 0xb0c4de,
|
|
1221
|
-
lightyellow: 0xffffe0,
|
|
1222
|
-
lime: 0x00ff00,
|
|
1223
|
-
limegreen: 0x32cd32,
|
|
1224
|
-
linen: 0xfaf0e6,
|
|
1225
|
-
magenta: 0xff00ff,
|
|
1226
|
-
maroon: 0x800000,
|
|
1227
|
-
mediumaquamarine: 0x66cdaa,
|
|
1228
|
-
mediumblue: 0x0000cd,
|
|
1229
|
-
mediumorchid: 0xba55d3,
|
|
1230
|
-
mediumpurple: 0x9370db,
|
|
1231
|
-
mediumseagreen: 0x3cb371,
|
|
1232
|
-
mediumslateblue: 0x7b68ee,
|
|
1233
|
-
mediumspringgreen: 0x00fa9a,
|
|
1234
|
-
mediumturquoise: 0x48d1cc,
|
|
1235
|
-
mediumvioletred: 0xc71585,
|
|
1236
|
-
midnightblue: 0x191970,
|
|
1237
|
-
mintcream: 0xf5fffa,
|
|
1238
|
-
mistyrose: 0xffe4e1,
|
|
1239
|
-
moccasin: 0xffe4b5,
|
|
1240
|
-
navajowhite: 0xffdead,
|
|
1241
|
-
navy: 0x000080,
|
|
1242
|
-
oldlace: 0xfdf5e6,
|
|
1243
|
-
olive: 0x808000,
|
|
1244
|
-
olivedrab: 0x6b8e23,
|
|
1245
|
-
orange: 0xffa500,
|
|
1246
|
-
orangered: 0xff4500,
|
|
1247
|
-
orchid: 0xda70d6,
|
|
1248
|
-
palegoldenrod: 0xeee8aa,
|
|
1249
|
-
palegreen: 0x98fb98,
|
|
1250
|
-
paleturquoise: 0xafeeee,
|
|
1251
|
-
palevioletred: 0xdb7093,
|
|
1252
|
-
papayawhip: 0xffefd5,
|
|
1253
|
-
peachpuff: 0xffdab9,
|
|
1254
|
-
peru: 0xcd853f,
|
|
1255
|
-
pink: 0xffc0cb,
|
|
1256
|
-
plum: 0xdda0dd,
|
|
1257
|
-
powderblue: 0xb0e0e6,
|
|
1258
|
-
purple: 0x800080,
|
|
1259
|
-
rebeccapurple: 0x663399,
|
|
1260
|
-
red: 0xff0000,
|
|
1261
|
-
rosybrown: 0xbc8f8f,
|
|
1262
|
-
royalblue: 0x4169e1,
|
|
1263
|
-
saddlebrown: 0x8b4513,
|
|
1264
|
-
salmon: 0xfa8072,
|
|
1265
|
-
sandybrown: 0xf4a460,
|
|
1266
|
-
seagreen: 0x2e8b57,
|
|
1267
|
-
seashell: 0xfff5ee,
|
|
1268
|
-
sienna: 0xa0522d,
|
|
1269
|
-
silver: 0xc0c0c0,
|
|
1270
|
-
skyblue: 0x87ceeb,
|
|
1271
|
-
slateblue: 0x6a5acd,
|
|
1272
|
-
slategray: 0x708090,
|
|
1273
|
-
slategrey: 0x708090,
|
|
1274
|
-
snow: 0xfffafa,
|
|
1275
|
-
springgreen: 0x00ff7f,
|
|
1276
|
-
steelblue: 0x4682b4,
|
|
1277
|
-
tan: 0xd2b48c,
|
|
1278
|
-
teal: 0x008080,
|
|
1279
|
-
thistle: 0xd8bfd8,
|
|
1280
|
-
tomato: 0xff6347,
|
|
1281
|
-
turquoise: 0x40e0d0,
|
|
1282
|
-
violet: 0xee82ee,
|
|
1283
|
-
wheat: 0xf5deb3,
|
|
1284
|
-
white: 0xffffff,
|
|
1285
|
-
whitesmoke: 0xf5f5f5,
|
|
1286
|
-
yellow: 0xffff00,
|
|
1287
|
-
yellowgreen: 0x9acd32
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
define(Color, color, {
|
|
1291
|
-
copy: function(channels) {
|
|
1292
|
-
return Object.assign(new this.constructor, this, channels);
|
|
1293
|
-
},
|
|
1294
|
-
displayable: function() {
|
|
1295
|
-
return this.rgb().displayable();
|
|
1296
|
-
},
|
|
1297
|
-
hex: color_formatHex, // Deprecated! Use color.formatHex.
|
|
1298
|
-
formatHex: color_formatHex,
|
|
1299
|
-
formatHsl: color_formatHsl,
|
|
1300
|
-
formatRgb: color_formatRgb,
|
|
1301
|
-
toString: color_formatRgb
|
|
1302
|
-
});
|
|
1303
|
-
|
|
1304
|
-
function color_formatHex() {
|
|
1305
|
-
return this.rgb().formatHex();
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
function color_formatHsl() {
|
|
1309
|
-
return hslConvert(this).formatHsl();
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
function color_formatRgb() {
|
|
1313
|
-
return this.rgb().formatRgb();
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
function color(format) {
|
|
1317
|
-
var m, l;
|
|
1318
|
-
format = (format + "").trim().toLowerCase();
|
|
1319
|
-
return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
|
|
1320
|
-
: l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
|
|
1321
|
-
: l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
|
|
1322
|
-
: l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
|
|
1323
|
-
: null) // invalid hex
|
|
1324
|
-
: (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
|
|
1325
|
-
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
|
|
1326
|
-
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
|
|
1327
|
-
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
|
|
1328
|
-
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
|
|
1329
|
-
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
|
|
1330
|
-
: named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
|
|
1331
|
-
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
|
|
1332
|
-
: null;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
function rgbn(n) {
|
|
1336
|
-
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
function rgba(r, g, b, a) {
|
|
1340
|
-
if (a <= 0) r = g = b = NaN;
|
|
1341
|
-
return new Rgb(r, g, b, a);
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
function rgbConvert(o) {
|
|
1345
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1346
|
-
if (!o) return new Rgb;
|
|
1347
|
-
o = o.rgb();
|
|
1348
|
-
return new Rgb(o.r, o.g, o.b, o.opacity);
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
function rgb$1(r, g, b, opacity) {
|
|
1352
|
-
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
function Rgb(r, g, b, opacity) {
|
|
1356
|
-
this.r = +r;
|
|
1357
|
-
this.g = +g;
|
|
1358
|
-
this.b = +b;
|
|
1359
|
-
this.opacity = +opacity;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
define(Rgb, rgb$1, extend(Color, {
|
|
1363
|
-
brighter: function(k) {
|
|
1364
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1365
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1366
|
-
},
|
|
1367
|
-
darker: function(k) {
|
|
1368
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1369
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1370
|
-
},
|
|
1371
|
-
rgb: function() {
|
|
1372
|
-
return this;
|
|
1373
|
-
},
|
|
1374
|
-
displayable: function() {
|
|
1375
|
-
return (-0.5 <= this.r && this.r < 255.5)
|
|
1376
|
-
&& (-0.5 <= this.g && this.g < 255.5)
|
|
1377
|
-
&& (-0.5 <= this.b && this.b < 255.5)
|
|
1378
|
-
&& (0 <= this.opacity && this.opacity <= 1);
|
|
1379
|
-
},
|
|
1380
|
-
hex: rgb_formatHex, // Deprecated! Use color.formatHex.
|
|
1381
|
-
formatHex: rgb_formatHex,
|
|
1382
|
-
formatRgb: rgb_formatRgb,
|
|
1383
|
-
toString: rgb_formatRgb
|
|
1384
|
-
}));
|
|
1385
|
-
|
|
1386
|
-
function rgb_formatHex() {
|
|
1387
|
-
return "#" + hex(this.r) + hex(this.g) + hex(this.b);
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
function rgb_formatRgb() {
|
|
1391
|
-
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
|
|
1392
|
-
return (a === 1 ? "rgb(" : "rgba(")
|
|
1393
|
-
+ Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
|
|
1394
|
-
+ Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
|
|
1395
|
-
+ Math.max(0, Math.min(255, Math.round(this.b) || 0))
|
|
1396
|
-
+ (a === 1 ? ")" : ", " + a + ")");
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
function hex(value) {
|
|
1400
|
-
value = Math.max(0, Math.min(255, Math.round(value) || 0));
|
|
1401
|
-
return (value < 16 ? "0" : "") + value.toString(16);
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
function hsla(h, s, l, a) {
|
|
1405
|
-
if (a <= 0) h = s = l = NaN;
|
|
1406
|
-
else if (l <= 0 || l >= 1) h = s = NaN;
|
|
1407
|
-
else if (s <= 0) h = NaN;
|
|
1408
|
-
return new Hsl(h, s, l, a);
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
function hslConvert(o) {
|
|
1412
|
-
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
|
|
1413
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1414
|
-
if (!o) return new Hsl;
|
|
1415
|
-
if (o instanceof Hsl) return o;
|
|
1416
|
-
o = o.rgb();
|
|
1417
|
-
var r = o.r / 255,
|
|
1418
|
-
g = o.g / 255,
|
|
1419
|
-
b = o.b / 255,
|
|
1420
|
-
min = Math.min(r, g, b),
|
|
1421
|
-
max = Math.max(r, g, b),
|
|
1422
|
-
h = NaN,
|
|
1423
|
-
s = max - min,
|
|
1424
|
-
l = (max + min) / 2;
|
|
1425
|
-
if (s) {
|
|
1426
|
-
if (r === max) h = (g - b) / s + (g < b) * 6;
|
|
1427
|
-
else if (g === max) h = (b - r) / s + 2;
|
|
1428
|
-
else h = (r - g) / s + 4;
|
|
1429
|
-
s /= l < 0.5 ? max + min : 2 - max - min;
|
|
1430
|
-
h *= 60;
|
|
1431
|
-
} else {
|
|
1432
|
-
s = l > 0 && l < 1 ? 0 : h;
|
|
1433
|
-
}
|
|
1434
|
-
return new Hsl(h, s, l, o.opacity);
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
function hsl(h, s, l, opacity) {
|
|
1438
|
-
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
function Hsl(h, s, l, opacity) {
|
|
1442
|
-
this.h = +h;
|
|
1443
|
-
this.s = +s;
|
|
1444
|
-
this.l = +l;
|
|
1445
|
-
this.opacity = +opacity;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
define(Hsl, hsl, extend(Color, {
|
|
1449
|
-
brighter: function(k) {
|
|
1450
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1451
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1452
|
-
},
|
|
1453
|
-
darker: function(k) {
|
|
1454
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1455
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1456
|
-
},
|
|
1457
|
-
rgb: function() {
|
|
1458
|
-
var h = this.h % 360 + (this.h < 0) * 360,
|
|
1459
|
-
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
|
|
1460
|
-
l = this.l,
|
|
1461
|
-
m2 = l + (l < 0.5 ? l : 1 - l) * s,
|
|
1462
|
-
m1 = 2 * l - m2;
|
|
1463
|
-
return new Rgb(
|
|
1464
|
-
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
|
|
1465
|
-
hsl2rgb(h, m1, m2),
|
|
1466
|
-
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
|
|
1467
|
-
this.opacity
|
|
1468
|
-
);
|
|
1469
|
-
},
|
|
1470
|
-
displayable: function() {
|
|
1471
|
-
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
|
|
1472
|
-
&& (0 <= this.l && this.l <= 1)
|
|
1473
|
-
&& (0 <= this.opacity && this.opacity <= 1);
|
|
1474
|
-
},
|
|
1475
|
-
formatHsl: function() {
|
|
1476
|
-
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
|
|
1477
|
-
return (a === 1 ? "hsl(" : "hsla(")
|
|
1478
|
-
+ (this.h || 0) + ", "
|
|
1479
|
-
+ (this.s || 0) * 100 + "%, "
|
|
1480
|
-
+ (this.l || 0) * 100 + "%"
|
|
1481
|
-
+ (a === 1 ? ")" : ", " + a + ")");
|
|
1482
|
-
}
|
|
1483
|
-
}));
|
|
1484
|
-
|
|
1485
|
-
/* From FvD 13.37, CSS Color Module Level 3 */
|
|
1486
|
-
function hsl2rgb(h, m1, m2) {
|
|
1487
|
-
return (h < 60 ? m1 + (m2 - m1) * h / 60
|
|
1488
|
-
: h < 180 ? m2
|
|
1489
|
-
: h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
|
|
1490
|
-
: m1) * 255;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
var constant = x => () => x;
|
|
1494
|
-
|
|
1495
|
-
function linear$1(a, d) {
|
|
1496
|
-
return function(t) {
|
|
1497
|
-
return a + t * d;
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
function exponential(a, b, y) {
|
|
1502
|
-
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
|
|
1503
|
-
return Math.pow(a + t * b, y);
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
function gamma(y) {
|
|
1508
|
-
return (y = +y) === 1 ? nogamma : function(a, b) {
|
|
1509
|
-
return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
function nogamma(a, b) {
|
|
1514
|
-
var d = b - a;
|
|
1515
|
-
return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
var rgb = (function rgbGamma(y) {
|
|
1519
|
-
var color = gamma(y);
|
|
1520
|
-
|
|
1521
|
-
function rgb(start, end) {
|
|
1522
|
-
var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
|
|
1523
|
-
g = color(start.g, end.g),
|
|
1524
|
-
b = color(start.b, end.b),
|
|
1525
|
-
opacity = nogamma(start.opacity, end.opacity);
|
|
1526
|
-
return function(t) {
|
|
1527
|
-
start.r = r(t);
|
|
1528
|
-
start.g = g(t);
|
|
1529
|
-
start.b = b(t);
|
|
1530
|
-
start.opacity = opacity(t);
|
|
1531
|
-
return start + "";
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
rgb.gamma = rgbGamma;
|
|
1536
|
-
|
|
1537
|
-
return rgb;
|
|
1538
|
-
})(1);
|
|
1539
|
-
|
|
1540
|
-
function numberArray(a, b) {
|
|
1541
|
-
if (!b) b = [];
|
|
1542
|
-
var n = a ? Math.min(b.length, a.length) : 0,
|
|
1543
|
-
c = b.slice(),
|
|
1544
|
-
i;
|
|
1545
|
-
return function(t) {
|
|
1546
|
-
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
|
|
1547
|
-
return c;
|
|
1548
|
-
};
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
function isNumberArray(x) {
|
|
1552
|
-
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
function genericArray(a, b) {
|
|
1556
|
-
var nb = b ? b.length : 0,
|
|
1557
|
-
na = a ? Math.min(nb, a.length) : 0,
|
|
1558
|
-
x = new Array(na),
|
|
1559
|
-
c = new Array(nb),
|
|
1560
|
-
i;
|
|
1561
|
-
|
|
1562
|
-
for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
|
|
1563
|
-
for (; i < nb; ++i) c[i] = b[i];
|
|
1564
|
-
|
|
1565
|
-
return function(t) {
|
|
1566
|
-
for (i = 0; i < na; ++i) c[i] = x[i](t);
|
|
1567
|
-
return c;
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
function date(a, b) {
|
|
1572
|
-
var d = new Date;
|
|
1573
|
-
return a = +a, b = +b, function(t) {
|
|
1574
|
-
return d.setTime(a * (1 - t) + b * t), d;
|
|
1575
|
-
};
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
function interpolateNumber(a, b) {
|
|
1579
|
-
return a = +a, b = +b, function(t) {
|
|
1580
|
-
return a * (1 - t) + b * t;
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
function object(a, b) {
|
|
1585
|
-
var i = {},
|
|
1586
|
-
c = {},
|
|
1587
|
-
k;
|
|
1588
|
-
|
|
1589
|
-
if (a === null || typeof a !== "object") a = {};
|
|
1590
|
-
if (b === null || typeof b !== "object") b = {};
|
|
1591
|
-
|
|
1592
|
-
for (k in b) {
|
|
1593
|
-
if (k in a) {
|
|
1594
|
-
i[k] = interpolate(a[k], b[k]);
|
|
1595
|
-
} else {
|
|
1596
|
-
c[k] = b[k];
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
return function(t) {
|
|
1601
|
-
for (k in i) c[k] = i[k](t);
|
|
1602
|
-
return c;
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
|
|
1607
|
-
reB = new RegExp(reA.source, "g");
|
|
1608
|
-
|
|
1609
|
-
function zero(b) {
|
|
1610
|
-
return function() {
|
|
1611
|
-
return b;
|
|
1612
|
-
};
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
function one(b) {
|
|
1616
|
-
return function(t) {
|
|
1617
|
-
return b(t) + "";
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
function string(a, b) {
|
|
1622
|
-
var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
|
|
1623
|
-
am, // current match in a
|
|
1624
|
-
bm, // current match in b
|
|
1625
|
-
bs, // string preceding current number in b, if any
|
|
1626
|
-
i = -1, // index in s
|
|
1627
|
-
s = [], // string constants and placeholders
|
|
1628
|
-
q = []; // number interpolators
|
|
1629
|
-
|
|
1630
|
-
// Coerce inputs to strings.
|
|
1631
|
-
a = a + "", b = b + "";
|
|
1632
|
-
|
|
1633
|
-
// Interpolate pairs of numbers in a & b.
|
|
1634
|
-
while ((am = reA.exec(a))
|
|
1635
|
-
&& (bm = reB.exec(b))) {
|
|
1636
|
-
if ((bs = bm.index) > bi) { // a string precedes the next number in b
|
|
1637
|
-
bs = b.slice(bi, bs);
|
|
1638
|
-
if (s[i]) s[i] += bs; // coalesce with previous string
|
|
1639
|
-
else s[++i] = bs;
|
|
1640
|
-
}
|
|
1641
|
-
if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
|
|
1642
|
-
if (s[i]) s[i] += bm; // coalesce with previous string
|
|
1643
|
-
else s[++i] = bm;
|
|
1644
|
-
} else { // interpolate non-matching numbers
|
|
1645
|
-
s[++i] = null;
|
|
1646
|
-
q.push({i: i, x: interpolateNumber(am, bm)});
|
|
1647
|
-
}
|
|
1648
|
-
bi = reB.lastIndex;
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
// Add remains of b.
|
|
1652
|
-
if (bi < b.length) {
|
|
1653
|
-
bs = b.slice(bi);
|
|
1654
|
-
if (s[i]) s[i] += bs; // coalesce with previous string
|
|
1655
|
-
else s[++i] = bs;
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
// Special optimization for only a single match.
|
|
1659
|
-
// Otherwise, interpolate each of the numbers and rejoin the string.
|
|
1660
|
-
return s.length < 2 ? (q[0]
|
|
1661
|
-
? one(q[0].x)
|
|
1662
|
-
: zero(b))
|
|
1663
|
-
: (b = q.length, function(t) {
|
|
1664
|
-
for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
|
|
1665
|
-
return s.join("");
|
|
1666
|
-
});
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
function interpolate(a, b) {
|
|
1670
|
-
var t = typeof b, c;
|
|
1671
|
-
return b == null || t === "boolean" ? constant(b)
|
|
1672
|
-
: (t === "number" ? interpolateNumber
|
|
1673
|
-
: t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
|
|
1674
|
-
: b instanceof color ? rgb
|
|
1675
|
-
: b instanceof Date ? date
|
|
1676
|
-
: isNumberArray(b) ? numberArray
|
|
1677
|
-
: Array.isArray(b) ? genericArray
|
|
1678
|
-
: typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
|
|
1679
|
-
: interpolateNumber)(a, b);
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
function interpolateRound(a, b) {
|
|
1683
|
-
return a = +a, b = +b, function(t) {
|
|
1684
|
-
return Math.round(a * (1 - t) + b * t);
|
|
1685
|
-
};
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
function constants(x) {
|
|
1689
|
-
return function() {
|
|
1690
|
-
return x;
|
|
1691
|
-
};
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
function number(x) {
|
|
1695
|
-
return +x;
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
var unit = [0, 1];
|
|
1699
|
-
|
|
1700
|
-
function identity$1(x) {
|
|
1701
|
-
return x;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
function normalize(a, b) {
|
|
1705
|
-
return (b -= (a = +a))
|
|
1706
|
-
? function(x) { return (x - a) / b; }
|
|
1707
|
-
: constants(isNaN(b) ? NaN : 0.5);
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
function clamper(a, b) {
|
|
1711
|
-
var t;
|
|
1712
|
-
if (a > b) t = a, a = b, b = t;
|
|
1713
|
-
return function(x) { return Math.max(a, Math.min(b, x)); };
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
|
|
1717
|
-
// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
|
|
1718
|
-
function bimap(domain, range, interpolate) {
|
|
1719
|
-
var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
|
|
1720
|
-
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
|
|
1721
|
-
else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
|
|
1722
|
-
return function(x) { return r0(d0(x)); };
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
function polymap(domain, range, interpolate) {
|
|
1726
|
-
var j = Math.min(domain.length, range.length) - 1,
|
|
1727
|
-
d = new Array(j),
|
|
1728
|
-
r = new Array(j),
|
|
1729
|
-
i = -1;
|
|
1730
|
-
|
|
1731
|
-
// Reverse descending domains.
|
|
1732
|
-
if (domain[j] < domain[0]) {
|
|
1733
|
-
domain = domain.slice().reverse();
|
|
1734
|
-
range = range.slice().reverse();
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
while (++i < j) {
|
|
1738
|
-
d[i] = normalize(domain[i], domain[i + 1]);
|
|
1739
|
-
r[i] = interpolate(range[i], range[i + 1]);
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
return function(x) {
|
|
1743
|
-
var i = bisectRight(domain, x, 1, j) - 1;
|
|
1744
|
-
return r[i](d[i](x));
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
function copy(source, target) {
|
|
1749
|
-
return target
|
|
1750
|
-
.domain(source.domain())
|
|
1751
|
-
.range(source.range())
|
|
1752
|
-
.interpolate(source.interpolate())
|
|
1753
|
-
.clamp(source.clamp())
|
|
1754
|
-
.unknown(source.unknown());
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
function transformer() {
|
|
1758
|
-
var domain = unit,
|
|
1759
|
-
range = unit,
|
|
1760
|
-
interpolate$1 = interpolate,
|
|
1761
|
-
transform,
|
|
1762
|
-
untransform,
|
|
1763
|
-
unknown,
|
|
1764
|
-
clamp = identity$1,
|
|
1765
|
-
piecewise,
|
|
1766
|
-
output,
|
|
1767
|
-
input;
|
|
1768
|
-
|
|
1769
|
-
function rescale() {
|
|
1770
|
-
var n = Math.min(domain.length, range.length);
|
|
1771
|
-
if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
|
|
1772
|
-
piecewise = n > 2 ? polymap : bimap;
|
|
1773
|
-
output = input = null;
|
|
1774
|
-
return scale;
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
function scale(x) {
|
|
1778
|
-
return isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
scale.invert = function(y) {
|
|
1782
|
-
return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
|
|
1783
|
-
};
|
|
1784
|
-
|
|
1785
|
-
scale.domain = function(_) {
|
|
1786
|
-
return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
scale.range = function(_) {
|
|
1790
|
-
return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
|
|
1791
|
-
};
|
|
1792
|
-
|
|
1793
|
-
scale.rangeRound = function(_) {
|
|
1794
|
-
return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
|
|
1795
|
-
};
|
|
1796
|
-
|
|
1797
|
-
scale.clamp = function(_) {
|
|
1798
|
-
return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
|
|
1799
|
-
};
|
|
1800
|
-
|
|
1801
|
-
scale.interpolate = function(_) {
|
|
1802
|
-
return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
scale.unknown = function(_) {
|
|
1806
|
-
return arguments.length ? (unknown = _, scale) : unknown;
|
|
1807
|
-
};
|
|
1808
|
-
|
|
1809
|
-
return function(t, u) {
|
|
1810
|
-
transform = t, untransform = u;
|
|
1811
|
-
return rescale();
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
function continuous() {
|
|
1816
|
-
return transformer()(identity$1, identity$1);
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
function formatDecimal(x) {
|
|
1820
|
-
return Math.abs(x = Math.round(x)) >= 1e21
|
|
1821
|
-
? x.toLocaleString("en").replace(/,/g, "")
|
|
1822
|
-
: x.toString(10);
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
// Computes the decimal coefficient and exponent of the specified number x with
|
|
1826
|
-
// significant digits p, where x is positive and p is in [1, 21] or undefined.
|
|
1827
|
-
// For example, formatDecimalParts(1.23) returns ["123", 0].
|
|
1828
|
-
function formatDecimalParts(x, p) {
|
|
1829
|
-
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
|
|
1830
|
-
var i, coefficient = x.slice(0, i);
|
|
1831
|
-
|
|
1832
|
-
// The string returned by toExponential either has the form \d\.\d+e[-+]\d+
|
|
1833
|
-
// (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
|
|
1834
|
-
return [
|
|
1835
|
-
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
1836
|
-
+x.slice(i + 1)
|
|
1837
|
-
];
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
|
-
function exponent(x) {
|
|
1841
|
-
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
function formatGroup(grouping, thousands) {
|
|
1845
|
-
return function(value, width) {
|
|
1846
|
-
var i = value.length,
|
|
1847
|
-
t = [],
|
|
1848
|
-
j = 0,
|
|
1849
|
-
g = grouping[0],
|
|
1850
|
-
length = 0;
|
|
1851
|
-
|
|
1852
|
-
while (i > 0 && g > 0) {
|
|
1853
|
-
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
1854
|
-
t.push(value.substring(i -= g, i + g));
|
|
1855
|
-
if ((length += g + 1) > width) break;
|
|
1856
|
-
g = grouping[j = (j + 1) % grouping.length];
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
return t.reverse().join(thousands);
|
|
1860
|
-
};
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
function formatNumerals(numerals) {
|
|
1864
|
-
return function(value) {
|
|
1865
|
-
return value.replace(/[0-9]/g, function(i) {
|
|
1866
|
-
return numerals[+i];
|
|
1867
|
-
});
|
|
1868
|
-
};
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
// [[fill]align][sign][symbol][0][width][,][.precision][~][type]
|
|
1872
|
-
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
1873
|
-
|
|
1874
|
-
function formatSpecifier(specifier) {
|
|
1875
|
-
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
1876
|
-
var match;
|
|
1877
|
-
return new FormatSpecifier({
|
|
1878
|
-
fill: match[1],
|
|
1879
|
-
align: match[2],
|
|
1880
|
-
sign: match[3],
|
|
1881
|
-
symbol: match[4],
|
|
1882
|
-
zero: match[5],
|
|
1883
|
-
width: match[6],
|
|
1884
|
-
comma: match[7],
|
|
1885
|
-
precision: match[8] && match[8].slice(1),
|
|
1886
|
-
trim: match[9],
|
|
1887
|
-
type: match[10]
|
|
1888
|
-
});
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
|
|
1892
|
-
|
|
1893
|
-
function FormatSpecifier(specifier) {
|
|
1894
|
-
this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
|
|
1895
|
-
this.align = specifier.align === undefined ? ">" : specifier.align + "";
|
|
1896
|
-
this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
|
|
1897
|
-
this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
|
|
1898
|
-
this.zero = !!specifier.zero;
|
|
1899
|
-
this.width = specifier.width === undefined ? undefined : +specifier.width;
|
|
1900
|
-
this.comma = !!specifier.comma;
|
|
1901
|
-
this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
|
|
1902
|
-
this.trim = !!specifier.trim;
|
|
1903
|
-
this.type = specifier.type === undefined ? "" : specifier.type + "";
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
FormatSpecifier.prototype.toString = function() {
|
|
1907
|
-
return this.fill
|
|
1908
|
-
+ this.align
|
|
1909
|
-
+ this.sign
|
|
1910
|
-
+ this.symbol
|
|
1911
|
-
+ (this.zero ? "0" : "")
|
|
1912
|
-
+ (this.width === undefined ? "" : Math.max(1, this.width | 0))
|
|
1913
|
-
+ (this.comma ? "," : "")
|
|
1914
|
-
+ (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
|
|
1915
|
-
+ (this.trim ? "~" : "")
|
|
1916
|
-
+ this.type;
|
|
1917
|
-
};
|
|
1918
|
-
|
|
1919
|
-
// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
|
|
1920
|
-
function formatTrim(s) {
|
|
1921
|
-
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
1922
|
-
switch (s[i]) {
|
|
1923
|
-
case ".": i0 = i1 = i; break;
|
|
1924
|
-
case "0": if (i0 === 0) i0 = i; i1 = i; break;
|
|
1925
|
-
default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
var prefixExponent;
|
|
1932
|
-
|
|
1933
|
-
function formatPrefixAuto(x, p) {
|
|
1934
|
-
var d = formatDecimalParts(x, p);
|
|
1935
|
-
if (!d) return x + "";
|
|
1936
|
-
var coefficient = d[0],
|
|
1937
|
-
exponent = d[1],
|
|
1938
|
-
i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
|
|
1939
|
-
n = coefficient.length;
|
|
1940
|
-
return i === n ? coefficient
|
|
1941
|
-
: i > n ? coefficient + new Array(i - n + 1).join("0")
|
|
1942
|
-
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
|
|
1943
|
-
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
function formatRounded(x, p) {
|
|
1947
|
-
var d = formatDecimalParts(x, p);
|
|
1948
|
-
if (!d) return x + "";
|
|
1949
|
-
var coefficient = d[0],
|
|
1950
|
-
exponent = d[1];
|
|
1951
|
-
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
|
|
1952
|
-
: coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
|
|
1953
|
-
: coefficient + new Array(exponent - coefficient.length + 2).join("0");
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
var formatTypes = {
|
|
1957
|
-
"%": (x, p) => (x * 100).toFixed(p),
|
|
1958
|
-
"b": (x) => Math.round(x).toString(2),
|
|
1959
|
-
"c": (x) => x + "",
|
|
1960
|
-
"d": formatDecimal,
|
|
1961
|
-
"e": (x, p) => x.toExponential(p),
|
|
1962
|
-
"f": (x, p) => x.toFixed(p),
|
|
1963
|
-
"g": (x, p) => x.toPrecision(p),
|
|
1964
|
-
"o": (x) => Math.round(x).toString(8),
|
|
1965
|
-
"p": (x, p) => formatRounded(x * 100, p),
|
|
1966
|
-
"r": formatRounded,
|
|
1967
|
-
"s": formatPrefixAuto,
|
|
1968
|
-
"X": (x) => Math.round(x).toString(16).toUpperCase(),
|
|
1969
|
-
"x": (x) => Math.round(x).toString(16)
|
|
1970
|
-
};
|
|
1971
|
-
|
|
1972
|
-
function identity(x) {
|
|
1973
|
-
return x;
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
|
-
var map = Array.prototype.map,
|
|
1977
|
-
prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
|
|
1978
|
-
|
|
1979
|
-
function formatLocale(locale) {
|
|
1980
|
-
var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
|
|
1981
|
-
currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
|
|
1982
|
-
currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
|
|
1983
|
-
decimal = locale.decimal === undefined ? "." : locale.decimal + "",
|
|
1984
|
-
numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
|
|
1985
|
-
percent = locale.percent === undefined ? "%" : locale.percent + "",
|
|
1986
|
-
minus = locale.minus === undefined ? "−" : locale.minus + "",
|
|
1987
|
-
nan = locale.nan === undefined ? "NaN" : locale.nan + "";
|
|
1988
|
-
|
|
1989
|
-
function newFormat(specifier) {
|
|
1990
|
-
specifier = formatSpecifier(specifier);
|
|
1991
|
-
|
|
1992
|
-
var fill = specifier.fill,
|
|
1993
|
-
align = specifier.align,
|
|
1994
|
-
sign = specifier.sign,
|
|
1995
|
-
symbol = specifier.symbol,
|
|
1996
|
-
zero = specifier.zero,
|
|
1997
|
-
width = specifier.width,
|
|
1998
|
-
comma = specifier.comma,
|
|
1999
|
-
precision = specifier.precision,
|
|
2000
|
-
trim = specifier.trim,
|
|
2001
|
-
type = specifier.type;
|
|
2002
|
-
|
|
2003
|
-
// The "n" type is an alias for ",g".
|
|
2004
|
-
if (type === "n") comma = true, type = "g";
|
|
2005
|
-
|
|
2006
|
-
// The "" type, and any invalid type, is an alias for ".12~g".
|
|
2007
|
-
else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
|
|
2008
|
-
|
|
2009
|
-
// If zero fill is specified, padding goes after sign and before digits.
|
|
2010
|
-
if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
|
|
2011
|
-
|
|
2012
|
-
// Compute the prefix and suffix.
|
|
2013
|
-
// For SI-prefix, the suffix is lazily computed.
|
|
2014
|
-
var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
|
|
2015
|
-
suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
|
|
2016
|
-
|
|
2017
|
-
// What format function should we use?
|
|
2018
|
-
// Is this an integer type?
|
|
2019
|
-
// Can this type generate exponential notation?
|
|
2020
|
-
var formatType = formatTypes[type],
|
|
2021
|
-
maybeSuffix = /[defgprs%]/.test(type);
|
|
2022
|
-
|
|
2023
|
-
// Set the default precision if not specified,
|
|
2024
|
-
// or clamp the specified precision to the supported range.
|
|
2025
|
-
// For significant precision, it must be in [1, 21].
|
|
2026
|
-
// For fixed precision, it must be in [0, 20].
|
|
2027
|
-
precision = precision === undefined ? 6
|
|
2028
|
-
: /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
|
|
2029
|
-
: Math.max(0, Math.min(20, precision));
|
|
2030
|
-
|
|
2031
|
-
function format(value) {
|
|
2032
|
-
var valuePrefix = prefix,
|
|
2033
|
-
valueSuffix = suffix,
|
|
2034
|
-
i, n, c;
|
|
2035
|
-
|
|
2036
|
-
if (type === "c") {
|
|
2037
|
-
valueSuffix = formatType(value) + valueSuffix;
|
|
2038
|
-
value = "";
|
|
2039
|
-
} else {
|
|
2040
|
-
value = +value;
|
|
2041
|
-
|
|
2042
|
-
// Determine the sign. -0 is not less than 0, but 1 / -0 is!
|
|
2043
|
-
var valueNegative = value < 0 || 1 / value < 0;
|
|
2044
|
-
|
|
2045
|
-
// Perform the initial formatting.
|
|
2046
|
-
value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
|
|
2047
|
-
|
|
2048
|
-
// Trim insignificant zeros.
|
|
2049
|
-
if (trim) value = formatTrim(value);
|
|
2050
|
-
|
|
2051
|
-
// If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
|
|
2052
|
-
if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
|
|
2053
|
-
|
|
2054
|
-
// Compute the prefix and suffix.
|
|
2055
|
-
valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
|
|
2056
|
-
valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
|
|
2057
|
-
|
|
2058
|
-
// Break the formatted value into the integer “value” part that can be
|
|
2059
|
-
// grouped, and fractional or exponential “suffix” part that is not.
|
|
2060
|
-
if (maybeSuffix) {
|
|
2061
|
-
i = -1, n = value.length;
|
|
2062
|
-
while (++i < n) {
|
|
2063
|
-
if (c = value.charCodeAt(i), 48 > c || c > 57) {
|
|
2064
|
-
valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
|
|
2065
|
-
value = value.slice(0, i);
|
|
2066
|
-
break;
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
// If the fill character is not "0", grouping is applied before padding.
|
|
2073
|
-
if (comma && !zero) value = group(value, Infinity);
|
|
2074
|
-
|
|
2075
|
-
// Compute the padding.
|
|
2076
|
-
var length = valuePrefix.length + value.length + valueSuffix.length,
|
|
2077
|
-
padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
2078
|
-
|
|
2079
|
-
// If the fill character is "0", grouping is applied after padding.
|
|
2080
|
-
if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
2081
|
-
|
|
2082
|
-
// Reconstruct the final output based on the desired alignment.
|
|
2083
|
-
switch (align) {
|
|
2084
|
-
case "<": value = valuePrefix + value + valueSuffix + padding; break;
|
|
2085
|
-
case "=": value = valuePrefix + padding + value + valueSuffix; break;
|
|
2086
|
-
case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
|
|
2087
|
-
default: value = padding + valuePrefix + value + valueSuffix; break;
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
return numerals(value);
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
format.toString = function() {
|
|
2094
|
-
return specifier + "";
|
|
2095
|
-
};
|
|
2096
|
-
|
|
2097
|
-
return format;
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
function formatPrefix(specifier, value) {
|
|
2101
|
-
var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
|
|
2102
|
-
e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
|
|
2103
|
-
k = Math.pow(10, -e),
|
|
2104
|
-
prefix = prefixes[8 + e / 3];
|
|
2105
|
-
return function(value) {
|
|
2106
|
-
return f(k * value) + prefix;
|
|
2107
|
-
};
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
return {
|
|
2111
|
-
format: newFormat,
|
|
2112
|
-
formatPrefix: formatPrefix
|
|
2113
|
-
};
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
var locale;
|
|
2117
|
-
var format;
|
|
2118
|
-
var formatPrefix;
|
|
2119
|
-
|
|
2120
|
-
defaultLocale({
|
|
2121
|
-
thousands: ",",
|
|
2122
|
-
grouping: [3],
|
|
2123
|
-
currency: ["$", ""]
|
|
2124
|
-
});
|
|
2125
|
-
|
|
2126
|
-
function defaultLocale(definition) {
|
|
2127
|
-
locale = formatLocale(definition);
|
|
2128
|
-
format = locale.format;
|
|
2129
|
-
formatPrefix = locale.formatPrefix;
|
|
2130
|
-
return locale;
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
function precisionFixed(step) {
|
|
2134
|
-
return Math.max(0, -exponent(Math.abs(step)));
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
function precisionPrefix(step, value) {
|
|
2138
|
-
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
function precisionRound(step, max) {
|
|
2142
|
-
step = Math.abs(step), max = Math.abs(max) - step;
|
|
2143
|
-
return Math.max(0, exponent(max) - exponent(step)) + 1;
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
function tickFormat(start, stop, count, specifier) {
|
|
2147
|
-
var step = tickStep(start, stop, count),
|
|
2148
|
-
precision;
|
|
2149
|
-
specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
|
2150
|
-
switch (specifier.type) {
|
|
2151
|
-
case "s": {
|
|
2152
|
-
var value = Math.max(Math.abs(start), Math.abs(stop));
|
|
2153
|
-
if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
|
|
2154
|
-
return formatPrefix(specifier, value);
|
|
2155
|
-
}
|
|
2156
|
-
case "":
|
|
2157
|
-
case "e":
|
|
2158
|
-
case "g":
|
|
2159
|
-
case "p":
|
|
2160
|
-
case "r": {
|
|
2161
|
-
if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
2162
|
-
break;
|
|
2163
|
-
}
|
|
2164
|
-
case "f":
|
|
2165
|
-
case "%": {
|
|
2166
|
-
if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
2167
|
-
break;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
return format(specifier);
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
function linearish(scale) {
|
|
2174
|
-
var domain = scale.domain;
|
|
2175
|
-
|
|
2176
|
-
scale.ticks = function(count) {
|
|
2177
|
-
var d = domain();
|
|
2178
|
-
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
2179
|
-
};
|
|
2180
|
-
|
|
2181
|
-
scale.tickFormat = function(count, specifier) {
|
|
2182
|
-
var d = domain();
|
|
2183
|
-
return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
|
2184
|
-
};
|
|
2185
|
-
|
|
2186
|
-
scale.nice = function(count) {
|
|
2187
|
-
if (count == null) count = 10;
|
|
2188
|
-
|
|
2189
|
-
var d = domain();
|
|
2190
|
-
var i0 = 0;
|
|
2191
|
-
var i1 = d.length - 1;
|
|
2192
|
-
var start = d[i0];
|
|
2193
|
-
var stop = d[i1];
|
|
2194
|
-
var prestep;
|
|
2195
|
-
var step;
|
|
2196
|
-
var maxIter = 10;
|
|
2197
|
-
|
|
2198
|
-
if (stop < start) {
|
|
2199
|
-
step = start, start = stop, stop = step;
|
|
2200
|
-
step = i0, i0 = i1, i1 = step;
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
while (maxIter-- > 0) {
|
|
2204
|
-
step = tickIncrement(start, stop, count);
|
|
2205
|
-
if (step === prestep) {
|
|
2206
|
-
d[i0] = start;
|
|
2207
|
-
d[i1] = stop;
|
|
2208
|
-
return domain(d);
|
|
2209
|
-
} else if (step > 0) {
|
|
2210
|
-
start = Math.floor(start / step) * step;
|
|
2211
|
-
stop = Math.ceil(stop / step) * step;
|
|
2212
|
-
} else if (step < 0) {
|
|
2213
|
-
start = Math.ceil(start * step) / step;
|
|
2214
|
-
stop = Math.floor(stop * step) / step;
|
|
2215
|
-
} else {
|
|
2216
|
-
break;
|
|
2217
|
-
}
|
|
2218
|
-
prestep = step;
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
|
-
return scale;
|
|
2222
|
-
};
|
|
2223
|
-
|
|
2224
|
-
return scale;
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
function linear() {
|
|
2228
|
-
var scale = continuous();
|
|
2229
|
-
|
|
2230
|
-
scale.copy = function() {
|
|
2231
|
-
return copy(scale, linear());
|
|
2232
|
-
};
|
|
2233
|
-
|
|
2234
|
-
initRange.apply(scale, arguments);
|
|
2235
|
-
|
|
2236
|
-
return linearish(scale);
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
function transformPow(exponent) {
|
|
2240
|
-
return function(x) {
|
|
2241
|
-
return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
|
|
2242
|
-
};
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
function transformSqrt(x) {
|
|
2246
|
-
return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x);
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
function transformSquare(x) {
|
|
2250
|
-
return x < 0 ? -x * x : x * x;
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
function powish(transform) {
|
|
2254
|
-
var scale = transform(identity$1, identity$1),
|
|
2255
|
-
exponent = 1;
|
|
2256
|
-
|
|
2257
|
-
function rescale() {
|
|
2258
|
-
return exponent === 1 ? transform(identity$1, identity$1)
|
|
2259
|
-
: exponent === 0.5 ? transform(transformSqrt, transformSquare)
|
|
2260
|
-
: transform(transformPow(exponent), transformPow(1 / exponent));
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
scale.exponent = function(_) {
|
|
2264
|
-
return arguments.length ? (exponent = +_, rescale()) : exponent;
|
|
2265
|
-
};
|
|
2266
|
-
|
|
2267
|
-
return linearish(scale);
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
function pow() {
|
|
2271
|
-
var scale = powish(transformer());
|
|
2272
|
-
|
|
2273
|
-
scale.copy = function() {
|
|
2274
|
-
return copy(scale, pow()).exponent(scale.exponent());
|
|
2275
|
-
};
|
|
2276
|
-
|
|
2277
|
-
initRange.apply(scale, arguments);
|
|
2278
|
-
|
|
2279
|
-
return scale;
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
function sqrt() {
|
|
2283
|
-
return pow.apply(null, arguments).exponent(0.5);
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
const COLOR_DEFAULT_FILE = "#db7100";
|
|
2287
|
-
const COLOR_DEFAULT_OWN_SOURCE = "#487ea4";
|
|
2288
|
-
const COLOR_DEFAULT_VENDOR_SOURCE = "#599e59";
|
|
2289
|
-
|
|
2290
|
-
const colorDefault = (node) => {
|
|
2291
|
-
if (node.children && node.children.length) {
|
|
2292
|
-
const parents = node.ancestors();
|
|
2293
|
-
const hasNodeModules = parents.some(
|
|
2294
|
-
({ data: { name } }) => name === "node_modules"
|
|
2295
|
-
);
|
|
2296
|
-
return hasNodeModules
|
|
2297
|
-
? COLOR_DEFAULT_VENDOR_SOURCE
|
|
2298
|
-
: COLOR_DEFAULT_OWN_SOURCE;
|
|
2299
|
-
} else {
|
|
2300
|
-
return COLOR_DEFAULT_FILE;
|
|
2301
|
-
}
|
|
2302
|
-
};
|
|
2303
|
-
|
|
2304
|
-
const LABELS = {
|
|
2305
|
-
renderedLength: "Rendered",
|
|
2306
|
-
gzipLength: "Gzip",
|
|
2307
|
-
brotliLength: "Brotli",
|
|
2308
|
-
};
|
|
2309
|
-
|
|
2310
|
-
const getAvailableSizeOptions = (options = {}) => {
|
|
2311
|
-
const availableSizeProperties = ["renderedLength"];
|
|
2312
|
-
if (options.gzip) {
|
|
2313
|
-
availableSizeProperties.push("gzipLength");
|
|
2314
|
-
}
|
|
2315
|
-
if (options.brotli) {
|
|
2316
|
-
availableSizeProperties.push("brotliLength");
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
return availableSizeProperties;
|
|
2320
|
-
};
|
|
2321
|
-
|
|
2322
|
-
const Tooltip = ({ node, root, sizeProperty, availableSizeProperties }) => {
|
|
2323
|
-
const content = d(() => {
|
|
2324
|
-
if (!node) return null;
|
|
2325
|
-
|
|
2326
|
-
const mainSize = node.originalValue[sizeProperty];
|
|
2327
|
-
|
|
2328
|
-
const percentageNum = (100 * mainSize) / root.originalValue[sizeProperty];
|
|
2329
|
-
const percentage = percentageNum.toFixed(2);
|
|
2330
|
-
const percentageString = percentage + "%";
|
|
2331
|
-
|
|
2332
|
-
return m`
|
|
2333
|
-
<div class="details-name">${node.data.name}</div>
|
|
2334
|
-
<div class="details-percentage">${percentageString}</div>
|
|
2335
|
-
${availableSizeProperties.map((sizeProp) => {
|
|
2336
|
-
if (sizeProp === sizeProperty) {
|
|
2337
|
-
return m`
|
|
2338
|
-
<div class="details-size">
|
|
2339
|
-
<b
|
|
2340
|
-
>${LABELS[sizeProp]}:${" "}${format_1(
|
|
2341
|
-
node.originalValue[sizeProp]
|
|
2342
|
-
)}</b
|
|
2343
|
-
>
|
|
2344
|
-
</div>
|
|
2345
|
-
`;
|
|
2346
|
-
} else {
|
|
2347
|
-
return m`
|
|
2348
|
-
<div class="details-size">
|
|
2349
|
-
${LABELS[sizeProp]}:${" "}
|
|
2350
|
-
${format_1(node.originalValue[sizeProp])}
|
|
2351
|
-
</div>
|
|
2352
|
-
`;
|
|
2353
|
-
}
|
|
2354
|
-
})}
|
|
2355
|
-
`;
|
|
2356
|
-
}, [node]);
|
|
2357
|
-
|
|
2358
|
-
return m`
|
|
2359
|
-
<div class="details">
|
|
2360
|
-
${content}
|
|
2361
|
-
</div>
|
|
2362
|
-
`;
|
|
2363
|
-
};
|
|
2364
|
-
|
|
2365
|
-
const Node = ({
|
|
2366
|
-
node,
|
|
2367
|
-
onClick,
|
|
2368
|
-
isSelected,
|
|
2369
|
-
onNodeHover,
|
|
2370
|
-
path,
|
|
2371
|
-
highlighted,
|
|
2372
|
-
}) => {
|
|
2373
|
-
return m`
|
|
2374
|
-
<path
|
|
2375
|
-
d=${path}
|
|
2376
|
-
fill-rule="evenodd"
|
|
2377
|
-
stroke="#fff"
|
|
2378
|
-
fill=${colorDefault(node)}
|
|
2379
|
-
stroke-width=${isSelected ? 3 : null}
|
|
2380
|
-
onClick=${onClick}
|
|
2381
|
-
onMouseOver=${(evt) => {
|
|
2382
|
-
evt.stopPropagation();
|
|
2383
|
-
onNodeHover(node);
|
|
2384
|
-
}}
|
|
2385
|
-
opacity=${highlighted ? 1 : 0.3}
|
|
2386
|
-
/>
|
|
2387
|
-
`;
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
|
-
const SunBurst = ({
|
|
2391
|
-
root,
|
|
2392
|
-
layout,
|
|
2393
|
-
size,
|
|
2394
|
-
onNodeHover,
|
|
2395
|
-
arc,
|
|
2396
|
-
radius,
|
|
2397
|
-
sizeProperty,
|
|
2398
|
-
highlightedNodes,
|
|
2399
|
-
}) => {
|
|
2400
|
-
const [selectedNode, setSelectedNode] = l(null);
|
|
2401
|
-
|
|
2402
|
-
const desiredValue = root.originalValue[sizeProperty] * 0.2;
|
|
2403
|
-
|
|
2404
|
-
//handle zoom of selected node
|
|
2405
|
-
const selectedNodeMultiplier =
|
|
2406
|
-
selectedNode != null
|
|
2407
|
-
? (desiredValue > selectedNode.originalValue[sizeProperty]
|
|
2408
|
-
? desiredValue / selectedNode.originalValue[sizeProperty]
|
|
2409
|
-
: 3) * selectedNode.height
|
|
2410
|
-
: 1;
|
|
2411
|
-
|
|
2412
|
-
// i only need to increase value of leaf nodes
|
|
2413
|
-
// as folders will sum they up
|
|
2414
|
-
const nodesToIncrease =
|
|
2415
|
-
selectedNode != null
|
|
2416
|
-
? selectedNode.children != null
|
|
2417
|
-
? selectedNode.leaves()
|
|
2418
|
-
: [selectedNode]
|
|
2419
|
-
: [];
|
|
2420
|
-
|
|
2421
|
-
const nodesToIncreaseSet = new Set(nodesToIncrease);
|
|
2422
|
-
|
|
2423
|
-
// update value for nodes
|
|
2424
|
-
root = root.eachAfter((node) => {
|
|
2425
|
-
let sum = 0;
|
|
2426
|
-
const children = node.children;
|
|
2427
|
-
if (children != null) {
|
|
2428
|
-
let i = children.length;
|
|
2429
|
-
while (--i >= 0) sum += children[i].value;
|
|
2430
|
-
} else {
|
|
2431
|
-
sum = nodesToIncreaseSet.has(node)
|
|
2432
|
-
? node.originalValue[sizeProperty] * selectedNodeMultiplier
|
|
2433
|
-
: node.originalValue[sizeProperty];
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
node.value = sum;
|
|
2437
|
-
});
|
|
2438
|
-
|
|
2439
|
-
layout(root);
|
|
2440
|
-
|
|
2441
|
-
return m`
|
|
2442
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox=${`0 0 ${size} ${size}`}>
|
|
2443
|
-
<g transform=${`translate(${radius},${radius})`}>
|
|
2444
|
-
${root.descendants().map((node) => {
|
|
2445
|
-
return m`
|
|
2446
|
-
<${Node}
|
|
2447
|
-
node=${node}
|
|
2448
|
-
onClick=${() =>
|
|
2449
|
-
setSelectedNode(selectedNode === node ? null : node)}
|
|
2450
|
-
isSelected=${selectedNode === node}
|
|
2451
|
-
onNodeHover=${onNodeHover}
|
|
2452
|
-
path=${arc(node)}
|
|
2453
|
-
highlighted=${highlightedNodes.includes(node)}
|
|
2454
|
-
/>
|
|
2455
|
-
`;
|
|
2456
|
-
})}
|
|
2457
|
-
</g>
|
|
2458
|
-
</svg>
|
|
2459
|
-
`;
|
|
2460
|
-
};
|
|
2461
|
-
|
|
2462
|
-
const Chart = ({
|
|
2463
|
-
layout,
|
|
2464
|
-
root,
|
|
2465
|
-
size,
|
|
2466
|
-
sizeProperty,
|
|
2467
|
-
availableSizeProperties,
|
|
2468
|
-
}) => {
|
|
2469
|
-
const [tooltipNode, setTooltipNode] = l(root);
|
|
2470
|
-
const [highlightedNodes, setHighlightedNodes] = l(root.descendants());
|
|
2471
|
-
|
|
2472
|
-
const handleMouseOut = () => {
|
|
2473
|
-
setTooltipNode(root);
|
|
2474
|
-
setHighlightedNodes(root.descendants());
|
|
2475
|
-
};
|
|
2476
|
-
|
|
2477
|
-
y(() => {
|
|
2478
|
-
handleMouseOut();
|
|
2479
|
-
document.addEventListener("mouseover", handleMouseOut);
|
|
2480
|
-
return () => {
|
|
2481
|
-
document.removeEventListener("mouseover", handleMouseOut);
|
|
2482
|
-
};
|
|
2483
|
-
}, [root]);
|
|
2484
|
-
|
|
2485
|
-
const radius = size / 2;
|
|
2486
|
-
|
|
2487
|
-
const x = linear().range([0, 2 * Math.PI]);
|
|
2488
|
-
const y$1 = sqrt().range([0, radius]);
|
|
2489
|
-
|
|
2490
|
-
const arc = d3arc()
|
|
2491
|
-
.startAngle((d) => Math.max(0, Math.min(2 * Math.PI, x(d.x0))))
|
|
2492
|
-
.endAngle((d) => Math.max(0, Math.min(2 * Math.PI, x(d.x1))))
|
|
2493
|
-
.innerRadius((d) => y$1(d.y0))
|
|
2494
|
-
.outerRadius((d) => y$1(d.y1));
|
|
2495
|
-
|
|
2496
|
-
return m`
|
|
2497
|
-
<${SunBurst}
|
|
2498
|
-
layout=${layout}
|
|
2499
|
-
root=${root}
|
|
2500
|
-
size=${size}
|
|
2501
|
-
radius=${radius}
|
|
2502
|
-
arc=${arc}
|
|
2503
|
-
sizeProperty=${sizeProperty}
|
|
2504
|
-
availableSizeProperties=${availableSizeProperties}
|
|
2505
|
-
onNodeHover=${(node) => {
|
|
2506
|
-
setTooltipNode(node);
|
|
2507
|
-
setHighlightedNodes(node.ancestors());
|
|
2508
|
-
}}
|
|
2509
|
-
highlightedNodes=${highlightedNodes}
|
|
2510
|
-
/>
|
|
2511
|
-
<${Tooltip}
|
|
2512
|
-
node=${tooltipNode}
|
|
2513
|
-
root=${root}
|
|
2514
|
-
sizeProperty=${sizeProperty}
|
|
2515
|
-
availableSizeProperties=${availableSizeProperties}
|
|
2516
|
-
/>
|
|
2517
|
-
`;
|
|
2518
|
-
};
|
|
2519
|
-
|
|
2520
|
-
const SideBar = ({
|
|
2521
|
-
availableSizeProperties,
|
|
2522
|
-
sizeProperty,
|
|
2523
|
-
setSizeProperty,
|
|
2524
|
-
}) => {
|
|
2525
|
-
const handleChange = (sizeProp) => () => {
|
|
2526
|
-
if (sizeProp !== sizeProperty) {
|
|
2527
|
-
setSizeProperty(sizeProp);
|
|
2528
|
-
}
|
|
2529
|
-
};
|
|
2530
|
-
return m`
|
|
2531
|
-
<aside class="sidebar">
|
|
2532
|
-
<div class="size-selectors">
|
|
2533
|
-
${availableSizeProperties.length > 1 &&
|
|
2534
|
-
availableSizeProperties.map((sizeProp) => {
|
|
2535
|
-
const id = `selector-${sizeProp}`;
|
|
2536
|
-
return m`
|
|
2537
|
-
<div class="size-selector">
|
|
2538
|
-
<input
|
|
2539
|
-
type="radio"
|
|
2540
|
-
id=${id}
|
|
2541
|
-
checked=${sizeProp === sizeProperty}
|
|
2542
|
-
onChange=${handleChange(sizeProp)}
|
|
2543
|
-
/>
|
|
2544
|
-
<label for=${id}>
|
|
2545
|
-
${LABELS[sizeProp]}
|
|
2546
|
-
</label>
|
|
2547
|
-
</div>
|
|
2548
|
-
`;
|
|
2549
|
-
})}
|
|
2550
|
-
</div>
|
|
2551
|
-
</aside>
|
|
2552
|
-
`;
|
|
2553
|
-
};
|
|
2554
|
-
|
|
2555
|
-
const Main = ({ width, height, data: { tree, nodes, options = {} } }) => {
|
|
2556
|
-
const availableSizeProperties = getAvailableSizeOptions(options);
|
|
2557
|
-
|
|
2558
|
-
const [sizeProperty, setSizeProperty] = l(availableSizeProperties[0]);
|
|
2559
|
-
|
|
2560
|
-
const size = Math.min(width, height);
|
|
2561
|
-
|
|
2562
|
-
const root = hierarchy(tree)
|
|
2563
|
-
.eachAfter((node) => {
|
|
2564
|
-
const value = {};
|
|
2565
|
-
for (const prop of availableSizeProperties) {
|
|
2566
|
-
value[prop] = 0;
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
// use node.data.children because if it is empty d3 will skip this node
|
|
2570
|
-
// and it will look like it is actually a leaf - which technically it is but not exactly
|
|
2571
|
-
// it is just a chunk without deps - usually just with imports
|
|
2572
|
-
if (node.children == null && node.data.children != null) {
|
|
2573
|
-
// this should be root withiout children
|
|
2574
|
-
for (const prop of availableSizeProperties) {
|
|
2575
|
-
value[prop] += node.data[prop] || 0;
|
|
2576
|
-
}
|
|
2577
|
-
} else if (node.data.children != null) {
|
|
2578
|
-
const children = node.children;
|
|
2579
|
-
let i = node.data.children.length;
|
|
2580
|
-
while (--i >= 0) {
|
|
2581
|
-
for (const prop of availableSizeProperties) {
|
|
2582
|
-
value[prop] += children[i].originalValue[prop] || 0;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
} else {
|
|
2586
|
-
for (const prop of availableSizeProperties) {
|
|
2587
|
-
value[prop] = nodes[node.data.uid][prop] || 0;
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
|
|
2591
|
-
node.originalValue = value;
|
|
2592
|
-
node.value = value[sizeProperty];
|
|
2593
|
-
})
|
|
2594
|
-
.sort(
|
|
2595
|
-
(a, b) => b.originalValue[sizeProperty] - a.originalValue[sizeProperty]
|
|
2596
|
-
);
|
|
2597
|
-
|
|
2598
|
-
const layout = d3partition();
|
|
2599
|
-
|
|
2600
|
-
return m`
|
|
2601
|
-
<${SideBar}
|
|
2602
|
-
sizeProperty=${sizeProperty}
|
|
2603
|
-
availableSizeProperties=${availableSizeProperties}
|
|
2604
|
-
setSizeProperty=${setSizeProperty}
|
|
2605
|
-
/>
|
|
2606
|
-
<${Chart}
|
|
2607
|
-
layout=${layout}
|
|
2608
|
-
root=${root}
|
|
2609
|
-
size=${size}
|
|
2610
|
-
sizeProperty=${sizeProperty}
|
|
2611
|
-
availableSizeProperties=${availableSizeProperties}
|
|
2612
|
-
/>
|
|
2613
|
-
`;
|
|
2614
|
-
};
|
|
2615
|
-
|
|
2616
|
-
const drawChart = (parentNode, data, width, height) => {
|
|
2617
|
-
N(
|
|
2618
|
-
m` <${Main} data=${data} width=${width} height=${height} /> `,
|
|
2619
|
-
parentNode
|
|
2620
|
-
);
|
|
2621
|
-
};
|
|
2622
|
-
|
|
2623
|
-
return drawChart;
|
|
2624
|
-
|
|
2625
|
-
}());
|
|
2626
|
-
|
|
2627
|
-
/*-->*/
|
|
2628
|
-
</script>
|
|
2629
|
-
<script>
|
|
2630
|
-
/*<!--*/
|
|
2631
|
-
const data = {"version":1,"tree":{"name":"index.js","children":[{"name":"useModal.ts","uid":"c637-0"},{"name":"useRefProp.ts","uid":"c637-1"},{"name":"usePrevious.ts","uid":"c637-2"},{"name":"useEventCallback.ts","uid":"c637-3"},{"name":"useClickOne.ts","uid":"c637-4"},{"name":"useValidate.ts","uid":"c637-5"},{"name":"useRequiredModeContext.ts","uid":"c637-6"},{"name":"useField.ts","uid":"c637-7"},{"name":"useQuery.ts","uid":"c637-8"},{"name":"useArray.ts","uid":"c637-9"},{"name":"useContainer.ts","uid":"c637-10"},{"name":"useGetKey.ts","uid":"c637-11"},{"name":"useSchema.ts","uid":"c637-12"},{"name":"useTitle.ts","uid":"c637-13"},{"name":"useGlobalOption.ts","uid":"c637-14"},{"name":"useGlobalState.ts","uid":"c637-15"},{"name":"useCountryStateCityOptions.ts","uid":"c637-16"},{"name":"index.ts","uid":"c637-17"}],"renderedLength":41542,"isRoot":true},"nodes":{"c637-0":{"renderedLength":405,"id":"useModal.ts"},"c637-1":{"renderedLength":287,"id":"useRefProp.ts"},"c637-2":{"renderedLength":293,"id":"usePrevious.ts"},"c637-3":{"renderedLength":593,"id":"useEventCallback.ts"},"c637-4":{"renderedLength":431,"id":"useClickOne.ts"},"c637-5":{"renderedLength":5680,"id":"useValidate.ts"},"c637-6":{"renderedLength":368,"id":"useRequiredModeContext.ts"},"c637-7":{"renderedLength":9622,"id":"useField.ts"},"c637-8":{"renderedLength":1283,"id":"useQuery.ts"},"c637-9":{"renderedLength":1646,"id":"useArray.ts"},"c637-10":{"renderedLength":635,"id":"useContainer.ts"},"c637-11":{"renderedLength":1906,"id":"useGetKey.ts"},"c637-12":{"renderedLength":9147,"id":"useSchema.ts"},"c637-13":{"renderedLength":4121,"id":"useTitle.ts"},"c637-14":{"renderedLength":911,"id":"useGlobalOption.ts"},"c637-15":{"renderedLength":294,"id":"useGlobalState.ts"},"c637-16":{"renderedLength":2795,"id":"useCountryStateCityOptions.ts"},"c637-17":{"renderedLength":0,"isEntry":true,"id":"index.ts"},"c637-18":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/helpers/slicedToArray"},"c637-19":{"renderedLength":0,"isExternal":true,"id":"react"},"c637-20":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/helpers/toConsumableArray"},"c637-21":{"renderedLength":0,"isExternal":true,"id":"ahooks/es/useDebounceFn"},"c637-22":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/helpers/defineProperty"},"c637-23":{"renderedLength":0,"isExternal":true,"id":"immer"},"c637-24":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/helpers/typeof"},"c637-25":{"renderedLength":0,"isExternal":true,"id":"moment"},"c637-26":{"renderedLength":0,"isExternal":true,"id":"@innoways/utils"},"c637-27":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/helpers/asyncToGenerator"},"c637-28":{"renderedLength":0,"isExternal":true,"id":"@babel/runtime/regenerator"}},"links":[{"source":"c637-17","target":"c637-0"},{"source":"c637-17","target":"c637-1"},{"source":"c637-17","target":"c637-2"},{"source":"c637-17","target":"c637-3"},{"source":"c637-17","target":"c637-4"},{"source":"c637-17","target":"c637-5"},{"source":"c637-17","target":"c637-7"},{"source":"c637-17","target":"c637-8"},{"source":"c637-17","target":"c637-9"},{"source":"c637-17","target":"c637-10"},{"source":"c637-17","target":"c637-12"},{"source":"c637-17","target":"c637-11"},{"source":"c637-17","target":"c637-13"},{"source":"c637-17","target":"c637-6"},{"source":"c637-17","target":"c637-14"},{"source":"c637-17","target":"c637-15"},{"source":"c637-17","target":"c637-16"},{"source":"c637-0","target":"c637-18"},{"source":"c637-0","target":"c637-19"},{"source":"c637-1","target":"c637-19"},{"source":"c637-2","target":"c637-19"},{"source":"c637-3","target":"c637-20"},{"source":"c637-3","target":"c637-19"},{"source":"c637-4","target":"c637-19"},{"source":"c637-5","target":"c637-21"},{"source":"c637-5","target":"c637-22"},{"source":"c637-5","target":"c637-23"},{"source":"c637-7","target":"c637-21"},{"source":"c637-7","target":"c637-22"},{"source":"c637-7","target":"c637-24"},{"source":"c637-7","target":"c637-25"},{"source":"c637-7","target":"c637-23"},{"source":"c637-7","target":"c637-3"},{"source":"c637-7","target":"c637-6"},{"source":"c637-7","target":"c637-26"},{"source":"c637-8","target":"c637-22"},{"source":"c637-8","target":"c637-27"},{"source":"c637-8","target":"c637-28"},{"source":"c637-8","target":"c637-19"},{"source":"c637-9","target":"c637-22"},{"source":"c637-9","target":"c637-19"},{"source":"c637-9","target":"c637-23"},{"source":"c637-10","target":"c637-19"},{"source":"c637-12","target":"c637-22"},{"source":"c637-12","target":"c637-26"},{"source":"c637-12","target":"c637-19"},{"source":"c637-12","target":"c637-23"},{"source":"c637-12","target":"c637-11"},{"source":"c637-11","target":"c637-19"},{"source":"c637-11","target":"c637-26"},{"source":"c637-13","target":"c637-22"},{"source":"c637-13","target":"c637-18"},{"source":"c637-13","target":"c637-19"},{"source":"c637-13","target":"c637-26"},{"source":"c637-6","target":"c637-19"},{"source":"c637-14","target":"c637-19"},{"source":"c637-15","target":"c637-19"},{"source":"c637-16","target":"c637-22"},{"source":"c637-16","target":"c637-18"},{"source":"c637-16","target":"c637-26"},{"source":"c637-16","target":"c637-19"}],"env":{"rollup":"2.61.1","rollup-plugin-visualizer":"4.2.2"},"options":{"gzip":false,"brotli":false}};
|
|
2632
|
-
|
|
2633
|
-
const run = () => {
|
|
2634
|
-
const width = window.innerWidth;
|
|
2635
|
-
const height = window.innerHeight;
|
|
2636
|
-
|
|
2637
|
-
const chartNode = document.querySelector("main");
|
|
2638
|
-
drawChart(chartNode, data, width, height);
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
|
-
window.addEventListener('resize', run);
|
|
2642
|
-
|
|
2643
|
-
document.addEventListener('DOMContentLoaded', run);
|
|
2644
|
-
/*-->*/
|
|
2645
|
-
</script>
|
|
2646
|
-
</body>
|
|
2647
|
-
</html>
|
|
2648
|
-
|