chartjs-chart-graph
Version:
Chart.js module for charting graphs
3 lines (2 loc) • 36.4 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("chart.js"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["exports","chart.js","chart.js/helpers"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ChartGraphs={},t.Chart,t.Chart.helpers)}(this,(function(t,e,n){"use strict";function r(t,e,n){return{fx:(e.x-t.x)*n.tension,fy:0,tx:(t.x-e.x)*n.tension,ty:0}}function i(t,e,n){return{fx:0,fy:(e.y-t.y)*n.tension,tx:0,ty:(t.y-e.y)*n.tension}}function a(t,e,n){const r=Math.hypot(e.x-t.x,e.y-t.y)*n.tension;return{fx:Number.isNaN(t.angle)?0:Math.cos(t.angle||0)*r,fy:Number.isNaN(t.angle)?0:Math.sin(t.angle||0)*-r,tx:Number.isNaN(e.angle)?0:Math.cos(e.angle||0)*-r,ty:Number.isNaN(e.angle)?0:Math.sin(e.angle||0)*r}}class s extends e.LineElement{draw(t){const{options:e}=this;t.save(),t.lineCap=e.borderCapStyle,t.setLineDash(e.borderDash||[]),t.lineDashOffset=e.borderDashOffset,t.lineJoin=e.borderJoinStyle,t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor;const n={horizontal:r,vertical:i,radial:a},s=n[this._orientation]||n.horizontal,o=(n,r)=>{const i=s(n,r,e),a={cpx:n.x+i.fx,cpy:n.y+i.fy},o={cpx:r.x+i.tx,cpy:r.y+i.ty};if("middle"===e.stepped){const e=(n.x+r.x)/2;t.lineTo(e,n.y),t.lineTo(e,r.y),t.lineTo(r.x,r.y)}else"after"===e.stepped?(t.lineTo(n.x,r.y),t.lineTo(r.x,r.y)):e.stepped?(t.lineTo(r.x,n.y),t.lineTo(r.x,r.y)):e.tension?t.bezierCurveTo(a.cpx,a.cpy,o.cpx,o.cpy,r.x,r.y):t.lineTo(r.x,r.y);return r},l=this.source.getProps(["x","y","angle"]),h=this.target.getProps(["x","y","angle"]),u=this.getProps(["points"]).points;t.beginPath();let c=l;if(t.moveTo(c.x,c.y),u&&u.length>0&&(c=u.reduce(o,c)),o(c,h),t.stroke(),e.directed){const n=h,r=s(c,n,e),i=e.arrowHeadSize,a=e.arrowHeadOffset;if(t.save(),t.translate(n.x,h.y),"middle"===e.stepped){const e=(c.x+n.x)/2;t.rotate(Math.atan2(n.y-n.y,n.x-e))}else if("after"===e.stepped)t.rotate(Math.atan2(n.y-n.y,n.x-c.x));else if(e.stepped)t.rotate(Math.atan2(n.y-c.y,n.x-n.x));else if(e.tension){const e={x:n.x+r.tx,y:n.y+r.ty},i=.1;t.rotate(Math.atan2(n.y-e.y*(1-i)-c.y*i,n.x-e.x*(1-i)-c.x*i))}else t.rotate(Math.atan2(n.y-c.y,n.x-c.x));t.translate(-a,0),t.beginPath(),t.moveTo(0,0),t.lineTo(-i,-i/2),t.lineTo(.9*-i,0),t.lineTo(-i,i/2),t.closePath(),t.fillStyle=t.strokeStyle,t.fill(),t.restore()}t.restore()}}function o(t,e,n){return t===e?e:t+(e-t)*n}function l(t,n,r,i=[],a=[]){e.registry.addControllers(r),Array.isArray(i)?e.registry.addElements(...i):e.registry.addElements(i),Array.isArray(a)?e.registry.addScales(...a):e.registry.addScales(a);const s=n;return s.type=t,s}s.id="edgeLine",s.defaults={...e.LineElement.defaults,tension:0,directed:!1,arrowHeadSize:15,arrowHeadOffset:5},s.defaultRoutes=e.LineElement.defaultRoutes,s.descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t};class h extends e.ScatterController{constructor(){super(...arguments),this._scheduleResyncLayoutId=-1,this._edgeListener={_onDataPush:(...t)=>{const e=t.length,n=this.getDataset().edges.length-e,r=this._cachedMeta._parsedEdges;t.forEach((t=>{r.push(this._parseDefinedEdge(t))})),this._insertEdgeElements(n,e)},_onDataPop:()=>{this._cachedMeta.edges.pop(),this._cachedMeta._parsedEdges.pop(),this._scheduleResyncLayout()},_onDataShift:()=>{this._cachedMeta.edges.shift(),this._cachedMeta._parsedEdges.shift(),this._scheduleResyncLayout()},_onDataSplice:(t,e,...n)=>{if(this._cachedMeta.edges.splice(t,e),this._cachedMeta._parsedEdges.splice(t,e),n.length>0){this._cachedMeta._parsedEdges.splice(t,0,...n.map((t=>this._parseDefinedEdge(t)))),this._insertEdgeElements(t,n.length)}else this._scheduleResyncLayout()},_onDataUnshift:(...t)=>{this._cachedMeta._parsedEdges.unshift(...t.map((t=>this._parseDefinedEdge(t)))),this._insertEdgeElements(0,t.length)}}}initialize(){const t=this._type,n=e.defaults.datasets[t];this.edgeElementType=e.registry.getElement(n.edgeElementType),super.initialize(),this.enableOptionSharing=!0,this._scheduleResyncLayout()}parse(t,e){const n=this._cachedMeta,r=this._data,{iScale:i,vScale:a}=n;for(let i=0;i<e;i+=1){const e=i+t,a=r[e],s=n._parsed[e]||{};a&&"number"==typeof a.x&&(s.x=a.x),a&&"number"==typeof a.y&&(s.y=a.y),n._parsed[e]=s}n._parsed.length>r.length&&n._parsed.splice(r.length,n._parsed.length-r.length),this._cachedMeta._sorted=!1,i._dataLimitsCached=!1,a._dataLimitsCached=!1,this._parseEdges()}reset(){this.resetLayout(),super.reset()}update(t){super.update(t);const e=this._cachedMeta.edges||[];this.updateEdgeElements(e,0,t)}_destroy(){e.ScatterController.prototype._destroy.call(this),this._edges&&n.unlistenArrayEvents(this._edges,this._edgeListener),this.stopLayout()}updateEdgeElements(t,e,n){var r,i,a;const s={_cachedDataOpts:this._cachedDataOpts,dataElementType:this.dataElementType,_sharedOptions:this._sharedOptions};this._cachedDataOpts={},this.dataElementType=this.edgeElementType,this._sharedOptions=this._edgeSharedOptions;const o=this.getDataset(),l=this._cachedMeta,h=l.data,u=this._cachedMeta._parsedEdges;this.getContext(-1,!1,n),this.getDataset=()=>new Proxy(o,{get(t,e){var n;return"data"===e?null!==(n=t.edges)&&void 0!==n?n:[]:t[e]}}),this.getParsed=t=>u[t],l.data=l.edges;const c="reset"===n,d=this.resolveDataElementOptions(e,n),f={},p=null!==(r=this.getSharedOptions(d))&&void 0!==r?r:f,y=this.includeOptions(n,p),{xScale:g,yScale:x}=l,_={x:null!==(i=null==g?void 0:g.getBasePixel())&&void 0!==i?i:0,y:null!==(a=null==x?void 0:x.getBasePixel())&&void 0!==a?a:0};function m(t){var e,n;return{x:c?_.x:null!==(e=null==g?void 0:g.getPixelForValue(t.x,0))&&void 0!==e?e:0,y:c?_.y:null!==(n=null==x?void 0:x.getPixelForValue(t.y,0))&&void 0!==n?n:0,angle:t.angle}}for(let r=0;r<t.length;r+=1){const i=t[r],a=e+r,s=u[a],o={source:h[s.source],target:h[s.target],points:Array.isArray(s.points)?s.points.map((t=>m(t))):[]};o.points._source=h[s.source],y&&(o.options=p!==f?p:this.resolveDataElementOptions(a,n)),this.updateEdgeElement(i,a,o,n)}this.updateSharedOptions(p,n,d),this._edgeSharedOptions=this._sharedOptions,Object.assign(this,s),delete this.getDataset,delete this.getParsed,l.data=h}updateEdgeElement(t,e,n,r){super.updateElement(t,e,n,r)}updateElement(t,e,n,r){var i;if("reset"===r){const{xScale:t}=this._cachedMeta;n.x=null!==(i=null==t?void 0:t.getBasePixel())&&void 0!==i?i:0}super.updateElement(t,e,n,r)}resolveNodeIndex(t,e){if("number"==typeof e)return e;if("string"==typeof e){return this.chart.data.labels.indexOf(e)}const n=t.indexOf(e);if(n>=0)return n;const r=this.getDataset().data.indexOf(e);return r>=0?r:(console.warn("cannot resolve edge ref",e),-1)}buildOrUpdateElements(){const t=this.getDataset().edges||[];this._edges!==t&&(this._edges&&n.unlistenArrayEvents(this._edges,this._edgeListener),t&&Object.isExtensible(t)&&n.listenArrayEvents(t,this._edgeListener),this._edges=t),super.buildOrUpdateElements()}draw(){const t=this._cachedMeta,e=this._cachedMeta.edges||[],r=t.data||[],i=this.chart.chartArea,a=this._ctx;e.length>0&&(n.clipArea(a,i),e.forEach((t=>t.draw.call(t,a,i))),n.unclipArea(a)),r.forEach((t=>t.draw.call(t,a,i)))}_resyncElements(){e.ScatterController.prototype._resyncElements.call(this);const t=this._cachedMeta,n=t._parsedEdges,r=t.edges||(t.edges=[]),i=r.length,a=n.length;a<i?(r.splice(a,i-a),this._scheduleResyncLayout()):a>i&&this._insertEdgeElements(i,a-i)}getTreeRootIndex(){const t=this.getDataset(),e=t.data;if(t.derivedEdges)return e.findIndex((t=>null==t.parent));const n=this._cachedMeta._parsedEdges||[],r=new Set(e.map(((t,e)=>e)));return n.forEach((t=>{r.delete(t.target)})),Array.from(r)[0]}getTreeRoot(){const t=this.getTreeRootIndex(),e=this.getParsed(t);return e.index=t,e}getTreeChildren(t){var e;const n=this._cachedMeta._parsedEdges,r=null!==(e=t.index)&&void 0!==e?e:0;return n.filter((t=>t.source===r)).map((t=>{const e=this.getParsed(t.target);return e.index=t.target,e}))}_parseDefinedEdge(t){const e=this.getDataset(),{data:n}=e;return{source:this.resolveNodeIndex(n,t.source),target:this.resolveNodeIndex(n,t.target),points:[]}}_parseEdges(){const t=this.getDataset(),e=t.data,n=this._cachedMeta;if(t.edges){const e=t.edges.map((t=>this._parseDefinedEdge(t)));return n._parsedEdges=e,e}const r=[];return n._parsedEdges=r,e.forEach(((t,n)=>{if(null!=t.parent){const i=this.resolveNodeIndex(e,t.parent);r.push({source:i,target:n,points:[]})}})),r}addElements(){super.addElements();const t=this._cachedMeta,e=this._parseEdges(),n=new Array(e.length);t.edges=n;for(let t=0;t<e.length;t+=1)n[t]=new this.edgeElementType}_resyncEdgeElements(){const t=this._cachedMeta,e=this._parseEdges(),n=t.edges||(t.edges=[]);for(let t=0;t<e.length;t+=1)n[t]=n[t]||new this.edgeElementType;e.length<n.length&&n.splice(e.length,n.length)}_insertElements(t,n){e.ScatterController.prototype._insertElements.call(this,t,n),n>0&&this._resyncEdgeElements()}_removeElements(t,n){e.ScatterController.prototype._removeElements.call(this,t,n),n>0&&this._resyncEdgeElements()}_insertEdgeElements(t,e){const n=[];for(let t=0;t<e;t+=1)n.push(new this.edgeElementType);this._cachedMeta.edges.splice(t,0,...n),this.updateEdgeElements(n,t,"reset"),this._scheduleResyncLayout()}reLayout(){}resetLayout(){}stopLayout(){}_scheduleResyncLayout(){null!=this._scheduleResyncLayoutId&&this._scheduleResyncLayoutId>=0||(this._scheduleResyncLayoutId=requestAnimationFrame((()=>{this._scheduleResyncLayoutId=-1,this.resyncLayout()})))}resyncLayout(){}}h.id="graph",h.defaults=n.merge({},[e.ScatterController.defaults,{clip:10,animations:{points:{fn:function(t,e,n){return Array.isArray(t)&&Array.isArray(e)&&e.length>0?e.map(((e,r)=>function(t,e,n,r){const i=t[e]||t[e-1]||t._source;return i?{x:o(i.x,n.x,r),y:o(i.y,n.y,r),angle:Number.isNaN(i.angle)?o(i.angle,n.angle,r):void 0}:n}(t,r,e,n))):e},properties:["points"]}},edgeElementType:s.id}]),h.overrides=n.merge({},[e.ScatterController.overrides,{layout:{padding:10},scales:{x:{display:!1,ticks:{maxTicksLimit:2,precision:100,minRotation:0,maxRotation:0}},y:{display:!1,ticks:{maxTicksLimit:2,precision:100,minRotation:0,maxRotation:0}}},plugins:{tooltip:{callbacks:{label(t){var e,n;return null===(n=null===(e=t.chart.data)||void 0===e?void 0:e.labels)||void 0===n?void 0:n[t.dataIndex]}}}}}]);class u extends e.Chart{constructor(t,n){super(t,l("graph",n,h,[s,e.PointElement],e.LinearScale))}}function c(t,e){var n,r=1;function i(){var i,a,s=n.length,o=0,l=0;for(i=0;i<s;++i)o+=(a=n[i]).x,l+=a.y;for(o=(o/s-t)*r,l=(l/s-e)*r,i=0;i<s;++i)(a=n[i]).x-=o,a.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function d(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,a,s,o,l,h,u,c,d,f=t._root,p={data:r},y=t._x0,g=t._y0,x=t._x1,_=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((h=e>=(a=(y+x)/2))?y=a:x=a,(u=n>=(s=(g+_)/2))?g=s:_=s,i=f,!(f=f[c=u<<1|h]))return i[c]=p,t;if(o=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===o&&n===l)return p.next=f,i?i[c]=p:t._root=p,t;do{i=i?i[c]=new Array(4):t._root=new Array(4),(h=e>=(a=(y+x)/2))?y=a:x=a,(u=n>=(s=(g+_)/2))?g=s:_=s}while((c=u<<1|h)==(d=(l>=s)<<1|o>=a));return i[d]=f,i[c]=p,t}function f(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function p(t){return t[0]}function y(t){return t[1]}function g(t,e,n){var r=new x(null==e?p:e,null==n?y:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function x(t,e,n,r,i,a){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function _(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}u.id=h.id;var m=g.prototype=x.prototype;function v(t){return function(){return t}}function E(t){return 1e-6*(t()-.5)}function w(t){return t.x+t.vx}function N(t){return t.y+t.vy}function M(t){var e,n,r,i=1,a=1;function s(){for(var t,s,l,h,u,c,d,f=e.length,p=0;p<a;++p)for(s=g(e,w,N).visitAfter(o),t=0;t<f;++t)l=e[t],c=n[l.index],d=c*c,h=l.x+l.vx,u=l.y+l.vy,s.visit(y);function y(t,e,n,a,s){var o=t.data,f=t.r,p=c+f;if(!o)return e>h+p||a<h-p||n>u+p||s<u-p;if(o.index>l.index){var y=h-o.x-o.vx,g=u-o.y-o.vy,x=y*y+g*g;x<p*p&&(0===y&&(x+=(y=E(r))*y),0===g&&(x+=(g=E(r))*g),x=(p-(x=Math.sqrt(x)))/x*i,l.vx+=(y*=x)*(p=(f*=f)/(d+f)),l.vy+=(g*=x)*p,o.vx-=y*(p=1-p),o.vy-=g*p)}}}function o(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,a=e.length;for(n=new Array(a),r=0;r<a;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=v(null==t?1:+t)),s.initialize=function(t,n){e=t,r=n,l()},s.iterations=function(t){return arguments.length?(a=+t,s):a},s.strength=function(t){return arguments.length?(i=+t,s):i},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),l(),s):t},s}function A(t){return t.index}function T(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function b(t){var e,n,r,i,a,s,o=A,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},h=v(30),u=1;function c(r){for(var i=0,o=t.length;i<u;++i)for(var l,h,c,d,f,p,y,g=0;g<o;++g)h=(l=t[g]).source,d=(c=l.target).x+c.vx-h.x-h.vx||E(s),f=c.y+c.vy-h.y-h.vy||E(s),d*=p=((p=Math.sqrt(d*d+f*f))-n[g])/p*r*e[g],f*=p,c.vx-=d*(y=a[g]),c.vy-=f*y,h.vx+=d*(y=1-y),h.vy+=f*y}function d(){if(r){var s,l,h=r.length,u=t.length,c=new Map(r.map(((t,e)=>[o(t,e,r),t])));for(s=0,i=new Array(h);s<u;++s)(l=t[s]).index=s,"object"!=typeof l.source&&(l.source=T(c,l.source)),"object"!=typeof l.target&&(l.target=T(c,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(s=0,a=new Array(u);s<u;++s)l=t[s],a[s]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(u),f(),n=new Array(u),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+h(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){r=t,s=e,d()},c.links=function(e){return arguments.length?(t=e,d(),c):t},c.id=function(t){return arguments.length?(o=t,c):o},c.iterations=function(t){return arguments.length?(u=+t,c):u},c.strength=function(t){return arguments.length?(l="function"==typeof t?t:v(+t),f(),c):l},c.distance=function(t){return arguments.length?(h="function"==typeof t?t:v(+t),p(),c):h},c}m.copy=function(){var t,e,n=new x(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=_(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=_(e));return n},m.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return d(this.cover(e,n),e,n,t)},m.addAll=function(t){var e,n,r,i,a=t.length,s=new Array(a),o=new Array(a),l=1/0,h=1/0,u=-1/0,c=-1/0;for(n=0;n<a;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(s[n]=r,o[n]=i,r<l&&(l=r),r>u&&(u=r),i<h&&(h=i),i>c&&(c=i));if(l>u||h>c)return this;for(this.cover(l,h).cover(u,c),n=0;n<a;++n)d(this,s[n],o[n],t[n]);return this},m.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,a=(r=Math.floor(e))+1;else{for(var s,o,l=i-n||1,h=this._root;n>t||t>=i||r>e||e>=a;)switch(o=(e<r)<<1|t<n,(s=new Array(4))[o]=h,h=s,l*=2,o){case 0:i=n+l,a=r+l;break;case 1:n=i-l,a=r+l;break;case 2:i=n+l,r=a-l;break;case 3:n=i-l,r=a-l}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this},m.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},m.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},m.find=function(t,e,n){var r,i,a,s,o,l,h,u=this._x0,c=this._y0,d=this._x1,p=this._y1,y=[],g=this._root;for(g&&y.push(new f(g,u,c,d,p)),null==n?n=1/0:(u=t-n,c=e-n,d=t+n,p=e+n,n*=n);l=y.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(a=l.y0)>p||(s=l.x1)<u||(o=l.y1)<c))if(g.length){var x=(i+s)/2,_=(a+o)/2;y.push(new f(g[3],x,_,s,o),new f(g[2],i,_,x,o),new f(g[1],x,a,s,_),new f(g[0],i,a,x,_)),(h=(e>=_)<<1|t>=x)&&(l=y[y.length-1],y[y.length-1]=y[y.length-1-h],y[y.length-1-h]=l)}else{var m=t-+this._x.call(null,g.data),v=e-+this._y.call(null,g.data),E=m*m+v*v;if(E<n){var w=Math.sqrt(n=E);u=t-w,c=e-w,d=t+w,p=e+w,r=g.data}}return r},m.remove=function(t){if(isNaN(a=+this._x.call(null,t))||isNaN(s=+this._y.call(null,t)))return this;var e,n,r,i,a,s,o,l,h,u,c,d,f=this._root,p=this._x0,y=this._y0,g=this._x1,x=this._y1;if(!f)return this;if(f.length)for(;;){if((h=a>=(o=(p+g)/2))?p=o:g=o,(u=s>=(l=(y+x)/2))?y=l:x=l,e=f,!(f=f[c=u<<1|h]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(n=e,d=c)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[c]=i:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},m.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},m.root=function(){return this._root},m.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},m.visit=function(t){var e,n,r,i,a,s,o=[],l=this._root;for(l&&o.push(new f(l,this._x0,this._y0,this._x1,this._y1));e=o.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,a=e.x1,s=e.y1)&&l.length){var h=(r+a)/2,u=(i+s)/2;(n=l[3])&&o.push(new f(n,h,u,a,s)),(n=l[2])&&o.push(new f(n,r,u,h,s)),(n=l[1])&&o.push(new f(n,h,i,a,u)),(n=l[0])&&o.push(new f(n,r,i,h,u))}return this},m.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new f(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var a,s=e.x0,o=e.y0,l=e.x1,h=e.y1,u=(s+l)/2,c=(o+h)/2;(a=i[0])&&n.push(new f(a,s,o,u,c)),(a=i[1])&&n.push(new f(a,u,o,l,c)),(a=i[2])&&n.push(new f(a,s,c,u,h)),(a=i[3])&&n.push(new f(a,u,c,l,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},m.x=function(t){return arguments.length?(this._x=t,this):this._x},m.y=function(t){return arguments.length?(this._y=t,this):this._y};var L={value:()=>{}};function z(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new D(r)}function D(t){this._=t}function S(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function I(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=L,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}D.prototype=z.prototype={constructor:D,on:function(t,e){var n,r,i=this._,a=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),s=-1,o=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<o;)if(n=(t=a[s]).type)i[n]=I(i[n],t.name,e);else if(null==e)for(n in i)i[n]=I(i[n],t.name,null);return this}for(;++s<o;)if((n=(t=a[s]).type)&&(n=S(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new D(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var O,P,C=0,k=0,R=0,q=0,j=0,F=0,B="object"==typeof performance&&performance.now?performance:Date,Y="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function G(){return j||(Y(X),j=B.now()+F)}function X(){j=0}function V(){this._call=this._time=this._next=null}function H(t,e,n){var r=new V;return r.restart(t,e,n),r}function U(){j=(q=B.now())+F,C=k=0;try{!function(){G(),++C;for(var t,e=O;e;)(t=j-e._time)>=0&&e._call.call(void 0,t),e=e._next;--C}()}finally{C=0,function(){var t,e,n=O,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:O=e);P=t,J(r)}(),j=0}}function W(){var t=B.now(),e=t-q;e>1e3&&(F-=e,q=t)}function J(t){C||(k&&(k=clearTimeout(k)),t-j>24?(t<1/0&&(k=setTimeout(U,t-B.now()-F)),R&&(R=clearInterval(R))):(R||(q=B.now(),R=setInterval(W,1e3)),C=1,Y(U)))}V.prototype=H.prototype={constructor:V,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?G():+n)+(null==e?0:+e),this._next||P===this||(P?P._next=this:O=this,P=this),this._call=t,this._time=n,J()},stop:function(){this._call&&(this._call=null,this._time=1/0,J())}};const K=4294967296;function Q(t){return t.x}function Z(t){return t.y}var $=Math.PI*(3-Math.sqrt(5));function tt(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),a=0,s=.6,o=new Map,l=H(c),h=z("tick","end"),u=function(){let t=1;return()=>(t=(1664525*t+1013904223)%K)/K}();function c(){d(),h.call("tick",e),n<r&&(l.stop(),h.call("end",e))}function d(r){var l,h,u=t.length;void 0===r&&(r=1);for(var c=0;c<r;++c)for(n+=(a-n)*i,o.forEach((function(t){t(n)})),l=0;l<u;++l)null==(h=t[l]).fx?h.x+=h.vx*=s:(h.x=h.fx,h.vx=0),null==h.fy?h.y+=h.vy*=s:(h.y=h.fy,h.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),a=n*$;e.x=i*Math.cos(a),e.y=i*Math.sin(a)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(c),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),o.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(a=+t,e):a},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(u=t,o.forEach(p),e):u},force:function(t,n){return arguments.length>1?(null==n?o.delete(t):o.set(t,p(n)),e):o.get(t)},find:function(e,n,r){var i,a,s,o,l,h=0,u=t.length;for(null==r?r=1/0:r*=r,h=0;h<u;++h)(s=(i=e-(o=t[h]).x)*i+(a=n-o.y)*a)<r&&(l=o,r=s);return l},on:function(t,n){return arguments.length>1?(h.on(t,n),e):h.on(t)}}}function et(){var t,e,n,r,i,a=v(-30),s=1,o=1/0,l=.81;function h(n){var i,a=t.length,s=g(t,Q,Z).visitAfter(c);for(r=n,i=0;i<a;++i)e=t[i],s.visit(d)}function u(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+a(n,e,t)}}function c(t){var e,n,r,a,s,o=0,l=0;if(t.length){for(r=a=s=0;s<4;++s)(e=t[s])&&(n=Math.abs(e.value))&&(o+=e.value,l+=n,r+=n*e.x,a+=n*e.y);t.x=r/l,t.y=a/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{o+=i[e.data.index]}while(e=e.next)}t.value=o}function d(t,a,h,u){if(!t.value)return!0;var c=t.x-e.x,d=t.y-e.y,f=u-a,p=c*c+d*d;if(f*f/l<p)return p<o&&(0===c&&(p+=(c=E(n))*c),0===d&&(p+=(d=E(n))*d),p<s&&(p=Math.sqrt(s*p)),e.vx+=c*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=o)){(t.data!==e||t.next)&&(0===c&&(p+=(c=E(n))*c),0===d&&(p+=(d=E(n))*d),p<s&&(p=Math.sqrt(s*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=c*f,e.vy+=d*f)}while(t=t.next)}}return h.initialize=function(e,r){t=e,n=r,u()},h.strength=function(t){return arguments.length?(a="function"==typeof t?t:v(+t),u(),h):a},h.distanceMin=function(t){return arguments.length?(s=t*t,h):Math.sqrt(s)},h.distanceMax=function(t){return arguments.length?(o=t*t,h):Math.sqrt(o)},h.theta=function(t){return arguments.length?(l=t*t,h):Math.sqrt(l)},h}function nt(t,e,n){var r,i,a,s=v(.1);function o(t){for(var s=0,o=r.length;s<o;++s){var l=r[s],h=l.x-e||1e-6,u=l.y-n||1e-6,c=Math.sqrt(h*h+u*u),d=(a[s]-c)*i[s]*t/c;l.vx+=h*d,l.vy+=u*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),a=new Array(n),e=0;e<n;++e)a[e]=+t(r[e],e,r),i[e]=isNaN(a[e])?0:+s(r[e],e,r)}}return"function"!=typeof t&&(t=v(+t)),null==e&&(e=0),null==n&&(n=0),o.initialize=function(t){r=t,l()},o.strength=function(t){return arguments.length?(s="function"==typeof t?t:v(+t),l(),o):s},o.radius=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),l(),o):t},o.x=function(t){return arguments.length?(e=+t,o):e},o.y=function(t){return arguments.length?(n=+t,o):n},o}function rt(t){var e,n,r,i=v(.1);function a(t){for(var i,a=0,s=e.length;a<s;++a)(i=e[a]).vx+=(r[a]-i.x)*n[a]*t}function s(){if(e){var a,s=e.length;for(n=new Array(s),r=new Array(s),a=0;a<s;++a)n[a]=isNaN(r[a]=+t(e[a],a,e))?0:+i(e[a],a,e)}}return"function"!=typeof t&&(t=v(null==t?0:+t)),a.initialize=function(t){e=t,s()},a.strength=function(t){return arguments.length?(i="function"==typeof t?t:v(+t),s(),a):i},a.x=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),s(),a):t},a}function it(t){var e,n,r,i=v(.1);function a(t){for(var i,a=0,s=e.length;a<s;++a)(i=e[a]).vy+=(r[a]-i.y)*n[a]*t}function s(){if(e){var a,s=e.length;for(n=new Array(s),r=new Array(s),a=0;a<s;++a)n[a]=isNaN(r[a]=+t(e[a],a,e))?0:+i(e[a],a,e)}}return"function"!=typeof t&&(t=v(null==t?0:+t)),a.initialize=function(t){e=t,s()},a.strength=function(t){return arguments.length?(i="function"==typeof t?t:v(+t),s(),a):i},a.y=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),s(),a):t},a}class at extends h{constructor(t,e){super(t,e),this._animTimer=-1,this._simulation=tt().on("tick",(()=>{this.chart.canvas&&-2!==this._animTimer?(this._copyPosition(),this.chart.render()):this._simulation.stop()})).on("end",(()=>{this.chart.canvas&&-2!==this._animTimer&&(this._copyPosition(),this.chart.render(),this.chart.update("default"))}));const n=this.options.simulation,r={center:c,collide:M,link:b,manyBody:et,x:rt,y:it,radial:nt};Object.keys(r).forEach((t=>{const e=n.forces[t];if(!e)return;const i=r[t]();"boolean"!=typeof e&&Object.keys(e).forEach((t=>{i[t](e[t])})),this._simulation.force(t,i)})),this._simulation.stop()}_destroy(){return this._animTimer>=0&&cancelAnimationFrame(this._animTimer),this._animTimer=-2,super._destroy()}_copyPosition(){const t=this._cachedMeta._parsed,e=t.reduce(((t,e)=>{const n=e._sim;return n&&null!=n.x&&null!=n.y?(n.x<t.minX&&(t.minX=n.x),n.x>t.maxX&&(t.maxX=n.x),n.y<t.minY&&(t.minY=n.y),n.y>t.maxY&&(t.maxY=n.y),t):t}),{minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY});t.forEach((t=>{var n,r;t._sim&&(t.x=((null!==(n=t._sim.x)&&void 0!==n?n:0)-e.minX)/(e.maxX-e.minX)*2-1,t.y=(t=>(t-e.minY)/(e.maxY-e.minY)*2-1)(null!==(r=t._sim.y)&&void 0!==r?r:0))}));const{xScale:n,yScale:r}=this._cachedMeta;this._cachedMeta.data.forEach(((e,i)=>{var a,s;const o=t[i];Object.assign(e,{x:null!==(a=null==n?void 0:n.getPixelForValue(o.x,i))&&void 0!==a?a:0,y:null!==(s=null==r?void 0:r.getPixelForValue(o.y,i))&&void 0!==s?s:0,skip:!1})}))}resetLayout(){super.resetLayout(),this._simulation.stop();const t=this._cachedMeta._parsed.map(((t,e)=>{const n={...t};return n.index=e,t._sim=n,t.reset?(delete n.x,delete n.y,delete n.vx,delete n.vy,n):n}));this._simulation.nodes(t),this._simulation.alpha(1).restart()}resyncLayout(){super.resyncLayout(),this._simulation.stop();const t=this._cachedMeta,e=t._parsed.map(((t,e)=>{const n={...t};return n.index=e,t._sim=n,null===n.x&&delete n.x,null===n.y&&delete n.y,null==n.x&&null==n.y&&(t.reset=!0),n})),n=this._simulation.force("link");if(n&&n.links([]),this._simulation.nodes(e),n&&n.links((t._parsedEdges||[]).map((t=>({...t})))),this.options.simulation.initialIterations>0){if(this._simulation.alpha(1),this._simulation.tick(this.options.simulation.initialIterations),this._copyPosition(),this.options.simulation.autoRestart)this._simulation.restart();else if(null!=this.chart.canvas&&-2!==this._animTimer){const t=this.chart;this._animTimer=requestAnimationFrame((()=>{t.canvas&&t.update()}))}}else this.options.simulation.autoRestart&&null!=this.chart.canvas&&-2!==this._animTimer&&this._simulation.alpha(1).restart()}reLayout(){this._simulation.alpha(1).restart()}stopLayout(){super.stopLayout(),this._simulation.stop()}}at.id="forceDirectedGraph",at.defaults=n.merge({},[h.defaults,{animation:!1,simulation:{initialIterations:0,autoRestart:!0,forces:{center:!0,collide:!1,link:!0,manyBody:!0,x:!1,y:!1,radial:!1}}}]),at.overrides=n.merge({},[h.overrides,{scales:{x:{min:-1,max:1},y:{min:-1,max:1}}}]);class st extends e.Chart{constructor(t,n){super(t,l("forceDirectedGraph",n,at,[s,e.PointElement],e.LinearScale))}}function ot(t,e){return t.parent===e.parent?1:2}function lt(t,e){return t+e.x}function ht(t,e){return Math.max(t,e.y)}function ut(){var t=ot,e=1,n=1,r=!1;function i(i){var a,s=0;i.eachAfter((function(e){var n=e.children;n?(e.x=function(t){return t.reduce(lt,0)/t.length}(n),e.y=function(t){return 1+t.reduce(ht,0)}(n)):(e.x=a?s+=t(e,a):0,e.y=0,a=e)}));var o=function(t){for(var e;e=t.children;)t=e[0];return t}(i),l=function(t){for(var e;e=t.children;)t=e[e.length-1];return t}(i),h=o.x-t(o,l)/2,u=l.x+t(l,o)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n}:function(t){t.x=(t.x-h)/(u-h)*e,t.y=(1-(i.y?t.y/i.y:1))*n})}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function ct(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function dt(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=pt)):void 0===e&&(e=ft);for(var n,r,i,a,s,o=new xt(t),l=[o];n=l.pop();)if((i=e(n.data))&&(s=(i=Array.from(i)).length))for(n.children=i,a=s-1;a>=0;--a)l.push(r=i[a]=new xt(i[a])),r.parent=n,r.depth=n.depth+1;return o.eachBefore(gt)}function ft(t){return t.children}function pt(t){return Array.isArray(t)?t[1]:null}function yt(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function gt(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function xt(t){this.data=t,this.depth=this.height=0,this.parent=null}function _t(t,e){return t.parent===e.parent?1:2}function mt(t){var e=t.children;return e?e[0]:t.t}function vt(t){var e=t.children;return e?e[e.length-1]:t.t}function Et(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function wt(t,e,n){return t.a.parent===e.parent?t.a:n}function Nt(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}function Mt(){var t=_t,e=1,n=1,r=null;function i(i){var l=function(t){for(var e,n,r,i,a,s=new Nt(t,0),o=[s];e=o.pop();)if(r=e._.children)for(e.children=new Array(a=r.length),i=a-1;i>=0;--i)o.push(n=e.children[i]=new Nt(r[i],i)),n.parent=e;return(s.parent=new Nt(null,0)).children=[s],s}(i);if(l.eachAfter(a),l.parent.m=-l.z,l.eachBefore(s),r)i.eachBefore(o);else{var h=i,u=i,c=i;i.eachBefore((function(t){t.x<h.x&&(h=t),t.x>u.x&&(u=t),t.depth>c.depth&&(c=t)}));var d=h===u?1:t(h,u)/2,f=d-h.x,p=e/(u.x+d+f),y=n/(c.depth||1);i.eachBefore((function(t){t.x=(t.x+f)*p,t.y=t.depth*y}))}return i}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,a=i.length;--a>=0;)(e=i[a]).z+=n,e.m+=n,n+=e.s+(r+=e.c)}(e);var a=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-a):e.z=a}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,a=e,s=e,o=n,l=a.parent.children[0],h=a.m,u=s.m,c=o.m,d=l.m;o=vt(o),a=mt(a),o&&a;)l=mt(l),(s=vt(s)).a=e,(i=o.z+c-a.z-h+t(o._,a._))>0&&(Et(wt(o,e,r),e,i),h+=i,u+=i),c+=o.m,h+=a.m,d+=l.m,u+=s.m;o&&!vt(s)&&(s.t=o,s.m+=c-u),a&&!mt(l)&&(l.t=a,l.m+=h-d,r=e)}return r}(e,i,e.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function o(t){t.x*=e,t.y=t.depth*n}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}st.id=at.id,xt.prototype=dt.prototype={constructor:xt,count:function(){return this.eachAfter(ct)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,a=this,s=[a],o=[],l=-1;a=s.pop();)if(o.push(a),n=a.children)for(r=0,i=n.length;r<i;++r)s.push(n[r]);for(;a=o.pop();)t.call(e,a,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,a=[i],s=-1;i=a.pop();)if(t.call(e,i,++s,this),n=i.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return dt(this).eachBefore(yt)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,a=[i];do{for(t=a.reverse(),a=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n])}while(a.length)}},Nt.prototype=Object.create(xt.prototype);class At extends h{constructor(){super(...arguments),this._animTimer=-1}updateEdgeElement(t,e,n,r){n._orientation=this.options.tree.orientation,super.updateEdgeElement(t,e,n,r)}_destroy(){return this._animTimer>=0&&cancelAnimationFrame(this._animTimer),this._animTimer=-2,super._destroy()}updateElement(t,e,n,r){null!=e&&(n.angle=this.getParsed(e).angle),super.updateElement(t,e,n,r)}resyncLayout(){const t=this._cachedMeta;t.root=dt(this.getTreeRoot(),(t=>this.getTreeChildren(t))).count().sort(((t,e)=>{var n,r;return e.height-t.height||(null!==(n=e.data.index)&&void 0!==n?n:0)-(null!==(r=t.data.index)&&void 0!==r?r:0)})),this.doLayout(t.root),super.resyncLayout()}reLayout(t={}){if(t){Object.assign(this.options.tree,t);const e=this.getDataset();e.tree?Object.assign(e.tree,t):e.tree=t}this.doLayout(this._cachedMeta.root)}doLayout(t){const e=this.options.tree,n="tree"===e.mode?Mt():ut();"radial"===e.orientation?n.size([2*Math.PI,1]):n.size([2,2]);const r={horizontal:t=>{t.data.x=t.y-1,t.data.y=1-t.x},vertical:t=>{t.data.x=t.x-1,t.data.y=1-t.y},radial:t=>{t.data.x=Math.cos(t.x)*t.y,t.data.y=Math.sin(t.x)*t.y,t.data.angle=0===t.y?Number.NaN:t.x}};n(t).each(r[e.orientation]||r.horizontal);const i=this.chart;-2!==this._animTimer&&(this._animTimer=requestAnimationFrame((()=>{i.canvas&&i.update()})))}}At.id="dendrogram",At.defaults=n.merge({},[h.defaults,{tree:{mode:"dendrogram",orientation:"horizontal"},animations:{numbers:{type:"number",properties:["x","y","angle","radius","rotation","borderWidth"]}},tension:.4}]),At.overrides=n.merge({},[h.overrides,{scales:{x:{min:-1,max:1},y:{min:-1,max:1}}}]);class Tt extends e.Chart{constructor(t,n){super(t,l("dendrogram",n,At,[s,e.PointElement],e.LinearScale))}}Tt.id=At.id;class bt extends At{}bt.id="dendogram",bt.defaults=n.merge({},[At.defaults,{tree:{mode:"dendrogram"}}]);const Lt=Tt;class zt extends At{}zt.id="tree",zt.defaults=n.merge({},[At.defaults,{tree:{mode:"tree"}}]),zt.overrides=At.overrides;class Dt extends e.Chart{constructor(t,n){super(t,l("tree",n,zt,[s,e.PointElement],e.LinearScale))}}Dt.id=zt.id,e.registry.addControllers(At,bt,at,h,zt),e.registry.addElements(s),t.DendogramChart=Lt,t.DendogramController=bt,t.DendrogramChart=Tt,t.DendrogramController=At,t.EdgeLine=s,t.ForceDirectedGraphChart=st,t.ForceDirectedGraphController=at,t.GraphChart=u,t.GraphController=h,t.TreeChart=Dt,t.TreeController=zt}));
//# sourceMappingURL=index.umd.min.js.map