gwt.material.design.amplugin.venn.client.resources.js.venn.js Maven / Gradle / Ivy
Show all versions of gwt-material-am4charts
/**
* @license
* Copyright (c) 2018 amCharts (Antanas Marcelionis, Martynas Majeris)
*
* This sofware is provided under multiple licenses. Please see below for
* links to appropriate usage.
*
* Free amCharts linkware license. Details and conditions:
* https://github.com/amcharts/amcharts4/blob/master/LICENSE
*
* One of the amCharts commercial licenses. Details and pricing:
* https://www.amcharts.com/online-store/
* https://www.amcharts.com/online-store/licenses-explained/
*
* If in doubt, contact amCharts at [email protected]
*
* PLEASE DO NOT REMOVE THIS COPYRIGHT NOTICE.
* @hidden
*/
am4internal_webpackJsonp(["7005"],{"1Zf7":function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("Gq40"),i=e("XqN8"),a=e("bS9u"),o=Object(i.a)("start","end","cancel","interrupt"),u=[],s=0,l=1,c=2,h=3,f=4,p=5,d=6,v=function(t,n,e,r,i,v){var g=t.__transition;if(g){if(e in g)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(p){var v,g,y,m;if(e.state!==l)return s();for(v in i)if((m=i[v]).name===e.name){if(m.state===h)return Object(a.b)(o);m.state===f?(m.state=d,m.timer.stop(),m.on.call("interrupt",t,t.__data__,m.index,m.group),delete i[v]):+vs)throw new Error("too late; already scheduled");return e}function y(t,n){var e=m(t,n);if(e.state>h)throw new Error("too late; already running");return e}function m(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}var x=function(t,n){var e,r,i,a=t.__transition,o=!0;if(a){for(i in n=null==n?null:n+"",a)(e=a[i]).name===n?(r=e.state>c&&e.state>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?new H(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?new H(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=k.exec(t))?new H(n[1],n[2],n[3],1):(n=S.exec(t))?new H(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=P.exec(t))?q(n[1],n[2],n[3],n[4]):(n=E.exec(t))?q(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=z.exec(t))?Y(n[1],n[2]/100,n[3]/100,1):(n=O.exec(t))?Y(n[1],n[2]/100,n[3]/100,n[4]):D.hasOwnProperty(t)?T(D[t]):"transparent"===t?new H(NaN,NaN,NaN,0):null}function T(t){return new H(t>>16&255,t>>8&255,255&t,1)}function q(t,n,e,r){return r<=0&&(t=n=e=NaN),new H(t,n,e,r)}function V(t){return t instanceof b||(t=C(t)),t?new H((t=t.rgb()).r,t.g,t.b,t.opacity):new H}function L(t,n,e,r){return 1===arguments.length?V(t):new H(t,n,e,null==r?1:r)}function H(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function X(){return"#"+B(this.r)+B(this.g)+B(this.b)}function F(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function B(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Y(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new U(t,n,e,r)}function G(t){if(t instanceof U)return new U(t.h,t.s,t.l,t.opacity);if(t instanceof b||(t=C(t)),!t)return new U;if(t instanceof U)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),a=Math.max(n,e,r),o=NaN,u=a-i,s=(a+i)/2;return u?(o=n===a?(e-r)/u+6*(e0&&s<1?0:o,new U(o,u,s,t.opacity)}function $(t,n,e,r){return 1===arguments.length?G(t):new U(t,n,e,null==r?1:r)}function U(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Z(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}w(b,C,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:R,formatHex:R,formatHsl:function(){return G(this).formatHsl()},formatRgb:j,toString:j}),w(H,L,_(b,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new H(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new H(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:X,formatHex:X,formatRgb:F,toString:F})),w(U,$,_(b,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new U(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new U(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new H(Z(t>=240?t-240:t+120,i,r),Z(t,i,r),Z(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var W=Math.PI/180,J=180/Math.PI,Q=.96422,K=1,tt=.82521,nt=4/29,et=6/29,rt=3*et*et,it=et*et*et;function at(t){if(t instanceof ut)return new ut(t.l,t.a,t.b,t.opacity);if(t instanceof dt)return vt(t);t instanceof H||(t=V(t));var n,e,r=ht(t.r),i=ht(t.g),a=ht(t.b),o=st((.2225045*r+.7168786*i+.0606169*a)/K);return r===i&&i===a?n=e=o:(n=st((.4360747*r+.3850649*i+.1430804*a)/Q),e=st((.0139322*r+.0971045*i+.7141733*a)/tt)),new ut(116*o-16,500*(n-o),200*(o-e),t.opacity)}function ot(t,n,e,r){return 1===arguments.length?at(t):new ut(t,n,e,null==r?1:r)}function ut(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function st(t){return t>it?Math.pow(t,1/3):t/rt+nt}function lt(t){return t>et?t*t*t:rt*(t-nt)}function ct(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ht(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ft(t){if(t instanceof dt)return new dt(t.h,t.c,t.l,t.opacity);if(t instanceof ut||(t=at(t)),0===t.a&&0===t.b)return new dt(NaN,0180||e<-180?e-360*Math.round(e/360):e):kt(isNaN(t)?n:t)}function Et(t){return 1==(t=+t)?zt:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):kt(isNaN(n)?e:n)}}function zt(t,n){var e=n-t;return e?St(t,e):kt(isNaN(t)?n:t)}var Ot=function t(n){var e=Et(n);function r(t,n){var r=e((t=L(t)).r,(n=L(n)).r),i=e(t.g,n.g),a=e(t.b,n.b),o=zt(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=a(n),t.opacity=o(n),t+""}}return r.gamma=t,r}(1);function Dt(t){return function(n){var e,r,i=n.length,a=new Array(i),o=new Array(i),u=new Array(i);for(e=0;e=1?(e=1,n-1):Math.floor(e*n),i=t[r],a=t[r+1],o=r>0?t[r-1]:2*i-a,u=ra&&(i=n.slice(a,i),u[o]?u[o]+=i:u[++o]=i),(e=e[0])===(r=r[0])?u[o]?u[o]+=r:u[++o]=r:(u[++o]=null,s.push({i:o,x:Rt(e,r)})),a=Ct.lastIndex;return a180?n+=360:n-t>180&&(t+=360),a.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Rt(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(a.rotate,o.rotate,u,s),function(t,n,e,a){t!==n?a.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Rt(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(a.skewX,o.skewX,u,s),function(t,n,e,r,a,o){if(t!==e||n!==r){var u=a.push(i(a)+"scale(",null,",",null,")");o.push({i:u-4,x:Rt(t,e)},{i:u-2,x:Rt(n,r)})}else 1===e&&1===r||a.push(i(a)+"scale("+e+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,u,s),a=o=null,function(t){for(var n,e=-1,r=s.length;++e=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?g:y;return function(){var o=a(this,t),u=o.on;u!==r&&(i=(r=u).copy()).on(n,e),o.on=i}}(e,t,n))},attr:function(t,n){var e=Object(r.namespace)(t),i="transform"===e?$t:Qt;return this.attrTween(t,"function"==typeof n?(e.local?function(t,n,e){var r,i,a;return function(){var o,u,s=e(this);if(null!=s)return(o=this.getAttributeNS(t.space,t.local))===(u=s+"")?null:o===r&&u===i?a:(i=u,a=n(r=o,s));this.removeAttributeNS(t.space,t.local)}}:function(t,n,e){var r,i,a;return function(){var o,u,s=e(this);if(null!=s)return(o=this.getAttribute(t))===(u=s+"")?null:o===r&&u===i?a:(i=u,a=n(r=o,s));this.removeAttribute(t)}})(e,i,Jt(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(t,n,e){var r,i,a=e+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=n(r=o,e)}}:function(t,n,e){var r,i,a=e+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=n(r=o,e)}})(e,i,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var i=Object(r.namespace)(t);return this.tween(e,(i.local?function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}:function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i})(i,n))},style:function(t,n,e){var i="transform"==(t+="")?Gt:Qt;return null==n?this.styleTween(t,function(t,n){var e,i,a;return function(){var o=Object(r.style)(this,t),u=(this.style.removeProperty(t),Object(r.style)(this,t));return o===u?null:o===e&&u===i?a:a=n(e=o,i=u)}}(t,i)).on("end.style."+t,tn(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var i,a,o;return function(){var u=Object(r.style)(this,t),s=e(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=Object(r.style)(this,t)),u===l?null:u===i&&l===a?o:(a=l,o=n(i=u,s))}}(t,i,Jt(this,"style."+t,n))).each(function(t,n){var e,r,i,a,o="style."+n,u="end."+o;return function(){var s=y(this,t),l=s.on,c=null==s.value[o]?a||(a=tn(n)):void 0;l===e&&i===c||(r=(e=l).copy()).on(u,i=c),s.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var i,a,o=e+"";return function(){var u=Object(r.style)(this,t);return u===o?null:u===i?a:a=n(i=u,e)}}(t,i,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function a(){var a=n.apply(this,arguments);return a!==i&&(r=(i=a)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,a,e)),r}return a._value=n,a}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Jt(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=m(this.node(),e).tween,a=0,o=i.length;al&&e.name===n)return new en([[t]],cn,n,+r);return null};e.d(n,"transition",function(){return rn}),e.d(n,"active",function(){return hn}),e.d(n,"interrupt",function(){return x})},FiMB:function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={};e.d(r,"VennDiagramDataItem",function(){return s}),e.d(r,"VennDiagram",function(){return l}),e.d(r,"VennSeriesDataItem",function(){return y}),e.d(r,"VennSeries",function(){return m});var i=e("m4/l"),a=e("DXFp"),o=e("aCit"),u=e("Mtpk"),s=function(t){function n(){var n=t.call(this)||this;return n.className="VennDiagramDataItem",n.applyTheme(),n}return Object(i.c)(n,t),n}(a.b),l=function(t){function n(){var n=t.call(this)||this;return n.className="VennDiagram",n.seriesContainer.layout="horizontal",n.padding(15,15,15,15),n.applyTheme(),n}return Object(i.c)(n,t),n.prototype.applyInternalDefaults=function(){t.prototype.applyInternalDefaults.call(this),u.hasValue(this.readerTitle)||(this.readerTitle=this.language.translate("Venn Diagram"))},n.prototype.setLegend=function(n){t.prototype.setLegend.call(this,n),n&&(n.valueLabels.template.disabled=!0)},n}(a.a);o.c.registeredClasses.VennDiagram=l,o.c.registeredClasses.VennDiagramDataItem=s;var c=e("AC2I"),h=e("hGwe"),f=e("tjMS"),p=e("Vs7R"),d=e("8ZqG"),v=e("MIZb"),g=e("YT44"),y=function(t){function n(){var n=t.call(this)||this;return n.radius=0,n.className="VennSeriesDataItem",n.events.on("visibilitychanged",function(){n.component},n,!1),n.applyTheme(),n}return Object(i.c)(n,t),Object.defineProperty(n.prototype,"intersections",{get:function(){return this.properties.intersections},set:function(t){this.setProperty("intersections",t)},enumerable:!0,configurable:!0}),n.prototype.hide=function(n,e,r,i){var a=this;return this.intersections||this.component.dataItems.each(function(t){t!=a&&t.intersections&&-1!=t.intersections.indexOf(a.category)&&t.hide(n,e,r,i)}),t.prototype.hide.call(this,n,e,r,i)},n.prototype.show=function(n,e,r){var i=this;return this.intersections||this.component.dataItems.each(function(t){t!=i&&t.intersections&&-1!=t.intersections.indexOf(i.category)&&t.show(n,e,r)}),t.prototype.show.call(this,n,e,r)},n.prototype.animateRadius=function(t,n,e){var r=this,i=this.animate({property:"radius",to:t},n,e);this._disposers.push(i),this._disposers.push(i.events.on("animationprogress",function(t){var n=r.radius,e=h.moveTo({x:-n,y:0});e+=h.arcToPoint({x:n,y:0},n,n,!0),e+=h.arcToPoint({x:-n,y:0},n,n,!0),r.slice.path=e,r.slice.isHover&&r.component.updateHoverSprite(r.slice)}))},n}(c.b),m=function(t){function n(){var n=t.call(this)||this;n.className="VennSeries",n.width=Object(f.c)(100),n.height=Object(f.c)(100),n.layout="absolute",n.slicesContainer.width=Object(f.c)(100),n.slicesContainer.height=Object(f.c)(100),n.slicesContainer.layout="none";var e=n.slices.template;e.strokeWidth=0,e.stroke=Object(d.c)("#ffffff"),n._disposers.push(n.events.on("maxsizechanged",function(){n.vennData=void 0,n.invalidateDataItems()},n,!1)),n.labelsContainer.layout="none",n.itemReaderText="{category}";var r=n.slicesContainer.createChild(p.a);r.strokeOpacity=1,r.strokeWidth=2,r.stroke=(new v.a).getFor("background"),r.strokeDasharray="3,3",r.zIndex=Number.MAX_VALUE,r.interactionsEnabled=!1,r.fill=Object(d.c)(),r.strokeDashoffset=0;var i=r.states.create("hover");return i.properties.strokeDashoffset=1e3,i.transitionDuration=1e5,n.hoverSprite=r,e.events.on("over",function(t){r.hide(0),r.show(),r.isHover=!0,n.updateHoverSprite(t.target)}),e.events.on("out",function(t){r.isHover=!1}),e.events.on("visibilitychanged",function(t){0==t.visible&&n.hoverSprite.hide()}),e.events.on("out",function(t){n.hoverSprite.hide()}),n.applyTheme(),n}return Object(i.c)(n,t),n.prototype.createSlice=function(){return new p.a},n.prototype.applyInternalDefaults=function(){t.prototype.applyInternalDefaults.call(this),u.hasValue(this.readerTitle)||(this.readerTitle=this.language.translate("Venn Series"))},n.prototype.createDataItem=function(){return new y},n.prototype.initSlice=function(t){t.isMeasured=!1,t.tooltipText="{category}"},n.prototype.initLabel=function(t){t.verticalCenter="middle",t.horizontalCenter="middle",t.isMeasured=!1,t.text="{category}"},n.prototype.updateHoverSprite=function(t){this.hoverSprite.path=t.path,this.hoverSprite.x=t.x,this.hoverSprite.y=t.y},n.prototype.validateDataElements=function(){var n=this;t.prototype.validateDataElements.call(this);var e=this.slicesContainer,r=this.labelsContainer,i=this.labels.template;this.alignLabels?(i.interactionsEnabled=!0,e.isMeasured=!0,r.isMeasured=!0):(i.interactionsEnabled=!1,e.isMeasured=!1,r.isMeasured=!1);var a=[];this.dataItems.each(function(t){var e={};t.intersections?e.sets=t.intersections:e.sets=[t.category],e.size=t.getValue("value");var r=!1;if(t.intersections){for(var i=0;i0&&!r&&!t.isHiding&&t.visible&&a.push(e)});var o=a.toString();if(o!=this.vennData&&(this.vennData=o,a.length>0)){var u=g.venn(a);u=g.normalizeSolution(u,null,null),u=g.scaleSolution(u,this.innerWidth,this.innerHeight,0);var s={};for(var l in u){var c=u[l],f=c.radius,p=this.getDataItemByCategory(l);if(this.interpolationDuration>0)p.animateRadius(f,this.interpolationDuration,this.interpolationEasing);else{var d=h.moveTo({x:-f,y:0});d+=h.arcToPoint({x:f,y:0},f,f,!0),d+=h.arcToPoint({x:-f,y:0},f,f,!0),p.slice.path=d,p.slice.isHover&&this.updateHoverSprite(p.slice)}var v=p.slice;void 0==v.x||void 0==v.y?(v.x=c.x,v.y=c.y):v.animate([{property:"x",to:c.x},{property:"y",to:c.y}],this.interpolationDuration,this.interpolationEasing),s[l]=c}var y=g.computeTextCentres(s,a),m=0;this.dataItems.each(function(t){var e=t.category,r=y[e];if(t.intersections&&(e=t.intersections.toString(),r=y[e])){for(var i=t.intersections,a=[],o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),i.hasOwnProperty(n)?{space:i[n],local:t}:t};var o=function(t){var n=a(t);return(n.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===r&&n.documentElement.namespaceURI===r?n.createElement(t):n.createElementNS(e,t)}})(n)};function u(){}var s=function(t){return null==t?u:function(){return this.querySelector(t)}};function l(){return[]}var c=function(t){return null==t?l:function(){return this.querySelectorAll(t)}},h=function(t){return function(){return this.matches(t)}},f=function(t){return new Array(t.length)};function p(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}p.prototype={constructor:p,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var d="$";function v(t,n,e,r,i,a){for(var o,u=0,s=n.length,l=a.length;un?1:t>=n?0:NaN}var m=function(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView};function x(t,n){return t.style.getPropertyValue(n)||m(t).getComputedStyle(t,null).getPropertyValue(n)}function w(t){return t.trim().split(/^|\s+/)}function _(t){return t.classList||new b(t)}function b(t){this._node=t,this._names=w(t.getAttribute("class")||"")}function M(t,n){for(var e=_(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function N(){this.textContent=""}function I(){this.innerHTML=""}function k(){this.nextSibling&&this.parentNode.appendChild(this)}function S(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function P(){return null}function E(){var t=this.parentNode;t&&t.removeChild(this)}function z(){var t=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function O(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}var D={},R=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(D={mouseenter:"mouseover",mouseleave:"mouseout"}));function j(t,n,e){return t=C(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function C(t,n,e){return function(r){var i=R;R=r;try{t.call(this,this.__data__,n,e)}finally{R=i}}}function T(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,a=n.length;r=b&&(b=_+1);!(w=m[b])&&++b=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=y);for(var e=this._groups,r=e.length,i=new Array(r),a=0;a1?this.each((null==n?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof n?function(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}:function(t,n,e){return function(){this.style.setProperty(t,n,e)}})(t,n,null==e?"":e)):x(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?function(t){return function(){delete this[t]}}:"function"==typeof n?function(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}:function(t,n){return function(){this[t]=n}})(t,n)):this.node()[t]},classed:function(t,n){var e=w(t+"");if(arguments.length<2){for(var r=_(this.node()),i=-1,a=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),o=a.length;if(!(arguments.length<2)){for(u=n?q:T,null==e&&(e=!1),r=0;rn[e].radius+r)return!1;return!0}(n,t)}),c=0,h=0,f=[];if(u.length>1){var p=l(u);for(e=0;e-1){var w=t[g.parentIndex[x]],_=Math.atan2(g.x-w.x,g.y-w.y),b=Math.atan2(v.x-w.x,v.y-w.y),M=b-_;M<0&&(M+=2*Math.PI);var A=b-M/2,N=o(y,{x:w.x+w.radius*Math.sin(A),y:w.y+w.radius*Math.cos(A)});N>2*w.radius&&(N=2*w.radius),(null===m||m.width>N)&&(m={circle:w,width:N,p1:g,p2:v})}null!==m&&(f.push(m),c+=a(m.circle.radius,m.width),v=g)}}else{var I=t[0];for(e=1;eMath.abs(I.radius-t[e].radius)){k=!0;break}k?c=h=0:(c=I.radius*I.radius*Math.PI,f.push({circle:I,p1:{x:I.x,y:I.y+I.radius},p2:{x:I.x-r,y:I.y+I.radius},width:2*I.radius}))}return h/=2,n&&(n.area=c+h,n.arcArea=c,n.polygonArea=h,n.arcs=f,n.innerPoints=u,n.intersectionPoints=i),c+h}function a(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function o(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function u(t,n,e){if(e>=t+n)return 0;if(e<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);var r=n-(e*e-t*t+n*n)/(2*e);return a(t,t-(e*e-n*n+t*t)/(2*e))+a(n,r)}function s(t,n){var e=o(t,n),r=t.radius,i=n.radius;if(e>=r+i||e<=Math.abs(r-i))return[];var a=(r*r-i*i+e*e)/(2*e),u=Math.sqrt(r*r-a*a),s=t.x+a*(n.x-t.x)/e,l=t.y+a*(n.y-t.y)/e,c=-(n.y-t.y)*(u/e),h=-(n.x-t.x)*(u/e);return[{x:s+c,y:l-h},{x:s-c,y:l+h}]}function l(t){for(var n={x:0,y:0},e=0;e=d[p-1].fx){var S=!1;if(_.fx>k.fx?(v(b,1+h,w,-h,k),b.fx=t(b),b.fx=1)break;for(g=1;gu+a*i*s||l>=d)p=i;else{if(Math.abs(h)<=-o*s)return i;h*(p-c)>=0&&(p=c),c=i,d=l}return 0}i=i||1,a=a||1e-6,o=o||.1;for(var g=0;g<10;++g){if(v(r.x,1,e.x,i,n),l=r.fx=t(r.x,r.fxprime),h=f(r.fxprime,n),l>u+a*i*s||g&&l>=c)return d(p,i,c);if(Math.abs(h)<=-o*s)return i;if(h>=0)return d(i,p,l);c=l,p=i,i*=2}return i}function m(t,n,e){var r,i,a,o={x:n.slice(),fx:0,fxprime:n.slice()},u={x:n.slice(),fx:0,fxprime:n.slice()},s=n.slice(),l=1;a=(e=e||{}).maxIterations||20*n.length,o.fx=t(o.x,o.fxprime),d(r=o.fxprime.slice(),o.fxprime,-1);for(var c=0;cn}),n=0;n0)throw"Initial bisect points must have opposite signs";if(0===o)return n;if(0===u)return e;for(var l=0;l=0&&(n=c),Math.abs(s)=8){var i=function(t,n){var e,r=(n=n||{}).restarts||10,i=[],a={};for(e=0;e=Math.min(n[a].size,n[o].size)?s=1:t.size<=1e-10&&(s=-1),i[a][o]=i[o][a]=s}),{distances:r,constraints:i}}(t,i,a),s=u.distances,l=u.constraints,f=p(s.map(p))/s.length;s=s.map(function(t){return t.map(function(t){return t/f})});var v,g,y=function(t,n){return function(t,n,e,r){var i,a=0;for(i=0;i0&&d<=h||f<0&&d>=h||(a+=2*v*v,n[2*i]+=4*v*(o-l),n[2*i+1]+=4*v*(u-c),n[2*s]+=4*v*(l-o),n[2*s+1]+=4*v*(c-u))}return a}(t,n,s,l)};for(e=0;e=Math.min(i[h].size,i[f].size)&&(c=0),a[h].push({set:f,size:l.size,weight:c}),a[f].push({set:h,size:l.size,weight:c})}var p=[];for(e in a)if(a.hasOwnProperty(e)){var d=0;for(o=0;o0){var i=t[0].x,a=t[0].y;for(r=0;r1){var u,s,l=Math.atan2(t[1].x,t[1].y)-n,c=Math.cos(l),h=Math.sin(l);for(r=0;r2){for(var f=Math.atan2(t[2].x,t[2].y)-n;f<0;)f+=2*Math.PI;for(;f>2*Math.PI;)f-=2*Math.PI;if(f>Math.PI){var p=t[1].y/(1e-10+t[1].x);for(r=0;rl&&p.node().getComputedTextLength()>o&&(h.pop(),p.text(h.join(" ")),h=[c],p=i.append("tspan").text(c),f++);var d=.35-1.1*f/2,v=i.attr("x"),g=i.attr("y");i.selectAll("tspan").attr("x",v).attr("y",g).attr("dy",function(t,n){return d+1.1*n+"em"})}}function z(t,n,e){var r,i,a=n[0].radius-o(n[0],t);for(r=1;r=s&&(u=r[e],s=c)}var h=g(function(e){return-1*z({x:e[0],y:e[1]},t,n)},[u.x,u.y],{maxIterations:500,minErrorDelta:1e-10}).x,f={x:h[0],y:h[1]},p=!0;for(e=0;et[e].radius){p=!1;break}for(e=0;e0&&console.log("WARNING: area "+a+" not represented on screen")}return e}function j(t,n,e){var r=[];return r.push("\nM",t,n),r.push("\nm",-e,0),r.push("\na",e,e,0,1,0,2*e,0),r.push("\na",e,e,0,1,0,2*-e,0),r.join(" ")}function C(t){var n=t.split(" ");return{x:parseFloat(n[1]),y:parseFloat(n[2]),radius:-parseFloat(n[4])}}function T(t){var n={};i(t,n);var e=n.arcs;if(0===e.length)return"M 0 0";if(1==e.length){var r=e[0].circle;return j(r.x,r.y,r.radius)}for(var a=["\nM",e[0].p2.x,e[0].p2.y],o=0;os;a.push("\nA",s,s,0,l?1:0,1,u.p1.x,u.p1.y)}return a.join(" ")}t.intersectionArea=i,t.circleCircleIntersection=s,t.circleOverlap=u,t.circleArea=a,t.distance=o,t.venn=x,t.greedyLayout=M,t.scaleSolution=P,t.normalizeSolution=S,t.bestInitialLayout=b,t.lossFunction=A,t.disjointCluster=I,t.distanceFromIntersectArea=_,t.VennDiagram=function(){var t=600,e=350,r=15,i=1e3,a=Math.PI/2,o=!0,u=!0,s=!0,l=null,c=null,h={},f=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],p=0,d=function(t){if(t in h)return h[t];var n=h[t]=f[p];return(p+=1)>=f.length&&(p=0),n},v=x,g=A;function y(h){var f=h.datum(),p={};f.forEach(function(t){0==t.size&&1==t.sets.length&&(p[t.sets[0]]=1)});var y={},m={};if((f=f.filter(function(t){return!t.sets.some(function(t){return t in p})})).length>0){var x=v(f,{lossFunction:g});o&&(x=S(x,a,c)),y=P(x,t,e,r),m=R(y,f)}var w={};function _(t){return t.sets in w?w[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}f.forEach(function(t){t.label&&(w[t.sets]=t.label)}),h.selectAll("svg").data([y]).enter().append("svg");var b=h.select("svg").attr("width",t).attr("height",e),M={},A=!1;b.selectAll(".venn-area path").each(function(t){var e=n.select(this).attr("d");1==t.sets.length&&e&&(A=!0,M[t.sets[0]]=C(e))});var N=function(n){return function(r){return T(n.sets.map(function(n){var i=M[n],a=y[n];return i||(i={x:t/2,y:e/2,radius:1}),a||(a={x:t/2,y:e/2,radius:1}),{x:i.x*(1-r)+a.x*r,y:i.y*(1-r)+a.y*r,radius:i.radius*(1-r)+a.radius*r}}))}},I=b.selectAll(".venn-area").data(f,function(t){return t.sets}),k=I.enter().append("g").attr("class",function(t){return"venn-area venn-"+(1==t.sets.length?"circle":"intersection")}).attr("data-venn-sets",function(t){return t.sets.join("_")}),z=k.append("path"),O=k.append("text").attr("class","label").text(function(t){return _(t)}).attr("text-anchor","middle").attr("dy",".35em").attr("x",t/2).attr("y",e/2);s&&(z.style("fill-opacity","0").filter(function(t){return 1==t.sets.length}).style("fill",function(t){return d(t.sets)}).style("fill-opacity",".25"),O.style("fill",function(t){return 1==t.sets.length?d(t.sets):"#444"}));var D=h;A?(D=h.transition("venn").duration(i)).selectAll("path").attrTween("d",N):D.selectAll("path").attr("d",function(t){return T(t.sets.map(function(t){return y[t]}))});var j=D.selectAll("text").filter(function(t){return t.sets in m}).text(function(t){return _(t)}).attr("x",function(t){return Math.floor(m[t.sets].x)}).attr("y",function(t){return Math.floor(m[t.sets].y)});u&&(A?"on"in j?j.on("end",E(y,_)):j.each("end",E(y,_)):j.each(E(y,_)));var q=I.exit().transition("venn").duration(i).remove();q.selectAll("path").attrTween("d",N);var V=q.selectAll("text").attr("x",t/2).attr("y",e/2);return null!==l&&(O.style("font-size","0px"),j.style("font-size",l),V.style("font-size","0px")),{circles:y,textCentres:m,nodes:I,enter:k,update:D,exit:q}}return y.wrap=function(t){return arguments.length?(u=t,y):u},y.width=function(n){return arguments.length?(t=n,y):t},y.height=function(t){return arguments.length?(e=t,y):e},y.padding=function(t){return arguments.length?(r=t,y):r},y.colours=function(t){return arguments.length?(d=t,y):d},y.fontSize=function(t){return arguments.length?(l=t,y):l},y.duration=function(t){return arguments.length?(i=t,y):i},y.layoutFunction=function(t){return arguments.length?(v=t,y):v},y.normalize=function(t){return arguments.length?(o=t,y):o},y.styled=function(t){return arguments.length?(s=t,y):s},y.orientation=function(t){return arguments.length?(a=t,y):a},y.orientationOrder=function(t){return arguments.length?(c=t,y):c},y.lossFunction=function(t){return arguments.length?(g=t,y):g},y},t.wrapText=E,t.computeTextCentres=R,t.computeTextCentre=O,t.sortAreas=function(t,n){for(var e=D(t.selectAll("svg").datum()),r={},i=0;i