d3plus-shape
Version:
Fancy SVG shapes for visualizations
7 lines • 63.1 kB
JavaScript
/*
d3plus-shape v0.16.11
Fancy SVG shapes for visualizations
Copyright (c) 2019 D3plus - https://d3plus.org
@license MIT
*/
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-selection"),require("d3-transition"),require("d3plus-common"),require("d3-array"),require("d3-color"),require("d3plus-color"),require("d3-shape"),require("d3plus-text"),require("d3-collection"),require("d3-interpolate-path"),require("d3-polygon")):typeof define==="function"&&define.amd?define("d3plus-shape",["exports","d3-selection","d3-transition","d3plus-common","d3-array","d3-color","d3plus-color","d3-shape","d3plus-text","d3-collection","d3-interpolate-path","d3-polygon"],e):(t=t||self,e(t.d3plus={},t.d3Selection,t.d3Transition,t.d3plusCommon,t.d3Array,t.d3Color,t.d3plusColor,t.paths,t.d3plusText,t.d3Collection,t.d3InterpolatePath,t.d3Polygon))})(this,function(t,v,p,y,xt,a,i,g,x,u,o,mt){"use strict";function c(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||false;i.configurable=true;if("value"in i)i.writable=true;Object.defineProperty(t,i.key,i)}}function n(t,e,n){if(e)r(t.prototype,e);if(n)r(t,n);return t}function h(t,e){if(typeof e!=="function"&&e!==null){throw new TypeError("Super expression must either be null or a function")}t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}});if(e)s(t,e)}function l(t){l=Object.setPrototypeOf?Object.getPrototypeOf:function t(e){return e.__proto__||Object.getPrototypeOf(e)};return l(t)}function s(t,e){s=Object.setPrototypeOf||function t(e,n){e.__proto__=n;return e};return s(t,e)}function f(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function _(t,e){if(e&&(typeof e==="object"||typeof e==="function")){return e}return f(t)}function d(t,e){while(!Object.prototype.hasOwnProperty.call(t,e)){t=l(t);if(t===null)break}return t}function m(t,e,n){if(typeof Reflect!=="undefined"&&Reflect.get){m=Reflect.get}else{m=function t(e,n,i){var r=d(e,n);if(!r)return;var a=Object.getOwnPropertyDescriptor(r,n);if(a.get){return a.get.call(i)}return a.value}}return m(t,e,n||t)}function kt(t,e){return k(t)||b(t,e)||w()}function k(t){if(Array.isArray(t))return t}function b(t,e){var n=[];var i=true;var r=false;var a=undefined;try{for(var s=t[Symbol.iterator](),o;!(i=(o=s.next()).done);i=true){n.push(o.value);if(e&&n.length===e)break}}catch(t){r=true;a=t}finally{try{if(!i&&s["return"]!=null)s["return"]()}finally{if(r)throw a}}return n}function w(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var O=function(){function h(){c(this,h);this._duration=600;this._height=y.accessor("height");this._id=y.accessor("id");this._pointerEvents=y.constant("auto");this._select;this._url=y.accessor("url");this._width=y.accessor("width");this._x=y.accessor("x",0);this._y=y.accessor("y",0)}n(h,[{key:"render",value:function t(e){var n=this;if(this._select===void 0)this.select(v.select("body").append("svg").style("width","".concat(window.innerWidth,"px")).style("height","".concat(window.innerHeight,"px")).style("display","block").node());var i=this._select.selectAll(".d3plus-Image").data(this._data,this._id);var r=i.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",function(t,e){return n._x(t,e)+n._width(t,e)/2}).attr("y",function(t,e){return n._y(t,e)+n._height(t,e)/2});var a=p.transition().duration(this._duration),s=this,o=r.merge(i);o.attr("xlink:href",this._url).style("pointer-events",this._pointerEvents).transition(a).attr("opacity",1).attr("width",function(t,e){return n._width(t,e)}).attr("height",function(t,e){return n._height(t,e)}).attr("x",function(t,e){return n._x(t,e)}).attr("y",function(t,e){return n._y(t,e)}).each(function(t,e){var n=v.select(this),i=s._url(t,e);var r=i.indexOf("http://")===0||i.indexOf("https://")===0;if(!r||i.indexOf(window.location.hostname)===0){var a=new h;a.src=i;a.crossOrigin="Anonymous";a.onload=function(){var t=document.createElement("canvas");t.width=this.width;t.height=this.height;var e=t.getContext("2d");e.drawImage(this,0,0);n.attr("xlink:href",t.toDataURL("image/png"))}}});i.exit().transition(a).attr("width",function(t,e){return n._width(t,e)}).attr("height",function(t,e){return n._height(t,e)}).attr("x",function(t,e){return n._x(t,e)}).attr("y",function(t,e){return n._y(t,e)}).attr("opacity",0).remove();if(e)setTimeout(e,this._duration+100);return this}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"height",value:function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height}},{key:"id",value:function t(e){return arguments.length?(this._id=e,this):this._id}},{key:"pointerEvents",value:function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents}},{key:"select",value:function t(e){return arguments.length?(this._select=v.select(e),this):this._select}},{key:"url",value:function t(e){return arguments.length?(this._url=e,this):this._url}},{key:"width",value:function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width}},{key:"x",value:function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x}},{key:"y",value:function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y}}]);return h}();var bt=function(t,e){var n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i};var C=function(t,e){return Math.sqrt(bt(t,e))};var e=function(t){h(e,t);function e(){var r;var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"g";c(this,e);r=_(this,l(e).call(this));r._activeOpacity=.25;r._activeStyle={stroke:function t(e,n){var i=r._fill(e,n);if(["transparent","none"].includes(i))i=r._stroke(e,n);return a.color(i).darker(1)},"stroke-width":function t(e,n){var i=r._strokeWidth(e,n)||1;return i*3}};r._ariaLabel=y.constant("");r._backgroundImage=y.constant(false);r._backgroundImageClass=new O;r._data=[];r._duration=600;r._fill=y.constant("black");r._fillOpacity=y.constant(1);r._hoverOpacity=.5;r._hoverStyle={stroke:function t(e,n){var i=r._fill(e,n);if(["transparent","none"].includes(i))i=r._stroke(e,n);return a.color(i).darker(.5)},"stroke-width":function t(e,n){var i=r._strokeWidth(e,n)||1;return i*2}};r._id=function(t,e){return t.id!==void 0?t.id:e};r._label=y.constant(false);r._labelClass=new x.TextBox;r._labelConfig={fontColor:function t(e,n){return i.colorContrast(r._fill(e,n))},fontSize:12,padding:5};r._name="Shape";r._opacity=y.constant(1);r._pointerEvents=y.constant("visiblePainted");r._role=y.constant("presentation");r._rotate=y.constant(0);r._rx=y.constant(0);r._ry=y.constant(0);r._scale=y.constant(1);r._shapeRendering=y.constant("geometricPrecision");r._stroke=function(t,e){return a.color(r._fill(t,e)).darker(1)};r._strokeDasharray=y.constant("0");r._strokeLinecap=y.constant("butt");r._strokeOpacity=y.constant(1);r._strokeWidth=y.constant(0);r._tagName=t;r._textAnchor=y.constant("start");r._vectorEffect=y.constant("non-scaling-stroke");r._verticalAlign=y.constant("top");r._x=y.accessor("x",0);r._y=y.accessor("y",0);return r}n(e,[{key:"_aes",value:function t(){return{}}},{key:"_applyEvents",value:function t(e){var a=this;var s=Object.keys(this._on);var n=function t(r){e.on(s[r],function(t,e){if(!a._on[s[r]])return;if(t.i!==void 0)e=t.i;if(t.nested&&t.values){var n=v.mouse(a._select.node()),i=t.values.map(function(t){return C(n,[a._x(t,e),a._y(t,e)])});t=t.values[i.indexOf(xt.min(i))]}a._on[s[r]].bind(a)(t,e)})};for(var i=0;i<s.length;i++){n(i)}}},{key:"_updateStyle",value:function t(e,n){var i=this;if(e.size()&&e.node().tagName==="g")e=e.selectAll("*");function r(t,e){return typeof this!=="function"?this:t.nested&&t.key&&t.values?this(t.values[0],i._data.indexOf(t.values[0])):this(t,e)}var a={};for(var s in n){if({}.hasOwnProperty.call(n,s)){a[s]=r.bind(n[s])}}e.transition().duration(0).call(y.attrize,a)}},{key:"_applyStyle",value:function t(e){var n=this;if(e.size()&&e.node().tagName==="g")e=e.selectAll("*");function i(t,e){return typeof this!=="function"?this:t.nested&&t.key&&t.values?this(t.values[0],n._data.indexOf(t.values[0])):this(t,e)}e.attr("fill",i.bind(this._fill)).attr("fill-opacity",i.bind(this._fillOpacity)).attr("rx",i.bind(this._rx)).attr("ry",i.bind(this._ry)).attr("stroke",i.bind(this._stroke)).attr("stroke-dasharray",i.bind(this._strokeDasharray)).attr("stroke-linecap",i.bind(this._strokeLinecap)).attr("stroke-opacity",i.bind(this._strokeOpacity)).attr("stroke-width",i.bind(this._strokeWidth)).attr("vector-effect",i.bind(this._vectorEffect))}},{key:"_applyTransform",value:function t(e){var n=this;e.attr("transform",function(t,e){return"\n translate(".concat(t.__d3plusShape__?t.translate?t.translate:"".concat(n._x(t.data,t.i),",").concat(n._y(t.data,t.i)):"".concat(n._x(t,e),",").concat(n._y(t,e)),")\n scale(").concat(t.__d3plusShape__?t.scale||n._scale(t.data,t.i):n._scale(t,e),")\n rotate(").concat(t.__d3plusShape__?t.rotate?t.rotate:n._rotate(t.data||t,t.i):n._rotate(t.data||t,t.i),")")})}},{key:"_nestWrapper",value:function t(n){return function(t,e){return n(t.__d3plusShape__?t.data:t,t.__d3plusShape__?t.i:e)}}},{key:"_renderActive",value:function t(){var r=this;this._group.selectAll(".d3plus-Shape, .d3plus-Image, .d3plus-textBox").each(function(t,e){if(!t)t={};if(!t.parentNode)t.parentNode=this.parentNode;var n=t.parentNode;if(v.select(this).classed("d3plus-textBox"))t=t.data;if(t.__d3plusShape__||t.__d3plus__){while(t&&(t.__d3plusShape__||t.__d3plus__)){e=t.i;t=t.data}}else e=r._data.indexOf(t);var i=!r._active||typeof r._active!=="function"||!r._active(t,e)?n:r._activeGroup.node();if(i!==this.parentNode){i.appendChild(this);if(this.className.baseVal.includes("d3plus-Shape")){if(n===i)v.select(this).call(r._applyStyle.bind(r));else v.select(this).call(r._updateStyle.bind(r,v.select(this),r._activeStyle))}}});this._group.selectAll("g.d3plus-".concat(this._name,"-shape, g.d3plus-").concat(this._name,"-image, g.d3plus-").concat(this._name,"-text")).attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)}},{key:"_renderHover",value:function t(){var r=this;this._group.selectAll("g.d3plus-".concat(this._name,"-shape, g.d3plus-").concat(this._name,"-image, g.d3plus-").concat(this._name,"-text, g.d3plus-").concat(this._name,"-hover")).selectAll(".d3plus-Shape, .d3plus-Image, .d3plus-textBox").each(function(t,e){if(!t)t={};if(!t.parentNode)t.parentNode=this.parentNode;var n=t.parentNode;if(v.select(this).classed("d3plus-textBox"))t=t.data;if(t.__d3plusShape__||t.__d3plus__){while(t&&(t.__d3plusShape__||t.__d3plus__)){e=t.i;t=t.data}}else e=r._data.indexOf(t);var i=!r._hover||typeof r._hover!=="function"||!r._hover(t,e)?n:r._hoverGroup.node();if(i!==this.parentNode)i.appendChild(this);if(this.className.baseVal.includes("d3plus-Shape")){if(n===i)v.select(this).call(r._applyStyle.bind(r));else v.select(this).call(r._updateStyle.bind(r,v.select(this),r._hoverStyle))}});this._group.selectAll("g.d3plus-".concat(this._name,"-shape, g.d3plus-").concat(this._name,"-image, g.d3plus-").concat(this._name,"-text")).attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)}},{key:"_renderImage",value:function t(){var u=this;var c=[];this._update.merge(this._enter).data().forEach(function(t,e){var n=u._aes(t,e);if(n.r||n.width&&n.height){var i=t;if(t.nested&&t.key&&t.values){i=t.values[0];e=u._data.indexOf(i)}var r=n.r?n.r*2:n.height,a=u._backgroundImage(i,e),s=n.r?n.r*2:n.width;if(a){var o=i.__d3plusShape__?i.translate?i.translate[0]:u._x(i.data,i.i):u._x(i,e),h=i.__d3plusShape__?i.translate?i.translate[1]:u._y(i.data,i.i):u._y(i,e);if(n.x)o+=n.x;if(n.y)h+=n.y;if(i.__d3plusShape__){i=i.data;e=i.i}c.push({__d3plus__:true,data:i,height:r,i:e,id:u._id(i,e),url:a,width:s,x:o+-s/2,y:h+-r/2})}}});this._backgroundImageClass.data(c).duration(this._duration).pointerEvents("none").select(y.elem("g.d3plus-".concat(this._name,"-image"),{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).render()}},{key:"_renderLabels",value:function t(){var f=this;var _=[];this._update.merge(this._enter).data().forEach(function(t,e){var n=t;if(t.nested&&t.key&&t.values){n=t.values[0];e=f._data.indexOf(n)}var i=f._label(n,e);if(f._labelBounds&&i!==false&&i!==undefined&&i!==null){var r=f._labelBounds(n,e,f._aes(t,e));if(r){if(i.constructor!==Array)i=[i];var a=n.__d3plusShape__?n.translate?n.translate[0]:f._x(n.data,n.i):f._x(n,e),s=n.__d3plusShape__?n.translate?n.translate[1]:f._y(n.data,n.i):f._y(n,e);if(n.__d3plusShape__){n=n.data;e=n.i}for(var o=0;o<i.length;o++){var h=r.constructor===Array?r[o]:Object.assign({},r);var u=f._rotate(n,e);var c=n.labelConfig&&n.labelConfig.rotate?n.labelConfig.rotate:r.angle!==undefined?r.angle:0;c+=u;var l=u!==0?[h.x*-1||0,h.y*-1||0]:[h.width/2,h.height/2];_.push({__d3plus__:true,data:n,height:h.height,l:o,id:"".concat(f._id(n,e),"_").concat(o),r:c,rotateAnchor:l,text:i[o],width:h.width,x:a+h.x,y:s+h.y})}}}});this._labelClass.data(_).duration(this._duration).pointerEvents("none").rotate(function(t){return t.__d3plus__?t.r:t.data.r}).rotateAnchor(function(t){return t.__d3plus__?t.rotateAnchor:t.data.rotateAnchor}).select(y.elem("g.d3plus-".concat(this._name,"-text"),{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).config(y.configPrep.bind(this)(this._labelConfig)).render()}},{key:"render",value:function t(e){var n=this;if(this._select===void 0){this.select(v.select("body").append("svg").style("width","".concat(window.innerWidth,"px")).style("height","".concat(window.innerHeight,"px")).style("display","block").node())}this._transition=p.transition().duration(this._duration);var i=this._data,r=this._id;if(this._dataFilter){i=this._dataFilter(i);if(i.key)r=i.key}if(this._sort){i=i.sort(function(t,e){while(t.__d3plusShape__||t.__d3plus__){t=t.data}while(e.__d3plusShape__||e.__d3plus__){e=e.data}return n._sort(t,e)})}v.selectAll("g.d3plus-".concat(this._name,"-hover > *, g.d3plus-").concat(this._name,"-active > *")).each(function(t){if(t&&t.parentNode)t.parentNode.appendChild(this);else this.parentNode.removeChild(this)});this._group=y.elem("g.d3plus-".concat(this._name,"-group"),{parent:this._select});var a=this._update=y.elem("g.d3plus-".concat(this._name,"-shape"),{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).selectAll(".d3plus-".concat(this._name)).data(i,r);a.order();if(this._duration){a.transition(this._transition).call(this._applyTransform.bind(this))}else{a.call(this._applyTransform.bind(this))}var s=this._enter=a.enter().append(this._tagName).attr("class",function(t,e){return"d3plus-Shape d3plus-".concat(n._name," d3plus-id-").concat(x.strip(n._nestWrapper(n._id)(t,e)))}).call(this._applyTransform.bind(this)).attr("aria-label",this._ariaLabel).attr("role",this._role).attr("opacity",this._nestWrapper(this._opacity));var o=s.merge(a);var h=o.attr("shape-rendering",this._nestWrapper(this._shapeRendering));if(this._duration){h=h.attr("pointer-events","none").transition(this._transition).transition().delay(100).attr("pointer-events",this._pointerEvents)}h.attr("opacity",this._nestWrapper(this._opacity));var u=this._exit=a.exit();if(this._duration)u.transition().delay(this._duration).remove();else u.remove();this._renderImage();this._renderLabels();this._hoverGroup=y.elem("g.d3plus-".concat(this._name,"-hover"),{parent:this._group});this._activeGroup=y.elem("g.d3plus-".concat(this._name,"-active"),{parent:this._group});var c=this._group.selectAll(".d3plus-HitArea").data(this._hitArea?i:[],r);c.order().call(this._applyTransform.bind(this));var l=this._name==="Line";l&&this._path.curve(g["curve".concat(this._curve.charAt(0).toUpperCase()).concat(this._curve.slice(1))]).defined(this._defined).x(this._x).y(this._y);var f=c.enter().append(l?"path":"rect").attr("class",function(t,e){return"d3plus-HitArea d3plus-id-".concat(x.strip(n._nestWrapper(n._id)(t,e)))}).attr("fill","black").attr("stroke","black").attr("pointer-events","painted").attr("opacity",0).call(this._applyTransform.bind(this));var _=this;var d=c.merge(f).each(function(t){var e=_._data.indexOf(t);var n=_._hitArea(t,e,_._aes(t,e));return n&&!(_._name==="Line"&&parseFloat(_._strokeWidth(t,e))>10)?v.select(this).call(y.attrize,n):v.select(this).remove()});c.exit().remove();this._applyEvents(this._hitArea?d:o);setTimeout(function(){if(n._active)n._renderActive();else if(n._hover)n._renderHover();if(e)e()},this._duration+100);return this}},{key:"active",value:function t(e){if(!arguments.length||e===undefined)return this._active;this._active=e;if(this._group){this._renderActive()}return this}},{key:"activeOpacity",value:function t(e){return arguments.length?(this._activeOpacity=e,this):this._activeOpacity}},{key:"activeStyle",value:function t(e){return arguments.length?(this._activeStyle=y.assign({},this._activeStyle,e),this):this._activeStyle}},{key:"ariaLabel",value:function t(e){return e!==undefined?(this._ariaLabel=typeof e==="function"?e:y.constant(e),this):this._ariaLabel}},{key:"backgroundImage",value:function t(e){return arguments.length?(this._backgroundImage=typeof e==="function"?e:y.constant(e),this):this._backgroundImage}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"fill",value:function t(e){return arguments.length?(this._fill=typeof e==="function"?e:y.constant(e),this):this._fill}},{key:"fillOpacity",value:function t(e){return arguments.length?(this._fillOpacity=typeof e==="function"?e:y.constant(e),this):this._fillOpacity}},{key:"hover",value:function t(e){if(!arguments.length||e===void 0)return this._hover;this._hover=e;if(this._group){this._renderHover()}return this}},{key:"hoverStyle",value:function t(e){return arguments.length?(this._hoverStyle=y.assign({},this._hoverStyle,e),this):this._hoverStyle}},{key:"hoverOpacity",value:function t(e){return arguments.length?(this._hoverOpacity=e,this):this._hoverOpacity}},{key:"hitArea",value:function t(e){return arguments.length?(this._hitArea=typeof e==="function"?e:y.constant(e),this):this._hitArea}},{key:"id",value:function t(e){return arguments.length?(this._id=e,this):this._id}},{key:"label",value:function t(e){return arguments.length?(this._label=typeof e==="function"?e:y.constant(e),this):this._label}},{key:"labelBounds",value:function t(e){return arguments.length?(this._labelBounds=typeof e==="function"?e:y.constant(e),this):this._labelBounds}},{key:"labelConfig",value:function t(e){return arguments.length?(this._labelConfig=y.assign(this._labelConfig,e),this):this._labelConfig}},{key:"opacity",value:function t(e){return arguments.length?(this._opacity=typeof e==="function"?e:y.constant(e),this):this._opacity}},{key:"pointerEvents",value:function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents}},{key:"role",value:function t(e){return e!==undefined?(this._role=typeof e==="function"?e:y.constant(e),this):this._role}},{key:"rotate",value:function t(e){return arguments.length?(this._rotate=typeof e==="function"?e:y.constant(e),this):this._rotate}},{key:"rx",value:function t(e){return arguments.length?(this._rx=typeof e==="function"?e:y.constant(e),this):this._rx}},{key:"ry",value:function t(e){return arguments.length?(this._ry=typeof e==="function"?e:y.constant(e),this):this._ry}},{key:"scale",value:function t(e){return arguments.length?(this._scale=typeof e==="function"?e:y.constant(e),this):this._scale}},{key:"select",value:function t(e){return arguments.length?(this._select=v.select(e),this):this._select}},{key:"shapeRendering",value:function t(e){return arguments.length?(this._shapeRendering=typeof e==="function"?e:y.constant(e),this):this._shapeRendering}},{key:"sort",value:function t(e){return arguments.length?(this._sort=e,this):this._sort}},{key:"stroke",value:function t(e){return arguments.length?(this._stroke=typeof e==="function"?e:y.constant(e),this):this._stroke}},{key:"strokeDasharray",value:function t(e){return arguments.length?(this._strokeDasharray=typeof e==="function"?e:y.constant(e),this):this._strokeDasharray}},{key:"strokeLinecap",value:function t(e){return arguments.length?(this._strokeLinecap=typeof e==="function"?e:y.constant(e),this):this._strokeLinecap}},{key:"strokeOpacity",value:function t(e){return arguments.length?(this._strokeOpacity=typeof e==="function"?e:y.constant(e),this):this._strokeOpacity}},{key:"strokeWidth",value:function t(e){return arguments.length?(this._strokeWidth=typeof e==="function"?e:y.constant(e),this):this._strokeWidth}},{key:"textAnchor",value:function t(e){return arguments.length?(this._textAnchor=typeof e==="function"?e:y.constant(e),this):this._textAnchor}},{key:"vectorEffect",value:function t(e){return arguments.length?(this._vectorEffect=typeof e==="function"?e:y.constant(e),this):this._vectorEffect}},{key:"verticalAlign",value:function t(e){return arguments.length?(this._verticalAlign=typeof e==="function"?e:y.constant(e),this):this._verticalAlign}},{key:"x",value:function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x}},{key:"y",value:function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y}}]);return e}(y.BaseClass);function S(t,e,n,i){var r=1e-9;var a=t[0]-e[0],s=n[0]-i[0],o=t[1]-e[1],h=n[1]-i[1];var u=a*h-o*s;if(Math.abs(u)<r)return null;var c=t[0]*e[1]-t[1]*e[0],l=n[0]*i[1]-n[1]*i[0];var f=(c*s-l*a)/u,_=(c*h-l*o)/u;return[f,_]}function A(t,e,n){var i=1e-9,r=kt(n,2),a=r[0],s=r[1];return!(a<Math.min(t[0],e[0])-i||a>Math.max(t[0],e[0])+i||s<Math.min(t[1],e[1])-i||s>Math.max(t[1],e[1])+i)}function E(t,e,n,i){var r=S(t,e,n,i);if(!r)return false;return A(t,e,r)&&A(n,i,r)}function wt(t,e){var n=-1;var i=t.length;var r=e.length;var a=t[i-1];while(++n<i){var s=a;a=t[n];var o=-1;var h=e[r-1];while(++o<r){var u=h;h=e[o];if(E(s,a,u,h))return false}}return mt.polygonContains(e,t[0])}function Ot(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var i=1e-9;e=[e[0]+i*Math.cos(n),e[1]+i*Math.sin(n)];var r=e,a=kt(r,2),s=a[0],o=a[1];var h=[s+Math.cos(n),o+Math.sin(n)];var u=0;if(Math.abs(h[0]-s)<i)u=1;var c=-1;var l=t.length;var f=t[l-1];var _=Number.MAX_VALUE;var d=Number.MAX_VALUE;var v=null;var p=null;while(++c<l){var y=f;f=t[c];var g=S(e,h,y,f);if(g&&A(y,f,g)){var x=bt(e,g);if(g[u]<e[u]){if(x<_){_=x;v=g}}else if(g[u]>e[u]){if(x<d){d=x;p=g}}}}return[v,p]}function M(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[0,0];var i=Math.cos(e),r=Math.sin(e),a=t[0]-n[0],s=t[1]-n[1];return[i*a-r*s+n[0],r*a+i*s+n[1]]}var Ct=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[0,0];return t.map(function(t){return M(t,e,n)})};function P(t,e,n){var i=e[0],r=e[1];var a=n[0]-i,s=n[1]-r;if(a!==0||s!==0){var o=((t[0]-i)*a+(t[1]-r)*s)/(a*a+s*s);if(o>1){i=n[0];r=n[1]}else if(o>0){i+=a*o;r+=s*o}}a=t[0]-i;s=t[1]-r;return a*a+s*s}function L(t,e){var n,i=t[0];var r=[i];for(var a=1,s=t.length;a<s;a++){n=t[a];if(bt(n,i)>e){r.push(n);i=n}}if(i!==n)r.push(n);return r}function j(t,e,n,i,r){var a,s=i;for(var o=e+1;o<n;o++){var h=P(t[o],t[e],t[n]);if(h>s){a=o;s=h}}if(s>i){if(a-e>1)j(t,e,a,i,r);r.push(t[a]);if(n-a>1)j(t,a,n,i,r)}}function R(t,e){var n=t.length-1;var i=[t[0]];j(t,0,n,e,i);i.push(t[n]);return i}var St=function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(t.length<=2)return t;var i=e*e;t=n?t:L(t,i);t=R(t,i);return t};var At=.5;var Et=5;var Mt={};function W(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(t.length<3){if(e.verbose)console.error("polygon has to have at least 3 points",t);return null}var n=[];e=Object.assign({angle:xt.range(-90,90+Et,Et),cache:true,maxAspectRatio:15,minAspectRatio:1,minHeight:0,minWidth:0,nTries:20,tolerance:.02,verbose:false},e);var i=e.angle instanceof Array?e.angle:typeof e.angle==="number"?[e.angle]:typeof e.angle==="string"&&!isNaN(e.angle)?[Number(e.angle)]:[];var r=e.aspectRatio instanceof Array?e.aspectRatio:typeof e.aspectRatio==="number"?[e.aspectRatio]:typeof e.aspectRatio==="string"&&!isNaN(e.aspectRatio)?[Number(e.aspectRatio)]:[];var a=e.origin&&e.origin instanceof Array?e.origin[0]instanceof Array?e.origin:[e.origin]:[];var s;if(e.cache){s=xt.merge(t).join(",");s+="-".concat(e.minAspectRatio);s+="-".concat(e.maxAspectRatio);s+="-".concat(e.minHeight);s+="-".concat(e.minWidth);s+="-".concat(i.join(","));s+="-".concat(a.join(","));if(Mt[s])return Mt[s]}var o=Math.abs(mt.polygonArea(t));if(o===0){if(e.verbose)console.error("polygon has 0 area",t);return null}var h=xt.extent(t,function(t){return t[0]}),u=kt(h,2),c=u[0],l=u[1];var f=xt.extent(t,function(t){return t[1]}),_=kt(f,2),d=_[0],v=_[1];var p=Math.min(l-c,v-d)*e.tolerance;if(p>0)t=St(t,p);if(e.events)n.push({type:"simplify",poly:t});var y=xt.extent(t,function(t){return t[0]});var g=kt(y,2);c=g[0];l=g[1];var x=xt.extent(t,function(t){return t[1]});var m=kt(x,2);d=m[0];v=m[1];var k=l-c,b=v-d;var w=Math.min(k,b)/50;if(!a.length){var O=mt.polygonCentroid(t);if(!isFinite(O[0])){if(e.verbose)console.error("cannot find centroid",t);return null}if(mt.polygonContains(t,O))a.push(O);var C=e.nTries;while(C){var S=Math.random()*k+c;var A=Math.random()*b+d;var E=[S,A];if(mt.polygonContains(t,E)){a.push(E)}C--}}if(e.events)n.push({type:"origins",points:a});var M=0;var P=null;for(var L=0;L<i.length;L++){var j=i[L];var R=-j*Math.PI/180;if(e.events)n.push({type:"angle",angle:j});for(var W=0;W<a.length;W++){var T=a[W];var N=Ot(t,T,R),I=kt(N,2),B=I[0],H=I[1];var q=Ot(t,T,R+Math.PI/2),F=kt(q,2),D=F[0],z=F[1];var G=[];if(B&&H)G.push([(B[0]+H[0])/2,(B[1]+H[1])/2]);if(D&&z)G.push([(D[0]+z[0])/2,(D[1]+z[1])/2]);if(e.events)n.push({type:"modifOrigin",idx:W,p1W:B,p2W:H,p1H:D,p2H:z,modifOrigins:G});for(var V=0;V<G.length;V++){var U=G[V];if(e.events)n.push({type:"origin",cx:U[0],cy:U[1]});var X=Ot(t,U,R),Y=kt(X,2),K=Y[0],Z=Y[1];if(K===null||Z===null)continue;var J=Math.min(bt(U,K),bt(U,Z));var Q=2*Math.sqrt(J);var $=Ot(t,U,R+Math.PI/2),tt=kt($,2),et=tt[0],nt=tt[1];if(et===null||nt===null)continue;var it=Math.min(bt(U,et),bt(U,nt));var rt=2*Math.sqrt(it);if(Q*rt<M)continue;var at=r;if(!at.length){var st=Math.max(e.minAspectRatio,e.minWidth/rt,M/(rt*rt));var ot=Math.min(e.maxAspectRatio,Q/e.minHeight,Q*Q/M);at=xt.range(st,ot+At,At)}for(var ht=0;ht<at.length;ht++){var ut=at[ht];var ct=Math.max(e.minWidth,Math.sqrt(M*ut));var lt=Math.min(Q,rt*ut);if(lt*rt<M)continue;if(e.events&<-ct>=w)n.push({type:"aRatio",aRatio:ut});while(lt-ct>=w){var ft=(ct+lt)/2;var _t=ft/ut;var dt=kt(U,2),vt=dt[0],pt=dt[1];var yt=[[vt-ft/2,pt-_t/2],[vt+ft/2,pt-_t/2],[vt+ft/2,pt+_t/2],[vt-ft/2,pt+_t/2]];yt=Ct(yt,R,U);var gt=wt(yt,t);if(gt){M=ft*_t;yt.push(yt[0]);P={area:M,cx:vt,cy:pt,width:ft,height:_t,angle:-j,points:yt};ct=ft}else{lt=ft}if(e.events)n.push({type:"rectangle",areaFraction:ft*_t/o,cx:vt,cy:pt,width:ft,height:_t,angle:j,insidePoly:gt})}}}}}if(e.cache){Mt[s]=P}return e.events?Object.assign(P||{},{events:n}):P}var T=function(t){h(a,t);function a(){var r;c(this,a);r=_(this,l(a).call(this));r._curve="linear";r._defined=function(){return true};r._labelBounds=function(t,e,n){var i=W(n.points);if(!i)return null;return{angle:i.angle,width:i.width,height:i.height,x:i.cx-i.width/2-r._x(t,e),y:i.cy-i.height/2-r._y(t,e)}};r._labelConfig=Object.assign(r._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});r._name="Area";r._x=y.accessor("x");r._x0=y.accessor("x");r._x1=null;r._y=y.constant(0);r._y0=y.constant(0);r._y1=y.accessor("y");return r}n(a,[{key:"_aes",value:function t(e){var n=this;var i=e.values.slice().sort(function(t,e){return n._y1?n._x(t)-n._x(e):n._y(t)-n._y(e)});var r=i.map(function(t,e){return[n._x0(t,e),n._y0(t,e)]});var a=i.reverse().map(function(t,e){return n._y1?[n._x(t,e),n._y1(t,e)]:[n._x1(t,e),n._y(t,e)]});var s=r.concat(a);if(r[0][1]>a[0][1])s=s.reverse();s.push(s[0]);return{points:s}}},{key:"_dataFilter",value:function t(i){var r=this;var e=u.nest().key(this._id).entries(i).map(function(t){t.data=y.merge(t.values);t.i=i.indexOf(t.values[0]);var e=xt.extent(t.values.map(r._x).concat(t.values.map(r._x0)).concat(r._x1?t.values.map(r._x1):[]));t.xR=e;t.width=e[1]-e[0];t.x=e[0]+t.width/2;var n=xt.extent(t.values.map(r._y).concat(t.values.map(r._y0)).concat(r._y1?t.values.map(r._y1):[]));t.yR=n;t.height=n[1]-n[0];t.y=n[0]+t.height/2;t.nested=true;t.translate=[t.x,t.y];t.__d3plusShape__=true;return t});e.key=function(t){return t.key};return e}},{key:"render",value:function t(e){var n=this;m(l(a.prototype),"render",this).call(this,e);var i=this._path=g.area().defined(this._defined).curve(g["curve".concat(this._curve.charAt(0).toUpperCase()).concat(this._curve.slice(1))]).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);var r=g.area().defined(function(t){return t}).curve(g["curve".concat(this._curve.charAt(0).toUpperCase()).concat(this._curve.slice(1))]).x(this._x).y(this._y).x0(function(t,e){return n._x1?n._x0(t,e)+(n._x1(t,e)-n._x0(t,e))/2:n._x0(t,e)}).x1(function(t,e){return n._x1?n._x0(t,e)+(n._x1(t,e)-n._x0(t,e))/2:n._x0(t,e)}).y0(function(t,e){return n._y1?n._y0(t,e)+(n._y1(t,e)-n._y0(t,e))/2:n._y0(t,e)}).y1(function(t,e){return n._y1?n._y0(t,e)+(n._y1(t,e)-n._y0(t,e))/2:n._y0(t,e)});this._enter.append("path").attr("transform",function(t){return"translate(".concat(-t.xR[0]-t.width/2,", ").concat(-t.yR[0]-t.height/2,")")}).attr("d",function(t){return r(t.values)}).call(this._applyStyle.bind(this)).transition(this._transition).attrTween("d",function(t){return o.interpolatePath(v.select(this).attr("d"),i(t.values))});this._update.select("path").transition(this._transition).attr("transform",function(t){return"translate(".concat(-t.xR[0]-t.width/2,", ").concat(-t.yR[0]-t.height/2,")")}).attrTween("d",function(t){return o.interpolatePath(v.select(this).attr("d"),i(t.values))}).call(this._applyStyle.bind(this));this._exit.select("path").transition(this._transition).attrTween("d",function(t){return o.interpolatePath(v.select(this).attr("d"),r(t.values))});return this}},{key:"curve",value:function t(e){return arguments.length?(this._curve=e,this):this._curve}},{key:"defined",value:function t(e){return arguments.length?(this._defined=e,this):this._defined}},{key:"x",value:function t(e){if(!arguments.length)return this._x;this._x=typeof e==="function"?e:y.constant(e);this._x0=this._x;return this}},{key:"x0",value:function t(e){if(!arguments.length)return this._x0;this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this}},{key:"x1",value:function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1}},{key:"y",value:function t(e){if(!arguments.length)return this._y;this._y=typeof e==="function"?e:y.constant(e);this._y0=this._y;return this}},{key:"y0",value:function t(e){if(!arguments.length)return this._y0;this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this}},{key:"y1",value:function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1}}]);return a}(e);var N=function(t){h(a,t);function a(){var i;c(this,a);i=_(this,l(a).call(this,"rect"));i._name="Bar";i._height=y.constant(10);i._labelBounds=function(t,e,n){return{width:n.width,height:n.height,x:i._x1!==null?i._getX(t,e):-n.width/2,y:i._x1===null?i._getY(t,e):-n.height/2}};i._width=y.constant(10);i._x=y.accessor("x");i._x0=y.accessor("x");i._x1=null;i._y=y.constant(0);i._y0=y.constant(0);i._y1=y.accessor("y");return i}n(a,[{key:"render",value:function t(e){var n=this;m(l(a.prototype),"render",this).call(this,e);var i=this._enter.attr("width",function(t,e){return n._x1===null?n._getWidth(t,e):0}).attr("height",function(t,e){return n._x1!==null?n._getHeight(t,e):0}).attr("x",function(t,e){return n._x1===null?-n._getWidth(t,e)/2:0}).attr("y",function(t,e){return n._x1!==null?-n._getHeight(t,e)/2:0}).call(this._applyStyle.bind(this));var r=this._update;if(this._duration){i=i.transition(this._transition);r=r.transition(this._transition);this._exit.transition(this._transition).attr("width",function(t,e){return n._x1===null?n._getWidth(t,e):0}).attr("height",function(t,e){return n._x1!==null?n._getHeight(t,e):0}).attr("x",function(t,e){return n._x1===null?-n._getWidth(t,e)/2:0}).attr("y",function(t,e){return n._x1!==null?-n._getHeight(t,e)/2:0})}i.call(this._applyPosition.bind(this));r.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));return this}},{key:"_aes",value:function t(e,n){return{height:this._getHeight(e,n),width:this._getWidth(e,n)}}},{key:"_applyPosition",value:function t(e){var n=this;e.attr("width",function(t,e){return n._getWidth(t,e)}).attr("height",function(t,e){return n._getHeight(t,e)}).attr("x",function(t,e){return n._x1!==null?n._getX(t,e):-n._getWidth(t,e)/2}).attr("y",function(t,e){return n._x1===null?n._getY(t,e):-n._getHeight(t,e)/2})}},{key:"_getHeight",value:function t(e,n){if(this._x1!==null)return this._height(e,n);return Math.abs(this._y1(e,n)-this._y(e,n))}},{key:"_getWidth",value:function t(e,n){if(this._x1===null)return this._width(e,n);return Math.abs(this._x1(e,n)-this._x(e,n))}},{key:"_getX",value:function t(e,n){var i=this._x1===null?this._x(e,n):this._x1(e,n)-this._x(e,n);if(i<0)return i;else return 0}},{key:"_getY",value:function t(e,n){var i=this._x1!==null?this._y(e,n):this._y1(e,n)-this._y(e,n);if(i<0)return i;else return 0}},{key:"height",value:function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height}},{key:"width",value:function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width}},{key:"x0",value:function t(e){if(!arguments.length)return this._x0;this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this}},{key:"x1",value:function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1}},{key:"y0",value:function t(e){if(!arguments.length)return this._y0;this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this}},{key:"y1",value:function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1}}]);return a}(e);var I=function(t){h(r,t);function r(){var t;c(this,r);t=_(this,l(r).call(this,"circle"));t._labelBounds=function(t,e,n){return{width:n.r*1.5,height:n.r*1.5,x:-n.r*.75,y:-n.r*.75}};t._labelConfig=y.assign(t._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});t._name="Circle";t._r=y.accessor("r");return t}n(r,[{key:"_applyPosition",value:function t(e){var n=this;e.attr("r",function(t,e){return n._r(t,e)}).attr("x",function(t,e){return-n._r(t,e)/2}).attr("y",function(t,e){return-n._r(t,e)/2})}},{key:"render",value:function t(e){m(l(r.prototype),"render",this).call(this,e);var n=this._enter.call(this._applyStyle.bind(this));var i=this._update;if(this._duration){n.attr("r",0).attr("x",0).attr("y",0).transition(this._transition).call(this._applyPosition.bind(this));i=i.transition(this._transition);this._exit.transition(this._transition).attr("r",0).attr("x",0).attr("y",0)}else{n.call(this._applyPosition.bind(this))}i.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));return this}},{key:"_aes",value:function t(e,n){return{r:this._r(e,n)}}},{key:"r",value:function t(e){return arguments.length?(this._r=typeof e==="function"?e:y.constant(e),this):this._r}}]);return r}(e);var B=function(t){h(r,t);function r(){var t;c(this,r);t=_(this,l(r).call(this,"rect"));t._height=y.accessor("height");t._labelBounds=function(t,e,n){return{width:n.width,height:n.height,x:-n.width/2,y:-n.height/2}};t._name="Rect";t._width=y.accessor("width");return t}n(r,[{key:"render",value:function t(e){m(l(r.prototype),"render",this).call(this,e);var n=this._enter.attr("width",0).attr("height",0).attr("x",0).attr("y",0).call(this._applyStyle.bind(this));var i=this._update;if(this._duration){n=n.transition(this._transition);i=i.transition(this._transition);this._exit.transition(this._transition).attr("width",0).attr("height",0).attr("x",0).attr("y",0)}n.call(this._applyPosition.bind(this));i.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));return this}},{key:"_aes",value:function t(e,n){return{width:this._width(e,n),height:this._height(e,n)}}},{key:"_applyPosition",value:function t(e){var n=this;e.attr("width",function(t,e){return n._width(t,e)}).attr("height",function(t,e){return n._height(t,e)}).attr("x",function(t,e){return-n._width(t,e)/2}).attr("y",function(t,e){return-n._height(t,e)/2})}},{key:"height",value:function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height}},{key:"width",value:function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width}}]);return r}(e);var H=function(t){h(s,t);function s(){var n;c(this,s);n=_(this,l(s).call(this));n._curve="linear";n._defined=function(t){return t};n._fill=y.constant("none");n._hitArea=y.constant({d:function t(e){return n._path(e.values)},fill:"none","stroke-width":10,transform:null});n._name="Line";n._path=g.line();n._stroke=y.constant("black");n._strokeWidth=y.constant(1);return n}n(s,[{key:"_dataFilter",value:function t(i){var r=this;var e=u.nest().key(this._id).entries(i).map(function(t){t.data=y.merge(t.values);t.i=i.indexOf(t.values[0]);var e=xt.extent(t.values,r._x);t.xR=e;t.width=e[1]-e[0];t.x=e[0]+t.width/2;var n=xt.extent(t.values,r._y);t.yR=n;t.height=n[1]-n[0];t.y=n[0]+t.height/2;t.nested=true;t.translate=[t.x,t.y];t.__d3plusShape__=true;return t});e.key=function(t){return t.key};return e}},{key:"render",value:function t(e){var n=this;m(l(s.prototype),"render",this).call(this,e);var i=this;this._path.curve(g["curve".concat(this._curve.charAt(0).toUpperCase()).concat(this._curve.slice(1))]).defined(this._defined).x(this._x).y(this._y);var r=this._enter.append("path").attr("transform",function(t){return"translate(".concat(-t.xR[0]-t.width/2,", ").concat(-t.yR[0]-t.height/2,")")}).attr("d",function(t){return n._path(t.values)}).call(this._applyStyle.bind(this));var a=this._update.select("path").attr("stroke-dasharray","0");if(this._duration){r.each(function(t){t.initialLength=this.getTotalLength()}).attr("stroke-dasharray",function(t){return"".concat(t.initialLength," ").concat(t.initialLength)}).attr("stroke-dashoffset",function(t){return t.initialLength}).transition(this._transition).attr("stroke-dashoffset",0);a=a.transition(this._transition).attrTween("d",function(t){return o.interpolatePath(v.select(this).attr("d"),i._path(t.values))});this._exit.selectAll("path").attr("stroke-dasharray",function(t){return"".concat(t.initialLength," ").concat(t.initialLength)}).transition(this._transition).attr("stroke-dashoffset",function(t){return-t.initialLength})}else{a=a.attr("d",function(t){return i._path(t.values)})}a.attr("transform",function(t){return"translate(".concat(-t.xR[0]-t.width/2,", ").concat(-t.yR[0]-t.height/2,")")}).call(this._applyStyle.bind(this));return this}},{key:"_aes",value:function t(e,n){var i=this;return{points:e.values.map(function(t){return[i._x(t,n),i._y(t,n)]})}}},{key:"curve",value:function t(e){return arguments.length?(this._curve=e,this):this._curve}},{key:"defined",value:function t(e){return arguments.length?(this._defined=e,this):this._defined}}]);return s}(e);var q={Circle:I,Rect:B};var F=function(t){h(e,t);function e(){var t;c(this,e);t=_(this,l(e).call(this));t._endpoint=y.accessor("endpoint","Rect");t._endpointConfig={Circle:{r:y.accessor("r",5)}};t._length=y.accessor("length",25);t._lineConfig={};t._orient=y.accessor("orient","top");t._x=y.accessor("x",0);t._y=y.accessor("y",0);return t}n(e,[{key:"render",value:function t(e){var o=this;if(this._select===void 0){this.select(v.select("body").append("svg").style("width","".concat(window.innerWidth,"px")).style("height","".concat(window.innerHeight,"px")).style("display","block").node())}var h=[];this._data.forEach(function(t,e){var n=o._orient(t,e);var i=o._x(t,e);var r=o._y(t,e);var a=i;if(n==="left")a-=o._length(t,e);else if(n==="right")a+=o._length(t,e);var s=r;if(n==="top")s-=o._length(t,e);else if(n==="bottom")s+=o._length(t,e);h.push({__d3plus__:true,data:t,i:e,id:e,x:i,y:r});h.push({__d3plus__:true,data:t,i:e,id:e,x:a,y:s})});this._line=(new H).data(h).select(y.elem("g.d3plus-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._lineConfig,"shape")).render(e);var n=this._data.map(function(t,e){var n={};n.__d3plus__=true;n.data=t;n.i=e;n.endpoint=o._endpoint(t,e);n.length=o._length(t,e);n.orient=o._orient(t,e);var i=o._x(t,e);if(n.orient==="left")i-=n.length;else if(n.orient==="right")i+=n.length;var r=o._y(t,e);if(n.orient==="top")r-=n.length;else if(n.orient==="bottom")r+=n.length;n.x=i;n.y=r;return n});this._whiskerEndpoint=[];u.nest().key(function(t){return t.endpoint}).entries(n).forEach(function(t){var e=t.key;o._whiskerEndpoint.push((new q[e]).data(t.values).select(y.elem("g.d3plus-Whisker-Endpoint-".concat(e),{parent:o._select}).node()).config({height:function t(e){return e.orient==="top"||e.orient==="bottom"?5:20},width:function t(e){return e.orient==="top"||e.orient==="bottom"?20:5}}).config(y.configPrep.bind(o)(o._endpointConfig,"shape",e)).render())});return this}},{key:"active",value:function t(e){if(this._line)this._line.active(e);if(this._whiskerEndpoint)this._whiskerEndpoint.forEach(function(t){return t.active(e)})}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"endpoint",value:function t(e){return arguments.length?(this._endpoint=typeof e==="function"?e:y.constant(e),this):this._endpoint}},{key:"endpointConfig",value:function t(e){return arguments.length?(this._endpointConfig=y.assign(this._endpointConfig,e),this):this._endpointConfig}},{key:"hover",value:function t(e){if(this._line)this._line.hover(e);if(this._whiskerEndpoint)this._whiskerEndpoint.forEach(function(t){return t.hover(e)})}},{key:"length",value:function t(e){return arguments.length?(this._length=typeof e==="function"?e:y.constant(e),this):this._length}},{key:"lineConfig",value:function t(e){return arguments.length?(this._lineConfig=y.assign(this._lineConfig,e),this):this._lineConfig}},{key:"orient",value:function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient}},{key:"select",value:function t(e){return arguments.length?(this._select=v.select(e),this):this._select}},{key:"x",value:function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x}},{key:"y",value:function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y}}]);return e}(y.BaseClass);var D={Circle:I,Rect:B};var z=function(t){h(e,t);function e(){var i;c(this,e);i=_(this,l(e).call(this));i._medianConfig={fill:y.constant("black")};i._orient=y.accessor("orient","vertical");i._outlier=y.accessor("outlier","Circle");i._outlierConfig={Circle:{r:y.accessor("r",5)},Rect:{height:function t(e,n){return i._orient(e,n)==="vertical"?5:20},width:function t(e,n){return i._orient(e,n)==="vertical"?20:5}}};i._rectConfig={fill:y.constant("white"),stroke:y.constant("black"),strokeWidth:y.constant(1)};i._rectWidth=y.constant(50);i._whiskerConfig={};i._whiskerMode=["tukey","tukey"];i._x=y.accessor("x",250);i._y=y.accessor("y",250);return i}n(e,[{key:"render",value:function t(){var a=this;if(this._select===void 0){this.select(v.select("body").append("svg").style("width","".concat(window.innerWidth,"px")).style("height","".concat(window.innerHeight,"px")).style("display","block").node())}var s=[];var e=u.nest().key(function(t,e){return a._orient(t,e)==="vertical"?a._x(t,e):a._y(t,e)}).entries(this._data).map(function(r){r.data=y.merge(r.values);r.i=a._data.indexOf(r.values[0]);r.orient=a._orient(r.data,r.i);var t=r.values.map(r.orient==="vertical"?a._y:a._x);t.sort(function(t,e){return t-e});r.first=xt.quantile(t,.25);r.median=xt.quantile(t,.5);r.third=xt.quantile(t,.75);var e=a._whiskerMode;if(e[0]==="tukey"){r.lowerLimit=r.first-(r.third-r.first)*1.5;if(r.lowerLimit<xt.min(t))r.lowerLimit=xt.min(t)}else if(e[0]==="extent")r.lowerLimit=xt.min(t);else if(typeof e[0]==="number")r.lowerLimit=xt.quantile(t,e[0]);if(e[1]==="tukey"){r.upperLimit=r.third+(r.third-r.first)*1.5;if(r.upperLimit>xt.max(t))r.upperLimit=xt.max(t)}else if(e[1]==="extent")r.upperLimit=xt.max(t);else if(typeof e[1]==="number")r.upperLimit=xt.quantile(t,e[1]);var n=r.third-r.first;if(r.orient==="vertical"){r.height=n;r.width=a._rectWidth(r.data,r.i);r.x=a._x(r.data,r.i);r.y=r.first+n/2}else if(r.orient==="horizontal"){r.height=a._rectWidth(r.data,r.i);r.width=n;r.x=r.first+n/2;r.y=a._y(r.data,r.i)}r.values.forEach(function(t,e){var n=r.orient==="vertical"?a._y(t,e):a._x(t,e);if(n<r.lowerLimit||n>r.upperLimit){var i={};i.__d3plus__=true;i.data=t;i.i=e;i.outlier=a._outlier(t,e);if(r.orient==="vertical"){i.x=r.x;i.y=n;s.push(i)}else if(r.orient==="horizontal"){i.y=r.y;i.x=n;s.push(i)}}});r.__d3plus__=true;return r});this._box=(new B).data(e).x(function(t){return t.x}).y(function(t){return t.y}).select(y.elem("g.d3plus-Box",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._rectConfig,"shape")).render();this._median=(new B).data(e).x(function(t){return t.orient==="vertical"?t.x:t.median}).y(function(t){return t.orient==="vertical"?t.median:t.y}).height(function(t){return t.orient==="vertical"?1:t.height}).width(function(t){return t.orient==="vertical"?t.width:1}).select(y.elem("g.d3plus-Box-Median",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._medianConfig,"shape")).render();var c=[];e.forEach(function(t,e){var n=t.x;var i=t.y;var r=t.first-t.lowerLimit;var a=t.upperLimit-t.third;if(t.orient==="vertical"){var s=i-t.height/2;var o=i+t.height/2;c.push({__d3plus__:true,data:t,i:e,x:n,y:s,length:r,orient:"top"},{__d3plus__:true,data:t,i:e,x:n,y:o,length:a,orient:"bottom"})}else if(t.orient==="horizontal"){var h=n+t.width/2;var u=n-t.width/2;c.push({__d3plus__:true,data:t,i:e,x:h,y:i,length:a,orient:"right"},{__d3plus__:true,data:t,i:e,x:u,y:i,length:r,orient:"left"})}});this._whisker=(new F).data(c).select(y.elem("g.d3plus-Box-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._whiskerConfig,"shape")).render();this._whiskerEndpoint=[];u.nest().key(function(t){return t.outlier}).entries(s).forEach(function(t){var e=t.key;a._whiskerEndpoint.push((new D[e]).data(t.values).select(y.elem("g.d3plus-Box-Outlier-".concat(e),{parent:a._select}).node()).config(y.configPrep.bind(a)(a._outlierConfig,"shape",e)).render())});return this}},{key:"active",value:function t(e){if(this._box)this._box.active(e);if(this._median)this._median.active(e);if(this._whisker)this._whisker.active(e);if(this._whiskerEndpoint)this._whiskerEndpoint.forEach(function(t){return t.active(e)})}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"hover",value:function t(e){if(this._box)this._box.hover(e);if(this._median)this._median.hover(e);if(this._whisker)this._whisker.hover(e);if(this._whiskerEndpoint)this._whiskerEndpoint.forEach(function(t){return t.hover(e)})}},{key:"medianConfig",value:function t(e){return arguments.length?(this._medianConfig=y.assign(this._medianConfig,e),this):this._medianConfig}},{key:"orient",value:function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient}},{key:"outlier",value:function t(e){return arguments.length?(this._outlier=typeof e==="function"?e:y.constant(e),this):this._outlier}},{key:"outlierConfig",value:function t(e){return arguments.length?(this._outlierConfig=y.assign(this._outlierConfig,e),this):this._outlierConfig}},{key:"rectConfig",value:function t(e){return arguments.length?(this._rectConfig=y.assign(this._rectConfig,e),this):this._rectConfig}},{key:"rectWidth",value:function t(e){return arguments.length?(this._rectWidth=typeof e==="function"?e:y.constant(e),this):this._rectWidth}},{key:"select",value:function t(e){return arguments.length?(this._select=v.select(e),this):this._select}},{key:"whiskerConfig",value:function t(e){return arguments.length?(this._whiskerConfig=y.assign(this._whiskerConfig,e),this):this._whiskerConfig}},{key:"whiskerMode",value:function t(e){return arguments.length?(this._whiskerMode=e instanceof Array?e:[e,e],this):this._whiskerMode}},{key:"x",value:function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.accessor(e),this):this._x}},{key:"y",value:function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.accessor(e),this):this._y}}]);return e}(y.BaseClass);var G=Math.PI;var V=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"circle";if(t<0)t=G*2+t;if(n==="square"){var i=45*(G/180);var r=0,a=0;if(t<G/2){var s=Math.tan(t);r+=t<i?e:e/s;a+=t<i?s*e:e}else if(t<=G){var o=Math.tan(G-t);r-=t<G-i?e/o:e;a+=t<G-i?e:o*e}else if(t<i+G){r-=e;a-=Math.tan(t-G)*e}else if(t<3*G/2){r-=e/Math.tan(t-G);a-=e}else if(t<2*G-i){r+=e/Math.tan(2*G-t);a-=e}else{r+=e;a-=Math.tan(2*G-t)*e}return[r,a]}else if(n==="circle"){return[e*Math.cos(t),e*Math.sin(t)]}else return null};var U=Math.PI;var X=function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:20;var n=[],i=/([MLA])([^MLAZ]+)/gi;var r=i.exec(t);while(r!=