d3plus-shape
Advanced tools
Comparing version 0.16.4 to 0.16.5
/* | ||
d3plus-shape v0.16.4 | ||
d3plus-shape v0.16.5 | ||
Fancy SVG shapes for visualizations | ||
@@ -7,2 +7,2 @@ Copyright (c) 2019 D3plus - https://d3plus.org | ||
*/ | ||
if(typeof Object.assign!=="function"){Object.defineProperty(Object,"assign",{value:function t(e){"use strict";if(e===null){throw new TypeError("Cannot convert undefined or null to object")}var i=Object(e);for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r!==null){for(var s in r){if(Object.prototype.hasOwnProperty.call(r,s)){i[s]=r[s]}}}}return i},writable:true,configurable:true})}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function t(e,i){var n=Object(this);var r=n.length>>>0;if(r===0)return false;var s=i|0;var o=Math.max(s>=0?s:r-Math.abs(s),0);function a(t,e){return t===e||typeof t==="number"&&typeof e==="number"&&isNaN(t)&&isNaN(e)}while(o<r){if(a(n[o],e)){return true}o++}return false}})}if(!String.prototype.includes){Object.defineProperty(String.prototype,"includes",{value:function(t,e){if(typeof e!=="number"){e=0}if(e+t.length>this.length){return false}else{return this.indexOf(t,e)!==-1}}})}if(!Array.prototype.find){Object.defineProperty(Array.prototype,"find",{value:function(t){if(this==null){throw new TypeError('"this" is null or not defined')}var e=Object(this);var i=e.length>>>0;if(typeof t!=="function"){throw new TypeError("predicate must be a function")}var n=arguments[1];var r=0;while(r<i){var s=e[r];if(t.call(n,s,r,e)){return s}r++}return undefined},configurable:true,writable:true})}if(!String.prototype.startsWith){Object.defineProperty(String.prototype,"startsWith",{value:function(t,e){e=!e||e<0?0:+e;return this.substring(e,e+t.length)===t}})}if(typeof window!=="undefined"){(function(){var n=function(t,e){var i=t.nodeType;if(i===3){e.push(t.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(i===1){e.push("<",t.tagName);if(t.hasAttributes()){[].forEach.call(t.attributes,function(t){e.push(" ",t.item.name,"='",t.item.value,"'")})}if(t.hasChildNodes()){e.push(">");[].forEach.call(t.childNodes,function(t){n(t,e)});e.push("</",t.tagName,">")}else{e.push("/>")}}else if(i==8){e.push("\x3c!--",t.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var t=[];var e=this.firstChild;while(e){n(e,t);e=e.nextSibling}return t.join("")},set:function(t){while(this.firstChild){this.removeChild(this.firstChild)}try{var e=new DOMParser;e.async=false;var i="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>";var n=e.parseFromString(i,"text/xml").documentElement;var r=n.firstChild;while(r){this.appendChild(this.ownerDocument.importNode(r,true));r=r.nextSibling}}catch(t){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})})()}(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-polygon"),require("d3-collection"),require("d3-interpolate-path")):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-polygon","d3-collection","d3-interpolate-path"],e):e(t.d3plus={},t.d3Selection,t.d3Transition,t.d3plusCommon,t.d3Array,t.d3Color,t.d3plusColor,t.paths,t.d3plusText,t.d3Polygon,t.d3Collection,t.d3InterpolatePath)})(this,function(t,f,d,y,ct,r,i,v,g,ut,l,o){"use strict";var h=function t(){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)};h.prototype.render=function t(e){var i=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var n=this._select.selectAll(".d3plus-Image").data(this._data,this._id);var r=n.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",function(t,e){return i._x(t,e)+i._width(t,e)/2}).attr("y",function(t,e){return i._y(t,e)+i._height(t,e)/2});var s=d.transition().duration(this._duration),o=this,a=r.merge(n);a.attr("xlink:href",this._url).style("pointer-events",this._pointerEvents).transition(s).attr("opacity",1).attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return i._x(t,e)}).attr("y",function(t,e){return i._y(t,e)}).each(function(t,e){var i=f.select(this),n=o._url(t,e);var r=n.indexOf("http://")===0||n.indexOf("https://")===0;if(!r||n.indexOf(window.location.hostname)===0){var s=new h;s.src=n;s.crossOrigin="Anonymous";s.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);i.attr("xlink:href",t.toDataURL("image/png"))}}});n.exit().transition(s).attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return i._x(t,e)}).attr("y",function(t,e){return i._y(t,e)}).attr("opacity",0).remove();if(e){setTimeout(e,this._duration+100)}return this};h.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};h.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};h.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};h.prototype.id=function t(e){return arguments.length?(this._id=e,this):this._id};h.prototype.pointerEvents=function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents};h.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};h.prototype.url=function t(e){return arguments.length?(this._url=e,this):this._url};h.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};h.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};h.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};function pt(t,e){var i=e[0]-t[0],n=e[1]-t[1];return i*i+n*n}function x(t,e){return Math.sqrt(pt(t,e))}var e=function(e){function t(t){var n=this;if(t===void 0)t="g";e.call(this);this._activeOpacity=.25;this._activeStyle={stroke:function(t,e){var i=n._fill(t,e);if(["transparent","none"].includes(i)){i=n._stroke(t,e)}return r.color(i).darker(1)},"stroke-width":function(t,e){var i=n._strokeWidth(t,e)||1;return i*3}};this._ariaLabel=y.constant("");this._backgroundImage=y.constant(false);this._backgroundImageClass=new h;this._data=[];this._duration=600;this._fill=y.constant("black");this._fillOpacity=y.constant(1);this._hoverOpacity=.5;this._hoverStyle={stroke:function(t,e){var i=n._fill(t,e);if(["transparent","none"].includes(i)){i=n._stroke(t,e)}return r.color(i).darker(.5)},"stroke-width":function(t,e){var i=n._strokeWidth(t,e)||1;return i*2}};this._id=function(t,e){return t.id!==void 0?t.id:e};this._label=y.constant(false);this._labelClass=new g.TextBox;this._labelConfig={fontColor:function(t,e){return i.colorContrast(n._fill(t,e))},fontSize:12,padding:5};this._name="Shape";this._opacity=y.constant(1);this._pointerEvents=y.constant("visiblePainted");this._role=y.constant("presentation");this._rotate=y.constant(0);this._rx=y.constant(0);this._ry=y.constant(0);this._scale=y.constant(1);this._shapeRendering=y.constant("geometricPrecision");this._stroke=function(t,e){return r.color(n._fill(t,e)).darker(1)};this._strokeDasharray=y.constant("0");this._strokeLinecap=y.constant("butt");this._strokeOpacity=y.constant(1);this._strokeWidth=y.constant(0);this._tagName=t;this._textAnchor=y.constant("start");this._vectorEffect=y.constant("non-scaling-stroke");this._verticalAlign=y.constant("top");this._x=y.accessor("x",0);this._y=y.accessor("y",0)}if(e)t.__proto__=e;t.prototype=Object.create(e&&e.prototype);t.prototype.constructor=t;t.prototype._aes=function t(){return{}};t.prototype._applyEvents=function t(e){var s=this;var o=Object.keys(this._on);var i=function(r){e.on(o[r],function(t,e){if(!s._on[o[r]]){return}if(t.i!==void 0){e=t.i}if(t.nested&&t.values){var i=f.mouse(s._select.node()),n=t.values.map(function(t){return x(i,[s._x(t,e),s._y(t,e)])});t=t.values[n.indexOf(ct.min(n))]}s._on[o[r]].bind(s)(t,e)})};for(var n=0;n<o.length;n++)i(n)};t.prototype._updateStyle=function t(e,i){var n=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],n._data.indexOf(t.values[0])):this(t,e)}var s={};for(var o in i){if({}.hasOwnProperty.call(i,o)){s[o]=r.bind(i[o])}}e.transition().duration(0).call(y.attrize,s)};t.prototype._applyStyle=function t(e){var i=this;if(e.size()&&e.node().tagName==="g"){e=e.selectAll("*")}function n(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)}e.attr("fill",n.bind(this._fill)).attr("fill-opacity",n.bind(this._fillOpacity)).attr("rx",n.bind(this._rx)).attr("ry",n.bind(this._ry)).attr("stroke",n.bind(this._stroke)).attr("stroke-dasharray",n.bind(this._strokeDasharray)).attr("stroke-linecap",n.bind(this._strokeLinecap)).attr("stroke-opacity",n.bind(this._strokeOpacity)).attr("stroke-width",n.bind(this._strokeWidth)).attr("vector-effect",n.bind(this._vectorEffect))};t.prototype._applyTransform=function t(e){var i=this;e.attr("transform",function(t,e){return"\n translate("+(t.__d3plusShape__?t.translate?t.translate:i._x(t.data,t.i)+","+i._y(t.data,t.i):i._x(t,e)+","+i._y(t,e))+")\n scale("+(t.__d3plusShape__?t.scale||i._scale(t.data,t.i):i._scale(t,e))+")\n rotate("+(t.__d3plusShape__?t.rotate?t.rotate:i._rotate(t.data||t,t.i):i._rotate(t.data||t,t.i))+")"})};t.prototype._nestWrapper=function t(i){return function(t,e){return i(t.__d3plusShape__?t.data:t,t.__d3plusShape__?t.i:e)}};t.prototype._renderActive=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 i=t.parentNode;if(f.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 n=!r._active||typeof r._active!=="function"||!r._active(t,e)?i:r._activeGroup.node();if(n!==this.parentNode){n.appendChild(this);if(this.className.baseVal.includes("d3plus-Shape")){if(i===n){f.select(this).call(r._applyStyle.bind(r))}else{f.select(this).call(r._updateStyle.bind(r,f.select(this),r._activeStyle))}}}});this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text").attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)};t.prototype._renderHover=function t(){var r=this;this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text, g.d3plus-"+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 i=t.parentNode;if(f.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 n=!r._hover||typeof r._hover!=="function"||!r._hover(t,e)?i:r._hoverGroup.node();if(n!==this.parentNode){n.appendChild(this)}if(this.className.baseVal.includes("d3plus-Shape")){if(i===n){f.select(this).call(r._applyStyle.bind(r))}else{f.select(this).call(r._updateStyle.bind(r,f.select(this),r._hoverStyle))}}});this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text").attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)};t.prototype._renderImage=function t(){var l=this;var c=[];this._update.merge(this._enter).data().forEach(function(t,e){var i=l._aes(t,e);if(i.r||i.width&&i.height){var n=t;if(t.nested&&t.key&&t.values){n=t.values[0];e=l._data.indexOf(n)}var r=i.r?i.r*2:i.height,s=l._backgroundImage(n,e),o=i.r?i.r*2:i.width;if(s){var a=n.__d3plusShape__?n.translate?n.translate[0]:l._x(n.data,n.i):l._x(n,e),h=n.__d3plusShape__?n.translate?n.translate[1]:l._y(n.data,n.i):l._y(n,e);if(i.x){a+=i.x}if(i.y){h+=i.y}if(n.__d3plusShape__){n=n.data;e=n.i}c.push({__d3plus__:true,data:n,height:r,i:e,id:l._id(n,e),url:s,width:o,x:a+-o/2,y:h+-r/2})}}});this._backgroundImageClass.data(c).duration(this._duration).pointerEvents("none").select(y.elem("g.d3plus-"+this._name+"-image",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).render()};t.prototype._renderLabels=function t(){var p=this;var _=[];this._update.merge(this._enter).data().forEach(function(t,e){var i=t;if(t.nested&&t.key&&t.values){i=t.values[0];e=p._data.indexOf(i)}var n=p._label(i,e);if(p._labelBounds&&n!==false&&n!==undefined&&n!==null){var r=p._labelBounds(i,e,p._aes(t,e));if(r){if(n.constructor!==Array){n=[n]}var s=i.__d3plusShape__?i.translate?i.translate[0]:p._x(i.data,i.i):p._x(i,e),o=i.__d3plusShape__?i.translate?i.translate[1]:p._y(i.data,i.i):p._y(i,e);if(i.__d3plusShape__){i=i.data;e=i.i}for(var a=0;a<n.length;a++){var h=r.constructor===Array?r[a]:Object.assign({},r);var l=p._rotate(i,e);var c=i.labelConfig&&i.labelConfig.rotate?i.labelConfig.rotate:r.angle!==undefined?r.angle:0;c+=l;var u=l!==0?[h.x*-1||0,h.y*-1||0]:[h.width/2,h.height/2];_.push({__d3plus__:true,data:i,height:h.height,l:a,id:p._id(i,e)+"_"+a,r:c,rotateAnchor:u,text:n[a],width:h.width,x:s+h.x,y:o+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-"+this._name+"-text",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).config(y.configPrep.bind(this)(this._labelConfig)).render()};t.prototype.render=function t(e){var i=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}this._transition=d.transition().duration(this._duration);var n=this._data,r=this._id;if(this._dataFilter){n=this._dataFilter(n);if(n.key){r=n.key}}if(this._sort){n=n.sort(function(t,e){while(t.__d3plusShape__||t.__d3plus__){t=t.data}while(e.__d3plusShape__||e.__d3plus__){e=e.data}return i._sort(t,e)})}f.selectAll("g.d3plus-"+this._name+"-hover > *, g.d3plus-"+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-"+this._name+"-group",{parent:this._select});var s=this._update=y.elem("g.d3plus-"+this._name+"-shape",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).selectAll(".d3plus-"+this._name).data(n,r);s.order().transition(this._transition).call(this._applyTransform.bind(this));var o=this._enter=s.enter().append(this._tagName).attr("class",function(t,e){return"d3plus-Shape d3plus-"+i._name+" d3plus-id-"+g.strip(i._nestWrapper(i._id)(t,e))}).call(this._applyTransform.bind(this)).attr("aria-label",this._ariaLabel).attr("role",this._role).attr("opacity",this._nestWrapper(this._opacity));var a=o.merge(s);a.attr("shape-rendering",this._nestWrapper(this._shapeRendering)).attr("pointer-events","none").transition(this._transition).attr("opacity",this._nestWrapper(this._opacity)).attr("pointer-events",this._pointerEvents);var h=this._exit=s.exit();h.transition().delay(this._duration).remove();this._renderImage();this._renderLabels();this._hoverGroup=y.elem("g.d3plus-"+this._name+"-hover",{parent:this._group});this._activeGroup=y.elem("g.d3plus-"+this._name+"-active",{parent:this._group});var l=this._group.selectAll(".d3plus-HitArea").data(this._hitArea?n:[],r);l.order().call(this._applyTransform.bind(this));var c=this._name==="Line";c&&this._path.curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).defined(this._defined).x(this._x).y(this._y);var u=l.enter().append(c?"path":"rect").attr("class",function(t,e){return"d3plus-HitArea d3plus-id-"+g.strip(i._nestWrapper(i._id)(t,e))}).attr("fill","black").attr("stroke","black").attr("pointer-events","painted").attr("opacity",0).call(this._applyTransform.bind(this));var p=this;var _=l.merge(u).each(function(t){var e=p._data.indexOf(t);var i=p._hitArea(t,e,p._aes(t,e));return i&&!(p._name==="Line"&&parseFloat(p._strokeWidth(t,e))>10)?f.select(this).call(y.attrize,i):f.select(this).remove()});l.exit().remove();this._applyEvents(this._hitArea?_:a);setTimeout(function(){if(i._active){i._renderActive()}else if(i._hover){i._renderHover()}if(e){e()}},this._duration+100);return this};t.prototype.active=function t(e){if(!arguments.length||e===undefined){return this._active}this._active=e;if(this._group){this._renderActive()}return this};t.prototype.activeOpacity=function t(e){return arguments.length?(this._activeOpacity=e,this):this._activeOpacity};t.prototype.activeStyle=function t(e){return arguments.length?(this._activeStyle=y.assign({},this._activeStyle,e),this):this._activeStyle};t.prototype.ariaLabel=function t(e){return e!==undefined?(this._ariaLabel=typeof e==="function"?e:y.constant(e),this):this._ariaLabel};t.prototype.backgroundImage=function t(e){return arguments.length?(this._backgroundImage=typeof e==="function"?e:y.constant(e),this):this._backgroundImage};t.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};t.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};t.prototype.fill=function t(e){return arguments.length?(this._fill=typeof e==="function"?e:y.constant(e),this):this._fill};t.prototype.fillOpacity=function t(e){return arguments.length?(this._fillOpacity=typeof e==="function"?e:y.constant(e),this):this._fillOpacity};t.prototype.hover=function t(e){if(!arguments.length||e===void 0){return this._hover}this._hover=e;if(this._group){this._renderHover()}return this};t.prototype.hoverStyle=function t(e){return arguments.length?(this._hoverStyle=y.assign({},this._hoverStyle,e),this):this._hoverStyle};t.prototype.hoverOpacity=function t(e){return arguments.length?(this._hoverOpacity=e,this):this._hoverOpacity};t.prototype.hitArea=function t(e){return arguments.length?(this._hitArea=typeof e==="function"?e:y.constant(e),this):this._hitArea};t.prototype.id=function t(e){return arguments.length?(this._id=e,this):this._id};t.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:y.constant(e),this):this._label};t.prototype.labelBounds=function t(e){return arguments.length?(this._labelBounds=typeof e==="function"?e:y.constant(e),this):this._labelBounds};t.prototype.labelConfig=function t(e){return arguments.length?(this._labelConfig=y.assign(this._labelConfig,e),this):this._labelConfig};t.prototype.opacity=function t(e){return arguments.length?(this._opacity=typeof e==="function"?e:y.constant(e),this):this._opacity};t.prototype.pointerEvents=function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents};t.prototype.role=function t(e){return e!==undefined?(this._role=typeof e==="function"?e:y.constant(e),this):this._role};t.prototype.rotate=function t(e){return arguments.length?(this._rotate=typeof e==="function"?e:y.constant(e),this):this._rotate};t.prototype.rx=function t(e){return arguments.length?(this._rx=typeof e==="function"?e:y.constant(e),this):this._rx};t.prototype.ry=function t(e){return arguments.length?(this._ry=typeof e==="function"?e:y.constant(e),this):this._ry};t.prototype.scale=function t(e){return arguments.length?(this._scale=typeof e==="function"?e:y.constant(e),this):this._scale};t.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};t.prototype.shapeRendering=function t(e){return arguments.length?(this._shapeRendering=typeof e==="function"?e:y.constant(e),this):this._shapeRendering};t.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};t.prototype.stroke=function t(e){return arguments.length?(this._stroke=typeof e==="function"?e:y.constant(e),this):this._stroke};t.prototype.strokeDasharray=function t(e){return arguments.length?(this._strokeDasharray=typeof e==="function"?e:y.constant(e),this):this._strokeDasharray};t.prototype.strokeLinecap=function t(e){return arguments.length?(this._strokeLinecap=typeof e==="function"?e:y.constant(e),this):this._strokeLinecap};t.prototype.strokeOpacity=function t(e){return arguments.length?(this._strokeOpacity=typeof e==="function"?e:y.constant(e),this):this._strokeOpacity};t.prototype.strokeWidth=function t(e){return arguments.length?(this._strokeWidth=typeof e==="function"?e:y.constant(e),this):this._strokeWidth};t.prototype.textAnchor=function t(e){return arguments.length?(this._textAnchor=typeof e==="function"?e:y.constant(e),this):this._textAnchor};t.prototype.vectorEffect=function t(e){return arguments.length?(this._vectorEffect=typeof e==="function"?e:y.constant(e),this):this._vectorEffect};t.prototype.verticalAlign=function t(e){return arguments.length?(this._verticalAlign=typeof e==="function"?e:y.constant(e),this):this._verticalAlign};t.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};t.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};return t}(y.BaseClass);function m(t,e,i,n){var r=1e-9;var s=t[0]-e[0],o=i[0]-n[0],a=t[1]-e[1],h=i[1]-n[1];var l=s*h-a*o;if(Math.abs(l)<r){return null}var c=t[0]*e[1]-t[1]*e[0],u=i[0]*n[1]-i[1]*n[0];var p=(c*o-u*s)/l,_=(c*h-u*a)/l;return[p,_]}function b(t,e,i){var n=1e-9;var r=i[0];var s=i[1];return!(r<Math.min(t[0],e[0])-n||r>Math.max(t[0],e[0])+n||s<Math.min(t[1],e[1])-n||s>Math.max(t[1],e[1])+n)}function c(t,e,i,n){var r=m(t,e,i,n);if(!r){return false}return b(t,e,r)&&b(i,n,r)}function _t(t,e){var i=-1;var n=t.length;var r=e.length;var s=t[n-1];while(++i<n){var o=s;s=t[i];var a=-1;var h=e[r-1];while(++a<r){var l=h;h=e[a];if(c(o,s,l,h)){return false}}}return ut.polygonContains(e,t[0])}function ft(t,e,i){if(i===void 0)i=0;var n=1e-9;e=[e[0]+n*Math.cos(i),e[1]+n*Math.sin(i)];var r=e[0];var s=e[1];var o=[r+Math.cos(i),s+Math.sin(i)];var a=0;if(Math.abs(o[0]-r)<n){a=1}var h=-1;var l=t.length;var c=t[l-1];var u=Number.MAX_VALUE;var p=Number.MAX_VALUE;var _=null;var f=null;while(++h<l){var d=c;c=t[h];var y=m(e,o,d,c);if(y&&b(d,c,y)){var v=pt(e,y);if(y[a]<e[a]){if(v<u){u=v;_=y}}else if(y[a]>e[a]){if(v<p){p=v;f=y}}}}return[_,f]}function n(t,e,i){if(i===void 0)i=[0,0];var n=Math.cos(e),r=Math.sin(e),s=t[0]-i[0],o=t[1]-i[1];return[n*s-r*o+i[0],r*s+n*o+i[1]]}function dt(t,e,i){if(i===void 0)i=[0,0];return t.map(function(t){return n(t,e,i)})}function u(t,e,i){var n=e[0],r=e[1];var s=i[0]-n,o=i[1]-r;if(s!==0||o!==0){var a=((t[0]-n)*s+(t[1]-r)*o)/(s*s+o*o);if(a>1){n=i[0];r=i[1]}else if(a>0){n+=s*a;r+=o*a}}s=t[0]-n;o=t[1]-r;return s*s+o*o}function s(t,e){var i,n=t[0];var r=[n];for(var s=1,o=t.length;s<o;s++){i=t[s];if(pt(i,n)>e){r.push(i);n=i}}if(n!==i){r.push(i)}return r}function p(t,e,i,n,r){var s,o=n;for(var a=e+1;a<i;a++){var h=u(t[a],t[e],t[i]);if(h>o){s=a;o=h}}if(o>n){if(s-e>1){p(t,e,s,n,r)}r.push(t[s]);if(i-s>1){p(t,s,i,n,r)}}}function a(t,e){var i=t.length-1;var n=[t[0]];p(t,0,i,e,n);n.push(t[i]);return n}function yt(t,e,i){if(e===void 0)e=1;if(i===void 0)i=false;if(t.length<=2){return t}var n=e*e;t=i?t:s(t,n);t=a(t,n);return t}var vt=.5;var gt=5;var xt={};function _(t,e){var i,n;if(e===void 0)e={};if(t.length<3){if(e.verbose){console.error("polygon has to have at least 3 points",t)}return null}var r=[];e=Object.assign({angle:ct.range(-90,90+gt,gt),cache:true,maxAspectRatio:15,minAspectRatio:1,minHeight:0,minWidth:0,nTries:20,tolerance:.02,verbose:false},e);var s=e.angle instanceof Array?e.angle:typeof e.angle==="number"?[e.angle]:typeof e.angle==="string"&&!isNaN(e.angle)?[Number(e.angle)]:[];var o=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 h;if(e.cache){h=ct.merge(t).join(",");h+="-"+e.minAspectRatio;h+="-"+e.maxAspectRatio;h+="-"+e.minHeight;h+="-"+e.minWidth;h+="-"+s.join(",");h+="-"+a.join(",");if(xt[h]){return xt[h]}}var l=Math.abs(ut.polygonArea(t));if(l===0){if(e.verbose){console.error("polygon has 0 area",t)}return null}var c=ct.extent(t,function(t){return t[0]});var u=c[0];var p=c[1];var _=ct.extent(t,function(t){return t[1]});var f=_[0];var d=_[1];var y=Math.min(p-u,d-f)*e.tolerance;if(y>0){t=yt(t,y)}if(e.events){r.push({type:"simplify",poly:t})}i=ct.extent(t,function(t){return t[0]}),u=i[0],p=i[1];n=ct.extent(t,function(t){return t[1]}),f=n[0],d=n[1];var v=[p-u,d-f];var g=v[0];var x=v[1];var m=Math.min(g,x)/50;if(!a.length){var b=ut.polygonCentroid(t);if(isNaN(b[0])||b[0]===Infinity||b[0]<0){if(e.verbose){console.error("cannot find centroid",t)}return null}if(ut.polygonContains(t,b)){a.push(b)}while(a.length<e.nTries){var w=Math.random()*g+u;var k=Math.random()*x+f;var C=[w,k];if(ut.polygonContains(t,C)){a.push(C)}}}if(e.events){r.push({type:"origins",points:a})}var O=0;var A=null;for(var S=0;S<s.length;S++){var M=s[S];var E=-M*Math.PI/180;if(e.events){r.push({type:"angle",angle:M})}for(var W=0;W<a.length;W++){var P=a[W];var R=ft(t,P,E);var N=R[0];var L=R[1];var j=ft(t,P,E+Math.PI/2);var B=j[0];var H=j[1];var I=[];if(N&&L){I.push([(N[0]+L[0])/2,(N[1]+L[1])/2])}if(B&&H){I.push([(B[0]+H[0])/2,(B[1]+H[1])/2])}if(e.events){r.push({type:"modifOrigin",idx:W,p1W:N,p2W:L,p1H:B,p2H:H,modifOrigins:I})}for(var q=0;q<I.length;q++){var T=I[q];if(e.events){r.push({type:"origin",cx:T[0],cy:T[1]})}var D=ft(t,T,E);var z=D[0];var V=D[1];if(z===null||V===null){continue}var F=Math.min(pt(T,z),pt(T,V));var G=2*Math.sqrt(F);var U=ft(t,T,E+Math.PI/2);var X=U[0];var Y=U[1];if(X===null||Y===null){continue}var Z=Math.min(pt(T,X),pt(T,Y));var J=2*Math.sqrt(Z);if(G*J<O){continue}var K=o;if(!K.length){var Q=Math.max(e.minAspectRatio,e.minWidth/J,O/(J*J));var $=Math.min(e.maxAspectRatio,G/e.minHeight,G*G/O);K=ct.range(Q,$+vt,vt)}for(var tt=0;tt<K.length;tt++){var et=K[tt];var it=Math.max(e.minWidth,Math.sqrt(O*et));var nt=Math.min(G,J*et);if(nt*J<O){continue}if(e.events&&nt-it>=m){r.push({type:"aRatio",aRatio:et})}while(nt-it>=m){var rt=(it+nt)/2;var st=rt/et;var ot=T[0];var at=T[1];var ht=[[ot-rt/2,at-st/2],[ot+rt/2,at-st/2],[ot+rt/2,at+st/2],[ot-rt/2,at+st/2]];ht=dt(ht,E,T);var lt=_t(ht,t);if(lt){O=rt*st;ht.push(ht[0]);A={area:O,cx:ot,cy:at,width:rt,height:st,angle:-M,points:ht};it=rt}else{nt=rt}if(e.events){r.push({type:"rectangle",areaFraction:rt*st/l,cx:ot,cy:at,width:rt,height:st,angle:M,insidePoly:lt})}}}}}}if(e.cache){xt[h]=A}return e.events?Object.assign(A||{},{events:r}):A}var w=function(s){function t(){var r=this;s.call(this);this._curve="linear";this._defined=function(){return true};this._labelBounds=function(t,e,i){var n=_(i.points);if(!n){return null}return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2-r._x(t,e),y:n.cy-n.height/2-r._y(t,e)}};this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});this._name="Area";this._x=y.accessor("x");this._x0=y.accessor("x");this._x1=null;this._y=y.constant(0);this._y0=y.constant(0);this._y1=y.accessor("y")}if(s)t.__proto__=s;t.prototype=Object.create(s&&s.prototype);t.prototype.constructor=t;t.prototype._aes=function t(e){var i=this;var n=e.values.slice().sort(function(t,e){return i._y1?i._x(t)-i._x(e):i._y(t)-i._y(e)});var r=n.map(function(t,e){return[i._x0(t,e),i._y0(t,e)]});var s=n.reverse().map(function(t,e){return i._y1?[i._x(t,e),i._y1(t,e)]:[i._x1(t,e),i._y(t,e)]});var o=r.concat(s);if(r[0][1]>s[0][1]){o=o.reverse()}o.push(o[0]);return{points:o}};t.prototype._dataFilter=function t(n){var r=this;var e=l.nest().key(this._id).entries(n).map(function(t){t.data=y.merge(t.values);t.i=n.indexOf(t.values[0]);var e=ct.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 i=ct.extent(t.values.map(r._y).concat(t.values.map(r._y0)).concat(r._y1?t.values.map(r._y1):[]));t.yR=i;t.height=i[1]-i[0];t.y=i[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};t.prototype.render=function t(e){s.prototype.render.call(this,e);var i=this._path=v.area().defined(this._defined).curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);var n=v.area().defined(function(t){return t}).curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);this._enter.append("path").attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attr("d",function(t){return i(t.values)}).call(this._applyStyle.bind(this));this._update.select("path").transition(this._transition).attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attrTween("d",function(t){return o.interpolatePath(f.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(f.select(this).attr("d"),n(t.values))});return this};t.prototype.curve=function t(e){return arguments.length?(this._curve=e,this):this._curve};t.prototype.defined=function t(e){return arguments.length?(this._defined=e,this):this._defined};t.prototype.x=function t(e){if(!arguments.length){return this._x}this._x=typeof e==="function"?e:y.constant(e);this._x0=this._x;return this};t.prototype.x0=function t(e){if(!arguments.length){return this._x0}this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this};t.prototype.x1=function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1};t.prototype.y=function t(e){if(!arguments.length){return this._y}this._y=typeof e==="function"?e:y.constant(e);this._y0=this._y;return this};t.prototype.y0=function t(e){if(!arguments.length){return this._y0}this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this};t.prototype.y1=function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1};return t}(e);var k=function(r){function t(){var n=this;r.call(this,"rect");this._name="Bar";this._height=y.constant(10);this._labelBounds=function(t,e,i){return{width:i.width,height:i.height,x:n._x1!==null?n._getX(t,e):-i.width/2,y:n._x1===null?n._getY(t,e):-i.height/2}};this._width=y.constant(10);this._x=y.accessor("x");this._x0=y.accessor("x");this._x1=null;this._y=y.constant(0);this._y0=y.constant(0);this._y1=y.accessor("y")}if(r)t.__proto__=r;t.prototype=Object.create(r&&r.prototype);t.prototype.constructor=t;t.prototype.render=function t(e){var i=this;r.prototype.render.call(this,e);this._enter.attr("width",function(t,e){return i._x1===null?i._getWidth(t,e):0}).attr("height",function(t,e){return i._x1!==null?i._getHeight(t,e):0}).attr("x",function(t,e){return i._x1===null?-i._getWidth(t,e)/2:0}).attr("y",function(t,e){return i._x1!==null?-i._getHeight(t,e)/2:0}).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("width",function(t,e){return i._x1===null?i._getWidth(t,e):0}).attr("height",function(t,e){return i._x1!==null?i._getHeight(t,e):0}).attr("x",function(t,e){return i._x1===null?-i._getWidth(t,e)/2:0}).attr("y",function(t,e){return i._x1!==null?-i._getHeight(t,e)/2:0});return this};t.prototype._aes=function t(e,i){return{height:this._getHeight(e,i),width:this._getWidth(e,i)}};t.prototype._applyPosition=function t(e){var i=this;e.attr("width",function(t,e){return i._getWidth(t,e)}).attr("height",function(t,e){return i._getHeight(t,e)}).attr("x",function(t,e){return i._x1!==null?i._getX(t,e):-i._getWidth(t,e)/2}).attr("y",function(t,e){return i._x1===null?i._getY(t,e):-i._getHeight(t,e)/2})};t.prototype._getHeight=function t(e,i){if(this._x1!==null){return this._height(e,i)}return Math.abs(this._y1(e,i)-this._y(e,i))};t.prototype._getWidth=function t(e,i){if(this._x1===null){return this._width(e,i)}return Math.abs(this._x1(e,i)-this._x(e,i))};t.prototype._getX=function t(e,i){var n=this._x1===null?this._x(e,i):this._x1(e,i)-this._x(e,i);if(n<0){return n}else{return 0}};t.prototype._getY=function t(e,i){var n=this._x1!==null?this._y(e,i):this._y1(e,i)-this._y(e,i);if(n<0){return n}else{return 0}};t.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};t.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};t.prototype.x0=function t(e){if(!arguments.length){return this._x0}this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this};t.prototype.x1=function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1};t.prototype.y0=function t(e){if(!arguments.length){return this._y0}this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this};t.prototype.y1=function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1};return t}(e);var C=function(i){function t(){i.call(this,"circle");this._labelBounds=function(t,e,i){return{width:i.r*1.5,height:i.r*1.5,x:-i.r*.75,y:-i.r*.75}};this._labelConfig=y.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});this._name="Circle";this._r=y.accessor("r")}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype._applyPosition=function t(e){var i=this;e.attr("r",function(t,e){return i._r(t,e)}).attr("x",function(t,e){return-i._r(t,e)/2}).attr("y",function(t,e){return-i._r(t,e)/2})};t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("r",0).attr("x",0).attr("y",0).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("r",0).attr("x",0).attr("y",0);return this};t.prototype._aes=function t(e,i){return{r:this._r(e,i)}};t.prototype.r=function t(e){return arguments.length?(this._r=typeof e==="function"?e:y.constant(e),this):this._r};return t}(e);var O=function(i){function t(){i.call(this,"rect");this._height=y.accessor("height");this._labelBounds=function(t,e,i){return{width:i.width,height:i.height,x:-i.width/2,y:-i.height/2}};this._name="Rect";this._width=y.accessor("width")}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("width",0).attr("height",0).attr("x",0).attr("y",0).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("width",0).attr("height",0).attr("x",0).attr("y",0);return this};t.prototype._aes=function t(e,i){return{width:this._width(e,i),height:this._height(e,i)}};t.prototype._applyPosition=function t(e){var i=this;e.attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return-i._width(t,e)/2}).attr("y",function(t,e){return-i._height(t,e)/2})};t.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};t.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};return t}(e);var A=function(r){function t(){var e=this;r.call(this);this._curve="linear";this._defined=function(t){return t};this._fill=y.constant("none");this._hitArea=y.constant({d:function(t){return e._path(t.values)},fill:"none","stroke-width":10,transform:null});this._name="Line";this._path=v.line();this._stroke=y.constant("black");this._strokeWidth=y.constant(1)}if(r)t.__proto__=r;t.prototype=Object.create(r&&r.prototype);t.prototype.constructor=t;t.prototype._dataFilter=function t(n){var r=this;var e=l.nest().key(this._id).entries(n).map(function(t){t.data=y.merge(t.values);t.i=n.indexOf(t.values[0]);var e=ct.extent(t.values,r._x);t.xR=e;t.width=e[1]-e[0];t.x=e[0]+t.width/2;var i=ct.extent(t.values,r._y);t.yR=i;t.height=i[1]-i[0];t.y=i[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};t.prototype.render=function t(e){var i=this;r.prototype.render.call(this,e);var n=this;this._path.curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).defined(this._defined).x(this._x).y(this._y);this._enter.append("path").attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attr("d",function(t){return i._path(t.values)}).call(this._applyStyle.bind(this));this._update.select("path").transition(this._transition).attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attrTween("d",function(t){return o.interpolatePath(f.select(this).attr("d"),n._path(t.values))}).call(this._applyStyle.bind(this));return this};t.prototype._aes=function t(e,i){var n=this;return{points:e.values.map(function(t){return[n._x(t,i),n._y(t,i)]})}};t.prototype.curve=function t(e){return arguments.length?(this._curve=e,this):this._curve};t.prototype.defined=function t(e){return arguments.length?(this._defined=e,this):this._defined};return t}(e);var S={Circle:C,Rect:O};var M=function(t){function e(){t.call(this);this._endpoint=y.accessor("endpoint","Rect");this._endpointConfig={Circle:{r:y.accessor("r",5)}};this._length=y.accessor("length",25);this._lineConfig={};this._orient=y.accessor("orient","top");this._x=y.accessor("x",0);this._y=y.accessor("y",0)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.render=function t(e){var a=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var h=[];this._data.forEach(function(t,e){var i=a._orient(t,e);var n=a._x(t,e);var r=a._y(t,e);var s=n;if(i==="left"){s-=a._length(t,e)}else if(i==="right"){s+=a._length(t,e)}var o=r;if(i==="top"){o-=a._length(t,e)}else if(i==="bottom"){o+=a._length(t,e)}h.push({__d3plus__:true,data:t,i:e,id:e,x:n,y:r});h.push({__d3plus__:true,data:t,i:e,id:e,x:s,y:o})});this._line=(new A).data(h).select(y.elem("g.d3plus-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._lineConfig,"shape")).render(e);var i=this._data.map(function(t,e){var i={};i.__d3plus__=true;i.data=t;i.i=e;i.endpoint=a._endpoint(t,e);i.length=a._length(t,e);i.orient=a._orient(t,e);var n=a._x(t,e);if(i.orient==="left"){n-=i.length}else if(i.orient==="right"){n+=i.length}var r=a._y(t,e);if(i.orient==="top"){r-=i.length}else if(i.orient==="bottom"){r+=i.length}i.x=n;i.y=r;return i});this._whiskerEndpoint=[];l.nest().key(function(t){return t.endpoint}).entries(i).forEach(function(t){var e=t.key;a._whiskerEndpoint.push((new S[e]).data(t.values).select(y.elem("g.d3plus-Whisker-Endpoint-"+e,{parent:a._select}).node()).config({height:function(t){return t.orient==="top"||t.orient==="bottom"?5:20},width:function(t){return t.orient==="top"||t.orient==="bottom"?20:5}}).config(y.configPrep.bind(a)(a._endpointConfig,"shape",e)).render())});return this};e.prototype.active=function t(e){if(this._line){this._line.active(e)}if(this._whiskerEndpoint){this._whiskerEndpoint.forEach(function(t){return t.active(e)})}};e.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};e.prototype.endpoint=function t(e){return arguments.length?(this._endpoint=typeof e==="function"?e:y.constant(e),this):this._endpoint};e.prototype.endpointConfig=function t(e){return arguments.length?(this._endpointConfig=y.assign(this._endpointConfig,e),this):this._endpointConfig};e.prototype.hover=function t(e){if(this._line){this._line.hover(e)}if(this._whiskerEndpoint){this._whiskerEndpoint.forEach(function(t){return t.hover(e)})}};e.prototype.length=function t(e){return arguments.length?(this._length=typeof e==="function"?e:y.constant(e),this):this._length};e.prototype.lineConfig=function t(e){return arguments.length?(this._lineConfig=y.assign(this._lineConfig,e),this):this._lineConfig};e.prototype.orient=function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient};e.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};e.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};e.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};return e}(y.BaseClass);var E={Circle:C,Rect:O};var W=function(t){function e(){var i=this;t.call(this);this._medianConfig={fill:y.constant("black")};this._orient=y.accessor("orient","vertical");this._outlier=y.accessor("outlier","Circle");this._outlierConfig={Circle:{r:y.accessor("r",5)},Rect:{height:function(t,e){return i._orient(t,e)==="vertical"?5:20},width:function(t,e){return i._orient(t,e)==="vertical"?20:5}}};this._rectConfig={fill:y.constant("white"),stroke:y.constant("black"),strokeWidth:y.constant(1)};this._rectWidth=y.constant(50);this._whiskerConfig={};this._whiskerMode=["tukey","tukey"];this._x=y.accessor("x",250);this._y=y.accessor("y",250)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.render=function t(){var s=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var o=[];var e=l.nest().key(function(t,e){return s._orient(t,e)==="vertical"?s._x(t,e):s._y(t,e)}).entries(this._data).map(function(r){r.data=y.merge(r.values);r.i=s._data.indexOf(r.values[0]);r.orient=s._orient(r.data,r.i);var t=r.values.map(r.orient==="vertical"?s._y:s._x);t.sort(function(t,e){return t-e});r.first=ct.quantile(t,.25);r.median=ct.quantile(t,.5);r.third=ct.quantile(t,.75);var e=s._whiskerMode;if(e[0]==="tukey"){r.lowerLimit=r.first-(r.third-r.first)*1.5;if(r.lowerLimit<ct.min(t)){r.lowerLimit=ct.min(t)}}else if(e[0]==="extent"){r.lowerLimit=ct.min(t)}else if(typeof e[0]==="number"){r.lowerLimit=ct.quantile(t,e[0])}if(e[1]==="tukey"){r.upperLimit=r.third+(r.third-r.first)*1.5;if(r.upperLimit>ct.max(t)){r.upperLimit=ct.max(t)}}else if(e[1]==="extent"){r.upperLimit=ct.max(t)}else if(typeof e[1]==="number"){r.upperLimit=ct.quantile(t,e[1])}var i=r.third-r.first;if(r.orient==="vertical"){r.height=i;r.width=s._rectWidth(r.data,r.i);r.x=s._x(r.data,r.i);r.y=r.first+i/2}else if(r.orient==="horizontal"){r.height=s._rectWidth(r.data,r.i);r.width=i;r.x=r.first+i/2;r.y=s._y(r.data,r.i)}r.values.forEach(function(t,e){var i=r.orient==="vertical"?s._y(t,e):s._x(t,e);if(i<r.lowerLimit||i>r.upperLimit){var n={};n.__d3plus__=true;n.data=t;n.i=e;n.outlier=s._outlier(t,e);if(r.orient==="vertical"){n.x=r.x;n.y=i;o.push(n)}else if(r.orient==="horizontal"){n.y=r.y;n.x=i;o.push(n)}}});r.__d3plus__=true;return r});this._box=(new O).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 O).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 i=t.x;var n=t.y;var r=t.first-t.lowerLimit;var s=t.upperLimit-t.third;if(t.orient==="vertical"){var o=n-t.height/2;var a=n+t.height/2;c.push({__d3plus__:true,data:t,i:e,x:i,y:o,length:r,orient:"top"},{__d3plus__:true,data:t,i:e,x:i,y:a,length:s,orient:"bottom"})}else if(t.orient==="horizontal"){var h=i+t.width/2;var l=i-t.width/2;c.push({__d3plus__:true,data:t,i:e,x:h,y:n,length:s,orient:"right"},{__d3plus__:true,data:t,i:e,x:l,y:n,length:r,orient:"left"})}});this._whisker=(new M).data(c).select(y.elem("g.d3plus-Box-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._whiskerConfig,"shape")).render();this._whiskerEndpoint=[];l.nest().key(function(t){return t.outlier}).entries(o).forEach(function(t){var e=t.key;s._whiskerEndpoint.push((new E[e]).data(t.values).select(y.elem("g.d3plus-Box-Outlier-"+e,{parent:s._select}).node()).config(y.configPrep.bind(s)(s._outlierConfig,"shape",e)).render())});return this};e.prototype.active=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)})}};e.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};e.prototype.hover=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)})}};e.prototype.medianConfig=function t(e){return arguments.length?(this._medianConfig=y.assign(this._medianConfig,e),this):this._medianConfig};e.prototype.orient=function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient};e.prototype.outlier=function t(e){return arguments.length?(this._outlier=typeof e==="function"?e:y.constant(e),this):this._outlier};e.prototype.outlierConfig=function t(e){return arguments.length?(this._outlierConfig=y.assign(this._outlierConfig,e),this):this._outlierConfig};e.prototype.rectConfig=function t(e){return arguments.length?(this._rectConfig=y.assign(this._rectConfig,e),this):this._rectConfig};e.prototype.rectWidth=function t(e){return arguments.length?(this._rectWidth=typeof e==="function"?e:y.constant(e),this):this._rectWidth};e.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};e.prototype.whiskerConfig=function t(e){return arguments.length?(this._whiskerConfig=y.assign(this._whiskerConfig,e),this):this._whiskerConfig};e.prototype.whiskerMode=function t(e){return arguments.length?(this._whiskerMode=e instanceof Array?e:[e,e],this):this._whiskerMode};e.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.accessor(e),this):this._x};e.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.accessor(e),this):this._y};return e}(y.BaseClass);var P=Math.PI;function R(t,e,i){if(i===void 0)i="circle";if(t<0){t=P*2+t}if(i==="square"){var n=45*(P/180);var r=0,s=0;if(t<P/2){var o=Math.tan(t);r+=t<n?e:e/o;s+=t<n?o*e:e}else if(t<=P){var a=Math.tan(P-t);r-=t<P-n?e/a:e;s+=t<P-n?e:a*e}else if(t<n+P){r-=e;s-=Math.tan(t-P)*e}else if(t<3*P/2){r-=e/Math.tan(t-P);s-=e}else if(t<2*P-n){r+=e/Math.tan(2*P-t);s-=e}else{r+=e;s-=Math.tan(2*P-t)*e}return[r,s]}else if(i==="circle"){return[e*Math.cos(t),e*Math.sin(t)]}else{return null}}var N=Math.PI;function L(t,e){if(e===void 0)e=20;var i=[],n=/([MLA])([^MLAZ]+)/gi;var r=n.exec(t);while(r!==null){if(["M","L"].includes(r[1])){i.push(r[2].split(",").map(Number))}else if(r[1]==="A"){var s=r[2].split(",").map(Number);var o=s.slice(s.length-2,s.length),a=i[i.length-1],h=s[0],l=x(a,o);var c=Math.acos((h*h+h*h-l*l)/(2*h*h));if(s[2]){c=N*2-c}var u=c/(c/(N*2)*(h*N*2)/e);var p=Math.atan2(-a[1],-a[0])-N;var _=u;while(_<c){i.push(R(s[4]?p+_:p-_,h));_+=u}i.push(o)}r=n.exec(t)}return i}var j=function(i){function t(){var r=this;i.call(this,"path");this._d=y.accessor("path");this._labelBounds=function(t,e,i){var n=_(i.points,{angle:r._labelConfig.rotate?r._labelConfig.rotate(t,e):0});return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}};this._name="Path";this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype._aes=function t(e,i){return{points:L(this._d(e,i))}};t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("opacity",0).attr("d",this._d).call(this._applyStyle.bind(this)).transition(this._transition).attr("opacity",1);this._update.transition(this._transition).call(this._applyStyle.bind(this)).attr("opacity",1).attr("d",this._d);this._exit.transition(this._transition).attr("opacity",0);return this};t.prototype.d=function t(e){return arguments.length?(this._d=typeof e==="function"?e:y.constant(e),this):this._d};return t}(e);t.Image=h;t.Shape=e;t.Area=w;t.Bar=k;t.Box=W;t.Circle=C;t.Line=A;t.Path=j;t.Rect=O;t.Whisker=M;t.largestRect=_;t.lineIntersection=m;t.path2polygon=L;t.pointDistance=x;t.pointDistanceSquared=pt;t.pointRotate=n;t.polygonInside=_t;t.polygonRayCast=ft;t.polygonRotate=dt;t.segmentBoxContains=b;t.segmentsIntersect=c;t.shapeEdgePoint=R;t.simplify=yt;Object.defineProperty(t,"__esModule",{value:true})}); | ||
if(typeof Object.assign!=="function"){Object.defineProperty(Object,"assign",{value:function t(e){"use strict";if(e===null){throw new TypeError("Cannot convert undefined or null to object")}var i=Object(e);for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r!==null){for(var s in r){if(Object.prototype.hasOwnProperty.call(r,s)){i[s]=r[s]}}}}return i},writable:true,configurable:true})}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function t(e,i){var n=Object(this);var r=n.length>>>0;if(r===0)return false;var s=i|0;var o=Math.max(s>=0?s:r-Math.abs(s),0);function a(t,e){return t===e||typeof t==="number"&&typeof e==="number"&&isNaN(t)&&isNaN(e)}while(o<r){if(a(n[o],e)){return true}o++}return false}})}if(!String.prototype.includes){Object.defineProperty(String.prototype,"includes",{value:function(t,e){if(typeof e!=="number"){e=0}if(e+t.length>this.length){return false}else{return this.indexOf(t,e)!==-1}}})}if(!Array.prototype.find){Object.defineProperty(Array.prototype,"find",{value:function(t){if(this==null){throw new TypeError('"this" is null or not defined')}var e=Object(this);var i=e.length>>>0;if(typeof t!=="function"){throw new TypeError("predicate must be a function")}var n=arguments[1];var r=0;while(r<i){var s=e[r];if(t.call(n,s,r,e)){return s}r++}return undefined},configurable:true,writable:true})}if(!String.prototype.startsWith){Object.defineProperty(String.prototype,"startsWith",{value:function(t,e){e=!e||e<0?0:+e;return this.substring(e,e+t.length)===t}})}if(typeof window!=="undefined"){(function(){var n=function(t,e){var i=t.nodeType;if(i===3){e.push(t.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(i===1){e.push("<",t.tagName);if(t.hasAttributes()){[].forEach.call(t.attributes,function(t){e.push(" ",t.item.name,"='",t.item.value,"'")})}if(t.hasChildNodes()){e.push(">");[].forEach.call(t.childNodes,function(t){n(t,e)});e.push("</",t.tagName,">")}else{e.push("/>")}}else if(i==8){e.push("\x3c!--",t.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var t=[];var e=this.firstChild;while(e){n(e,t);e=e.nextSibling}return t.join("")},set:function(t){while(this.firstChild){this.removeChild(this.firstChild)}try{var e=new DOMParser;e.async=false;var i="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>";var n=e.parseFromString(i,"text/xml").documentElement;var r=n.firstChild;while(r){this.appendChild(this.ownerDocument.importNode(r,true));r=r.nextSibling}}catch(t){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})})()}(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-polygon"),require("d3-collection"),require("d3-interpolate-path")):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-polygon","d3-collection","d3-interpolate-path"],e):e(t.d3plus={},t.d3Selection,t.d3Transition,t.d3plusCommon,t.d3Array,t.d3Color,t.d3plusColor,t.paths,t.d3plusText,t.d3Polygon,t.d3Collection,t.d3InterpolatePath)})(this,function(t,f,d,y,ct,r,i,v,g,ut,l,o){"use strict";var h=function t(){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)};h.prototype.render=function t(e){var i=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var n=this._select.selectAll(".d3plus-Image").data(this._data,this._id);var r=n.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",function(t,e){return i._x(t,e)+i._width(t,e)/2}).attr("y",function(t,e){return i._y(t,e)+i._height(t,e)/2});var s=d.transition().duration(this._duration),o=this,a=r.merge(n);a.attr("xlink:href",this._url).style("pointer-events",this._pointerEvents).transition(s).attr("opacity",1).attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return i._x(t,e)}).attr("y",function(t,e){return i._y(t,e)}).each(function(t,e){var i=f.select(this),n=o._url(t,e);var r=n.indexOf("http://")===0||n.indexOf("https://")===0;if(!r||n.indexOf(window.location.hostname)===0){var s=new h;s.src=n;s.crossOrigin="Anonymous";s.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);i.attr("xlink:href",t.toDataURL("image/png"))}}});n.exit().transition(s).attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return i._x(t,e)}).attr("y",function(t,e){return i._y(t,e)}).attr("opacity",0).remove();if(e){setTimeout(e,this._duration+100)}return this};h.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};h.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};h.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};h.prototype.id=function t(e){return arguments.length?(this._id=e,this):this._id};h.prototype.pointerEvents=function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents};h.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};h.prototype.url=function t(e){return arguments.length?(this._url=e,this):this._url};h.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};h.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};h.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};function pt(t,e){var i=e[0]-t[0],n=e[1]-t[1];return i*i+n*n}function x(t,e){return Math.sqrt(pt(t,e))}var e=function(e){function t(t){var n=this;if(t===void 0)t="g";e.call(this);this._activeOpacity=.25;this._activeStyle={stroke:function(t,e){var i=n._fill(t,e);if(["transparent","none"].includes(i)){i=n._stroke(t,e)}return r.color(i).darker(1)},"stroke-width":function(t,e){var i=n._strokeWidth(t,e)||1;return i*3}};this._ariaLabel=y.constant("");this._backgroundImage=y.constant(false);this._backgroundImageClass=new h;this._data=[];this._duration=600;this._fill=y.constant("black");this._fillOpacity=y.constant(1);this._hoverOpacity=.5;this._hoverStyle={stroke:function(t,e){var i=n._fill(t,e);if(["transparent","none"].includes(i)){i=n._stroke(t,e)}return r.color(i).darker(.5)},"stroke-width":function(t,e){var i=n._strokeWidth(t,e)||1;return i*2}};this._id=function(t,e){return t.id!==void 0?t.id:e};this._label=y.constant(false);this._labelClass=new g.TextBox;this._labelConfig={fontColor:function(t,e){return i.colorContrast(n._fill(t,e))},fontSize:12,padding:5};this._name="Shape";this._opacity=y.constant(1);this._pointerEvents=y.constant("visiblePainted");this._role=y.constant("presentation");this._rotate=y.constant(0);this._rx=y.constant(0);this._ry=y.constant(0);this._scale=y.constant(1);this._shapeRendering=y.constant("geometricPrecision");this._stroke=function(t,e){return r.color(n._fill(t,e)).darker(1)};this._strokeDasharray=y.constant("0");this._strokeLinecap=y.constant("butt");this._strokeOpacity=y.constant(1);this._strokeWidth=y.constant(0);this._tagName=t;this._textAnchor=y.constant("start");this._vectorEffect=y.constant("non-scaling-stroke");this._verticalAlign=y.constant("top");this._x=y.accessor("x",0);this._y=y.accessor("y",0)}if(e)t.__proto__=e;t.prototype=Object.create(e&&e.prototype);t.prototype.constructor=t;t.prototype._aes=function t(){return{}};t.prototype._applyEvents=function t(e){var s=this;var o=Object.keys(this._on);var i=function(r){e.on(o[r],function(t,e){if(!s._on[o[r]]){return}if(t.i!==void 0){e=t.i}if(t.nested&&t.values){var i=f.mouse(s._select.node()),n=t.values.map(function(t){return x(i,[s._x(t,e),s._y(t,e)])});t=t.values[n.indexOf(ct.min(n))]}s._on[o[r]].bind(s)(t,e)})};for(var n=0;n<o.length;n++)i(n)};t.prototype._updateStyle=function t(e,i){var n=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],n._data.indexOf(t.values[0])):this(t,e)}var s={};for(var o in i){if({}.hasOwnProperty.call(i,o)){s[o]=r.bind(i[o])}}e.transition().duration(0).call(y.attrize,s)};t.prototype._applyStyle=function t(e){var i=this;if(e.size()&&e.node().tagName==="g"){e=e.selectAll("*")}function n(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)}e.attr("fill",n.bind(this._fill)).attr("fill-opacity",n.bind(this._fillOpacity)).attr("rx",n.bind(this._rx)).attr("ry",n.bind(this._ry)).attr("stroke",n.bind(this._stroke)).attr("stroke-dasharray",n.bind(this._strokeDasharray)).attr("stroke-linecap",n.bind(this._strokeLinecap)).attr("stroke-opacity",n.bind(this._strokeOpacity)).attr("stroke-width",n.bind(this._strokeWidth)).attr("vector-effect",n.bind(this._vectorEffect))};t.prototype._applyTransform=function t(e){var i=this;e.attr("transform",function(t,e){return"\n translate("+(t.__d3plusShape__?t.translate?t.translate:i._x(t.data,t.i)+","+i._y(t.data,t.i):i._x(t,e)+","+i._y(t,e))+")\n scale("+(t.__d3plusShape__?t.scale||i._scale(t.data,t.i):i._scale(t,e))+")\n rotate("+(t.__d3plusShape__?t.rotate?t.rotate:i._rotate(t.data||t,t.i):i._rotate(t.data||t,t.i))+")"})};t.prototype._nestWrapper=function t(i){return function(t,e){return i(t.__d3plusShape__?t.data:t,t.__d3plusShape__?t.i:e)}};t.prototype._renderActive=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 i=t.parentNode;if(f.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 n=!r._active||typeof r._active!=="function"||!r._active(t,e)?i:r._activeGroup.node();if(n!==this.parentNode){n.appendChild(this);if(this.className.baseVal.includes("d3plus-Shape")){if(i===n){f.select(this).call(r._applyStyle.bind(r))}else{f.select(this).call(r._updateStyle.bind(r,f.select(this),r._activeStyle))}}}});this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text").attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)};t.prototype._renderHover=function t(){var r=this;this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text, g.d3plus-"+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 i=t.parentNode;if(f.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 n=!r._hover||typeof r._hover!=="function"||!r._hover(t,e)?i:r._hoverGroup.node();if(n!==this.parentNode){n.appendChild(this)}if(this.className.baseVal.includes("d3plus-Shape")){if(i===n){f.select(this).call(r._applyStyle.bind(r))}else{f.select(this).call(r._updateStyle.bind(r,f.select(this),r._hoverStyle))}}});this._group.selectAll("g.d3plus-"+this._name+"-shape, g.d3plus-"+this._name+"-image, g.d3plus-"+this._name+"-text").attr("opacity",this._hover?this._hoverOpacity:this._active?this._activeOpacity:1)};t.prototype._renderImage=function t(){var l=this;var c=[];this._update.merge(this._enter).data().forEach(function(t,e){var i=l._aes(t,e);if(i.r||i.width&&i.height){var n=t;if(t.nested&&t.key&&t.values){n=t.values[0];e=l._data.indexOf(n)}var r=i.r?i.r*2:i.height,s=l._backgroundImage(n,e),o=i.r?i.r*2:i.width;if(s){var a=n.__d3plusShape__?n.translate?n.translate[0]:l._x(n.data,n.i):l._x(n,e),h=n.__d3plusShape__?n.translate?n.translate[1]:l._y(n.data,n.i):l._y(n,e);if(i.x){a+=i.x}if(i.y){h+=i.y}if(n.__d3plusShape__){n=n.data;e=n.i}c.push({__d3plus__:true,data:n,height:r,i:e,id:l._id(n,e),url:s,width:o,x:a+-o/2,y:h+-r/2})}}});this._backgroundImageClass.data(c).duration(this._duration).pointerEvents("none").select(y.elem("g.d3plus-"+this._name+"-image",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).render()};t.prototype._renderLabels=function t(){var p=this;var _=[];this._update.merge(this._enter).data().forEach(function(t,e){var i=t;if(t.nested&&t.key&&t.values){i=t.values[0];e=p._data.indexOf(i)}var n=p._label(i,e);if(p._labelBounds&&n!==false&&n!==undefined&&n!==null){var r=p._labelBounds(i,e,p._aes(t,e));if(r){if(n.constructor!==Array){n=[n]}var s=i.__d3plusShape__?i.translate?i.translate[0]:p._x(i.data,i.i):p._x(i,e),o=i.__d3plusShape__?i.translate?i.translate[1]:p._y(i.data,i.i):p._y(i,e);if(i.__d3plusShape__){i=i.data;e=i.i}for(var a=0;a<n.length;a++){var h=r.constructor===Array?r[a]:Object.assign({},r);var l=p._rotate(i,e);var c=i.labelConfig&&i.labelConfig.rotate?i.labelConfig.rotate:r.angle!==undefined?r.angle:0;c+=l;var u=l!==0?[h.x*-1||0,h.y*-1||0]:[h.width/2,h.height/2];_.push({__d3plus__:true,data:i,height:h.height,l:a,id:p._id(i,e)+"_"+a,r:c,rotateAnchor:u,text:n[a],width:h.width,x:s+h.x,y:o+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-"+this._name+"-text",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).config(y.configPrep.bind(this)(this._labelConfig)).render()};t.prototype.render=function t(e){var i=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}this._transition=d.transition().duration(this._duration);var n=this._data,r=this._id;if(this._dataFilter){n=this._dataFilter(n);if(n.key){r=n.key}}if(this._sort){n=n.sort(function(t,e){while(t.__d3plusShape__||t.__d3plus__){t=t.data}while(e.__d3plusShape__||e.__d3plus__){e=e.data}return i._sort(t,e)})}f.selectAll("g.d3plus-"+this._name+"-hover > *, g.d3plus-"+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-"+this._name+"-group",{parent:this._select});var s=this._update=y.elem("g.d3plus-"+this._name+"-shape",{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).selectAll(".d3plus-"+this._name).data(n,r);s.order().transition(this._transition).call(this._applyTransform.bind(this));var o=this._enter=s.enter().append(this._tagName).attr("class",function(t,e){return"d3plus-Shape d3plus-"+i._name+" d3plus-id-"+g.strip(i._nestWrapper(i._id)(t,e))}).call(this._applyTransform.bind(this)).attr("aria-label",this._ariaLabel).attr("role",this._role).attr("opacity",this._nestWrapper(this._opacity));var a=o.merge(s);a.attr("shape-rendering",this._nestWrapper(this._shapeRendering)).attr("pointer-events","none").transition(this._transition).attr("opacity",this._nestWrapper(this._opacity)).attr("pointer-events",this._pointerEvents);var h=this._exit=s.exit();h.transition().delay(this._duration).remove();this._renderImage();this._renderLabels();this._hoverGroup=y.elem("g.d3plus-"+this._name+"-hover",{parent:this._group});this._activeGroup=y.elem("g.d3plus-"+this._name+"-active",{parent:this._group});var l=this._group.selectAll(".d3plus-HitArea").data(this._hitArea?n:[],r);l.order().call(this._applyTransform.bind(this));var c=this._name==="Line";c&&this._path.curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).defined(this._defined).x(this._x).y(this._y);var u=l.enter().append(c?"path":"rect").attr("class",function(t,e){return"d3plus-HitArea d3plus-id-"+g.strip(i._nestWrapper(i._id)(t,e))}).attr("fill","black").attr("stroke","black").attr("pointer-events","painted").attr("opacity",0).call(this._applyTransform.bind(this));var p=this;var _=l.merge(u).each(function(t){var e=p._data.indexOf(t);var i=p._hitArea(t,e,p._aes(t,e));return i&&!(p._name==="Line"&&parseFloat(p._strokeWidth(t,e))>10)?f.select(this).call(y.attrize,i):f.select(this).remove()});l.exit().remove();this._applyEvents(this._hitArea?_:a);setTimeout(function(){if(i._active){i._renderActive()}else if(i._hover){i._renderHover()}if(e){e()}},this._duration+100);return this};t.prototype.active=function t(e){if(!arguments.length||e===undefined){return this._active}this._active=e;if(this._group){this._renderActive()}return this};t.prototype.activeOpacity=function t(e){return arguments.length?(this._activeOpacity=e,this):this._activeOpacity};t.prototype.activeStyle=function t(e){return arguments.length?(this._activeStyle=y.assign({},this._activeStyle,e),this):this._activeStyle};t.prototype.ariaLabel=function t(e){return e!==undefined?(this._ariaLabel=typeof e==="function"?e:y.constant(e),this):this._ariaLabel};t.prototype.backgroundImage=function t(e){return arguments.length?(this._backgroundImage=typeof e==="function"?e:y.constant(e),this):this._backgroundImage};t.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};t.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};t.prototype.fill=function t(e){return arguments.length?(this._fill=typeof e==="function"?e:y.constant(e),this):this._fill};t.prototype.fillOpacity=function t(e){return arguments.length?(this._fillOpacity=typeof e==="function"?e:y.constant(e),this):this._fillOpacity};t.prototype.hover=function t(e){if(!arguments.length||e===void 0){return this._hover}this._hover=e;if(this._group){this._renderHover()}return this};t.prototype.hoverStyle=function t(e){return arguments.length?(this._hoverStyle=y.assign({},this._hoverStyle,e),this):this._hoverStyle};t.prototype.hoverOpacity=function t(e){return arguments.length?(this._hoverOpacity=e,this):this._hoverOpacity};t.prototype.hitArea=function t(e){return arguments.length?(this._hitArea=typeof e==="function"?e:y.constant(e),this):this._hitArea};t.prototype.id=function t(e){return arguments.length?(this._id=e,this):this._id};t.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:y.constant(e),this):this._label};t.prototype.labelBounds=function t(e){return arguments.length?(this._labelBounds=typeof e==="function"?e:y.constant(e),this):this._labelBounds};t.prototype.labelConfig=function t(e){return arguments.length?(this._labelConfig=y.assign(this._labelConfig,e),this):this._labelConfig};t.prototype.opacity=function t(e){return arguments.length?(this._opacity=typeof e==="function"?e:y.constant(e),this):this._opacity};t.prototype.pointerEvents=function t(e){return arguments.length?(this._pointerEvents=typeof e==="function"?e:y.constant(e),this):this._pointerEvents};t.prototype.role=function t(e){return e!==undefined?(this._role=typeof e==="function"?e:y.constant(e),this):this._role};t.prototype.rotate=function t(e){return arguments.length?(this._rotate=typeof e==="function"?e:y.constant(e),this):this._rotate};t.prototype.rx=function t(e){return arguments.length?(this._rx=typeof e==="function"?e:y.constant(e),this):this._rx};t.prototype.ry=function t(e){return arguments.length?(this._ry=typeof e==="function"?e:y.constant(e),this):this._ry};t.prototype.scale=function t(e){return arguments.length?(this._scale=typeof e==="function"?e:y.constant(e),this):this._scale};t.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};t.prototype.shapeRendering=function t(e){return arguments.length?(this._shapeRendering=typeof e==="function"?e:y.constant(e),this):this._shapeRendering};t.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};t.prototype.stroke=function t(e){return arguments.length?(this._stroke=typeof e==="function"?e:y.constant(e),this):this._stroke};t.prototype.strokeDasharray=function t(e){return arguments.length?(this._strokeDasharray=typeof e==="function"?e:y.constant(e),this):this._strokeDasharray};t.prototype.strokeLinecap=function t(e){return arguments.length?(this._strokeLinecap=typeof e==="function"?e:y.constant(e),this):this._strokeLinecap};t.prototype.strokeOpacity=function t(e){return arguments.length?(this._strokeOpacity=typeof e==="function"?e:y.constant(e),this):this._strokeOpacity};t.prototype.strokeWidth=function t(e){return arguments.length?(this._strokeWidth=typeof e==="function"?e:y.constant(e),this):this._strokeWidth};t.prototype.textAnchor=function t(e){return arguments.length?(this._textAnchor=typeof e==="function"?e:y.constant(e),this):this._textAnchor};t.prototype.vectorEffect=function t(e){return arguments.length?(this._vectorEffect=typeof e==="function"?e:y.constant(e),this):this._vectorEffect};t.prototype.verticalAlign=function t(e){return arguments.length?(this._verticalAlign=typeof e==="function"?e:y.constant(e),this):this._verticalAlign};t.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};t.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};return t}(y.BaseClass);function m(t,e,i,n){var r=1e-9;var s=t[0]-e[0],o=i[0]-n[0],a=t[1]-e[1],h=i[1]-n[1];var l=s*h-a*o;if(Math.abs(l)<r){return null}var c=t[0]*e[1]-t[1]*e[0],u=i[0]*n[1]-i[1]*n[0];var p=(c*o-u*s)/l,_=(c*h-u*a)/l;return[p,_]}function b(t,e,i){var n=1e-9;var r=i[0];var s=i[1];return!(r<Math.min(t[0],e[0])-n||r>Math.max(t[0],e[0])+n||s<Math.min(t[1],e[1])-n||s>Math.max(t[1],e[1])+n)}function c(t,e,i,n){var r=m(t,e,i,n);if(!r){return false}return b(t,e,r)&&b(i,n,r)}function _t(t,e){var i=-1;var n=t.length;var r=e.length;var s=t[n-1];while(++i<n){var o=s;s=t[i];var a=-1;var h=e[r-1];while(++a<r){var l=h;h=e[a];if(c(o,s,l,h)){return false}}}return ut.polygonContains(e,t[0])}function ft(t,e,i){if(i===void 0)i=0;var n=1e-9;e=[e[0]+n*Math.cos(i),e[1]+n*Math.sin(i)];var r=e[0];var s=e[1];var o=[r+Math.cos(i),s+Math.sin(i)];var a=0;if(Math.abs(o[0]-r)<n){a=1}var h=-1;var l=t.length;var c=t[l-1];var u=Number.MAX_VALUE;var p=Number.MAX_VALUE;var _=null;var f=null;while(++h<l){var d=c;c=t[h];var y=m(e,o,d,c);if(y&&b(d,c,y)){var v=pt(e,y);if(y[a]<e[a]){if(v<u){u=v;_=y}}else if(y[a]>e[a]){if(v<p){p=v;f=y}}}}return[_,f]}function n(t,e,i){if(i===void 0)i=[0,0];var n=Math.cos(e),r=Math.sin(e),s=t[0]-i[0],o=t[1]-i[1];return[n*s-r*o+i[0],r*s+n*o+i[1]]}function dt(t,e,i){if(i===void 0)i=[0,0];return t.map(function(t){return n(t,e,i)})}function u(t,e,i){var n=e[0],r=e[1];var s=i[0]-n,o=i[1]-r;if(s!==0||o!==0){var a=((t[0]-n)*s+(t[1]-r)*o)/(s*s+o*o);if(a>1){n=i[0];r=i[1]}else if(a>0){n+=s*a;r+=o*a}}s=t[0]-n;o=t[1]-r;return s*s+o*o}function s(t,e){var i,n=t[0];var r=[n];for(var s=1,o=t.length;s<o;s++){i=t[s];if(pt(i,n)>e){r.push(i);n=i}}if(n!==i){r.push(i)}return r}function p(t,e,i,n,r){var s,o=n;for(var a=e+1;a<i;a++){var h=u(t[a],t[e],t[i]);if(h>o){s=a;o=h}}if(o>n){if(s-e>1){p(t,e,s,n,r)}r.push(t[s]);if(i-s>1){p(t,s,i,n,r)}}}function a(t,e){var i=t.length-1;var n=[t[0]];p(t,0,i,e,n);n.push(t[i]);return n}function yt(t,e,i){if(e===void 0)e=1;if(i===void 0)i=false;if(t.length<=2){return t}var n=e*e;t=i?t:s(t,n);t=a(t,n);return t}var vt=.5;var gt=5;var xt={};function _(t,e){var i,n;if(e===void 0)e={};if(t.length<3){if(e.verbose){console.error("polygon has to have at least 3 points",t)}return null}var r=[];e=Object.assign({angle:ct.range(-90,90+gt,gt),cache:true,maxAspectRatio:15,minAspectRatio:1,minHeight:0,minWidth:0,nTries:20,tolerance:.02,verbose:false},e);var s=e.angle instanceof Array?e.angle:typeof e.angle==="number"?[e.angle]:typeof e.angle==="string"&&!isNaN(e.angle)?[Number(e.angle)]:[];var o=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 h;if(e.cache){h=ct.merge(t).join(",");h+="-"+e.minAspectRatio;h+="-"+e.maxAspectRatio;h+="-"+e.minHeight;h+="-"+e.minWidth;h+="-"+s.join(",");h+="-"+a.join(",");if(xt[h]){return xt[h]}}var l=Math.abs(ut.polygonArea(t));if(l===0){if(e.verbose){console.error("polygon has 0 area",t)}return null}var c=ct.extent(t,function(t){return t[0]});var u=c[0];var p=c[1];var _=ct.extent(t,function(t){return t[1]});var f=_[0];var d=_[1];var y=Math.min(p-u,d-f)*e.tolerance;if(y>0){t=yt(t,y)}if(e.events){r.push({type:"simplify",poly:t})}i=ct.extent(t,function(t){return t[0]}),u=i[0],p=i[1];n=ct.extent(t,function(t){return t[1]}),f=n[0],d=n[1];var v=[p-u,d-f];var g=v[0];var x=v[1];var m=Math.min(g,x)/50;if(!a.length){var b=ut.polygonCentroid(t);if(isNaN(b[0])||b[0]===Infinity||[-1,-0].includes(Math.sign(b[0]))){if(e.verbose){console.error("cannot find centroid",t)}return null}if(ut.polygonContains(t,b)){a.push(b)}while(a.length<e.nTries){var w=Math.random()*g+u;var k=Math.random()*x+f;var C=[w,k];if(ut.polygonContains(t,C)){a.push(C)}}}if(e.events){r.push({type:"origins",points:a})}var O=0;var A=null;for(var S=0;S<s.length;S++){var M=s[S];var E=-M*Math.PI/180;if(e.events){r.push({type:"angle",angle:M})}for(var W=0;W<a.length;W++){var P=a[W];var R=ft(t,P,E);var N=R[0];var L=R[1];var j=ft(t,P,E+Math.PI/2);var B=j[0];var H=j[1];var I=[];if(N&&L){I.push([(N[0]+L[0])/2,(N[1]+L[1])/2])}if(B&&H){I.push([(B[0]+H[0])/2,(B[1]+H[1])/2])}if(e.events){r.push({type:"modifOrigin",idx:W,p1W:N,p2W:L,p1H:B,p2H:H,modifOrigins:I})}for(var q=0;q<I.length;q++){var T=I[q];if(e.events){r.push({type:"origin",cx:T[0],cy:T[1]})}var D=ft(t,T,E);var z=D[0];var V=D[1];if(z===null||V===null){continue}var F=Math.min(pt(T,z),pt(T,V));var G=2*Math.sqrt(F);var U=ft(t,T,E+Math.PI/2);var X=U[0];var Y=U[1];if(X===null||Y===null){continue}var Z=Math.min(pt(T,X),pt(T,Y));var J=2*Math.sqrt(Z);if(G*J<O){continue}var K=o;if(!K.length){var Q=Math.max(e.minAspectRatio,e.minWidth/J,O/(J*J));var $=Math.min(e.maxAspectRatio,G/e.minHeight,G*G/O);K=ct.range(Q,$+vt,vt)}for(var tt=0;tt<K.length;tt++){var et=K[tt];var it=Math.max(e.minWidth,Math.sqrt(O*et));var nt=Math.min(G,J*et);if(nt*J<O){continue}if(e.events&&nt-it>=m){r.push({type:"aRatio",aRatio:et})}while(nt-it>=m){var rt=(it+nt)/2;var st=rt/et;var ot=T[0];var at=T[1];var ht=[[ot-rt/2,at-st/2],[ot+rt/2,at-st/2],[ot+rt/2,at+st/2],[ot-rt/2,at+st/2]];ht=dt(ht,E,T);var lt=_t(ht,t);if(lt){O=rt*st;ht.push(ht[0]);A={area:O,cx:ot,cy:at,width:rt,height:st,angle:-M,points:ht};it=rt}else{nt=rt}if(e.events){r.push({type:"rectangle",areaFraction:rt*st/l,cx:ot,cy:at,width:rt,height:st,angle:M,insidePoly:lt})}}}}}}if(e.cache){xt[h]=A}return e.events?Object.assign(A||{},{events:r}):A}var w=function(s){function t(){var r=this;s.call(this);this._curve="linear";this._defined=function(){return true};this._labelBounds=function(t,e,i){var n=_(i.points);if(!n){return null}return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2-r._x(t,e),y:n.cy-n.height/2-r._y(t,e)}};this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});this._name="Area";this._x=y.accessor("x");this._x0=y.accessor("x");this._x1=null;this._y=y.constant(0);this._y0=y.constant(0);this._y1=y.accessor("y")}if(s)t.__proto__=s;t.prototype=Object.create(s&&s.prototype);t.prototype.constructor=t;t.prototype._aes=function t(e){var i=this;var n=e.values.slice().sort(function(t,e){return i._y1?i._x(t)-i._x(e):i._y(t)-i._y(e)});var r=n.map(function(t,e){return[i._x0(t,e),i._y0(t,e)]});var s=n.reverse().map(function(t,e){return i._y1?[i._x(t,e),i._y1(t,e)]:[i._x1(t,e),i._y(t,e)]});var o=r.concat(s);if(r[0][1]>s[0][1]){o=o.reverse()}o.push(o[0]);return{points:o}};t.prototype._dataFilter=function t(n){var r=this;var e=l.nest().key(this._id).entries(n).map(function(t){t.data=y.merge(t.values);t.i=n.indexOf(t.values[0]);var e=ct.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 i=ct.extent(t.values.map(r._y).concat(t.values.map(r._y0)).concat(r._y1?t.values.map(r._y1):[]));t.yR=i;t.height=i[1]-i[0];t.y=i[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};t.prototype.render=function t(e){s.prototype.render.call(this,e);var i=this._path=v.area().defined(this._defined).curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);var n=v.area().defined(function(t){return t}).curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).x(this._x).x0(this._x0).x1(this._x1).y(this._y).y0(this._y0).y1(this._y1);this._enter.append("path").attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attr("d",function(t){return i(t.values)}).call(this._applyStyle.bind(this));this._update.select("path").transition(this._transition).attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attrTween("d",function(t){return o.interpolatePath(f.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(f.select(this).attr("d"),n(t.values))});return this};t.prototype.curve=function t(e){return arguments.length?(this._curve=e,this):this._curve};t.prototype.defined=function t(e){return arguments.length?(this._defined=e,this):this._defined};t.prototype.x=function t(e){if(!arguments.length){return this._x}this._x=typeof e==="function"?e:y.constant(e);this._x0=this._x;return this};t.prototype.x0=function t(e){if(!arguments.length){return this._x0}this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this};t.prototype.x1=function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1};t.prototype.y=function t(e){if(!arguments.length){return this._y}this._y=typeof e==="function"?e:y.constant(e);this._y0=this._y;return this};t.prototype.y0=function t(e){if(!arguments.length){return this._y0}this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this};t.prototype.y1=function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1};return t}(e);var k=function(r){function t(){var n=this;r.call(this,"rect");this._name="Bar";this._height=y.constant(10);this._labelBounds=function(t,e,i){return{width:i.width,height:i.height,x:n._x1!==null?n._getX(t,e):-i.width/2,y:n._x1===null?n._getY(t,e):-i.height/2}};this._width=y.constant(10);this._x=y.accessor("x");this._x0=y.accessor("x");this._x1=null;this._y=y.constant(0);this._y0=y.constant(0);this._y1=y.accessor("y")}if(r)t.__proto__=r;t.prototype=Object.create(r&&r.prototype);t.prototype.constructor=t;t.prototype.render=function t(e){var i=this;r.prototype.render.call(this,e);this._enter.attr("width",function(t,e){return i._x1===null?i._getWidth(t,e):0}).attr("height",function(t,e){return i._x1!==null?i._getHeight(t,e):0}).attr("x",function(t,e){return i._x1===null?-i._getWidth(t,e)/2:0}).attr("y",function(t,e){return i._x1!==null?-i._getHeight(t,e)/2:0}).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("width",function(t,e){return i._x1===null?i._getWidth(t,e):0}).attr("height",function(t,e){return i._x1!==null?i._getHeight(t,e):0}).attr("x",function(t,e){return i._x1===null?-i._getWidth(t,e)/2:0}).attr("y",function(t,e){return i._x1!==null?-i._getHeight(t,e)/2:0});return this};t.prototype._aes=function t(e,i){return{height:this._getHeight(e,i),width:this._getWidth(e,i)}};t.prototype._applyPosition=function t(e){var i=this;e.attr("width",function(t,e){return i._getWidth(t,e)}).attr("height",function(t,e){return i._getHeight(t,e)}).attr("x",function(t,e){return i._x1!==null?i._getX(t,e):-i._getWidth(t,e)/2}).attr("y",function(t,e){return i._x1===null?i._getY(t,e):-i._getHeight(t,e)/2})};t.prototype._getHeight=function t(e,i){if(this._x1!==null){return this._height(e,i)}return Math.abs(this._y1(e,i)-this._y(e,i))};t.prototype._getWidth=function t(e,i){if(this._x1===null){return this._width(e,i)}return Math.abs(this._x1(e,i)-this._x(e,i))};t.prototype._getX=function t(e,i){var n=this._x1===null?this._x(e,i):this._x1(e,i)-this._x(e,i);if(n<0){return n}else{return 0}};t.prototype._getY=function t(e,i){var n=this._x1!==null?this._y(e,i):this._y1(e,i)-this._y(e,i);if(n<0){return n}else{return 0}};t.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};t.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};t.prototype.x0=function t(e){if(!arguments.length){return this._x0}this._x0=typeof e==="function"?e:y.constant(e);this._x=this._x0;return this};t.prototype.x1=function t(e){return arguments.length?(this._x1=typeof e==="function"||e===null?e:y.constant(e),this):this._x1};t.prototype.y0=function t(e){if(!arguments.length){return this._y0}this._y0=typeof e==="function"?e:y.constant(e);this._y=this._y0;return this};t.prototype.y1=function t(e){return arguments.length?(this._y1=typeof e==="function"||e===null?e:y.constant(e),this):this._y1};return t}(e);var C=function(i){function t(){i.call(this,"circle");this._labelBounds=function(t,e,i){return{width:i.r*1.5,height:i.r*1.5,x:-i.r*.75,y:-i.r*.75}};this._labelConfig=y.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"});this._name="Circle";this._r=y.accessor("r")}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype._applyPosition=function t(e){var i=this;e.attr("r",function(t,e){return i._r(t,e)}).attr("x",function(t,e){return-i._r(t,e)/2}).attr("y",function(t,e){return-i._r(t,e)/2})};t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("r",0).attr("x",0).attr("y",0).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("r",0).attr("x",0).attr("y",0);return this};t.prototype._aes=function t(e,i){return{r:this._r(e,i)}};t.prototype.r=function t(e){return arguments.length?(this._r=typeof e==="function"?e:y.constant(e),this):this._r};return t}(e);var O=function(i){function t(){i.call(this,"rect");this._height=y.accessor("height");this._labelBounds=function(t,e,i){return{width:i.width,height:i.height,x:-i.width/2,y:-i.height/2}};this._name="Rect";this._width=y.accessor("width")}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("width",0).attr("height",0).attr("x",0).attr("y",0).call(this._applyStyle.bind(this)).transition(this._transition).call(this._applyPosition.bind(this));this._update.transition(this._transition).call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));this._exit.transition(this._transition).attr("width",0).attr("height",0).attr("x",0).attr("y",0);return this};t.prototype._aes=function t(e,i){return{width:this._width(e,i),height:this._height(e,i)}};t.prototype._applyPosition=function t(e){var i=this;e.attr("width",function(t,e){return i._width(t,e)}).attr("height",function(t,e){return i._height(t,e)}).attr("x",function(t,e){return-i._width(t,e)/2}).attr("y",function(t,e){return-i._height(t,e)/2})};t.prototype.height=function t(e){return arguments.length?(this._height=typeof e==="function"?e:y.constant(e),this):this._height};t.prototype.width=function t(e){return arguments.length?(this._width=typeof e==="function"?e:y.constant(e),this):this._width};return t}(e);var A=function(r){function t(){var e=this;r.call(this);this._curve="linear";this._defined=function(t){return t};this._fill=y.constant("none");this._hitArea=y.constant({d:function(t){return e._path(t.values)},fill:"none","stroke-width":10,transform:null});this._name="Line";this._path=v.line();this._stroke=y.constant("black");this._strokeWidth=y.constant(1)}if(r)t.__proto__=r;t.prototype=Object.create(r&&r.prototype);t.prototype.constructor=t;t.prototype._dataFilter=function t(n){var r=this;var e=l.nest().key(this._id).entries(n).map(function(t){t.data=y.merge(t.values);t.i=n.indexOf(t.values[0]);var e=ct.extent(t.values,r._x);t.xR=e;t.width=e[1]-e[0];t.x=e[0]+t.width/2;var i=ct.extent(t.values,r._y);t.yR=i;t.height=i[1]-i[0];t.y=i[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};t.prototype.render=function t(e){var i=this;r.prototype.render.call(this,e);var n=this;this._path.curve(v["curve"+this._curve.charAt(0).toUpperCase()+this._curve.slice(1)]).defined(this._defined).x(this._x).y(this._y);this._enter.append("path").attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attr("d",function(t){return i._path(t.values)}).call(this._applyStyle.bind(this));this._update.select("path").transition(this._transition).attr("transform",function(t){return"translate("+(-t.xR[0]-t.width/2)+", "+(-t.yR[0]-t.height/2)+")"}).attrTween("d",function(t){return o.interpolatePath(f.select(this).attr("d"),n._path(t.values))}).call(this._applyStyle.bind(this));return this};t.prototype._aes=function t(e,i){var n=this;return{points:e.values.map(function(t){return[n._x(t,i),n._y(t,i)]})}};t.prototype.curve=function t(e){return arguments.length?(this._curve=e,this):this._curve};t.prototype.defined=function t(e){return arguments.length?(this._defined=e,this):this._defined};return t}(e);var S={Circle:C,Rect:O};var M=function(t){function e(){t.call(this);this._endpoint=y.accessor("endpoint","Rect");this._endpointConfig={Circle:{r:y.accessor("r",5)}};this._length=y.accessor("length",25);this._lineConfig={};this._orient=y.accessor("orient","top");this._x=y.accessor("x",0);this._y=y.accessor("y",0)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.render=function t(e){var a=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var h=[];this._data.forEach(function(t,e){var i=a._orient(t,e);var n=a._x(t,e);var r=a._y(t,e);var s=n;if(i==="left"){s-=a._length(t,e)}else if(i==="right"){s+=a._length(t,e)}var o=r;if(i==="top"){o-=a._length(t,e)}else if(i==="bottom"){o+=a._length(t,e)}h.push({__d3plus__:true,data:t,i:e,id:e,x:n,y:r});h.push({__d3plus__:true,data:t,i:e,id:e,x:s,y:o})});this._line=(new A).data(h).select(y.elem("g.d3plus-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._lineConfig,"shape")).render(e);var i=this._data.map(function(t,e){var i={};i.__d3plus__=true;i.data=t;i.i=e;i.endpoint=a._endpoint(t,e);i.length=a._length(t,e);i.orient=a._orient(t,e);var n=a._x(t,e);if(i.orient==="left"){n-=i.length}else if(i.orient==="right"){n+=i.length}var r=a._y(t,e);if(i.orient==="top"){r-=i.length}else if(i.orient==="bottom"){r+=i.length}i.x=n;i.y=r;return i});this._whiskerEndpoint=[];l.nest().key(function(t){return t.endpoint}).entries(i).forEach(function(t){var e=t.key;a._whiskerEndpoint.push((new S[e]).data(t.values).select(y.elem("g.d3plus-Whisker-Endpoint-"+e,{parent:a._select}).node()).config({height:function(t){return t.orient==="top"||t.orient==="bottom"?5:20},width:function(t){return t.orient==="top"||t.orient==="bottom"?20:5}}).config(y.configPrep.bind(a)(a._endpointConfig,"shape",e)).render())});return this};e.prototype.active=function t(e){if(this._line){this._line.active(e)}if(this._whiskerEndpoint){this._whiskerEndpoint.forEach(function(t){return t.active(e)})}};e.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};e.prototype.endpoint=function t(e){return arguments.length?(this._endpoint=typeof e==="function"?e:y.constant(e),this):this._endpoint};e.prototype.endpointConfig=function t(e){return arguments.length?(this._endpointConfig=y.assign(this._endpointConfig,e),this):this._endpointConfig};e.prototype.hover=function t(e){if(this._line){this._line.hover(e)}if(this._whiskerEndpoint){this._whiskerEndpoint.forEach(function(t){return t.hover(e)})}};e.prototype.length=function t(e){return arguments.length?(this._length=typeof e==="function"?e:y.constant(e),this):this._length};e.prototype.lineConfig=function t(e){return arguments.length?(this._lineConfig=y.assign(this._lineConfig,e),this):this._lineConfig};e.prototype.orient=function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient};e.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};e.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.constant(e),this):this._x};e.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.constant(e),this):this._y};return e}(y.BaseClass);var E={Circle:C,Rect:O};var W=function(t){function e(){var i=this;t.call(this);this._medianConfig={fill:y.constant("black")};this._orient=y.accessor("orient","vertical");this._outlier=y.accessor("outlier","Circle");this._outlierConfig={Circle:{r:y.accessor("r",5)},Rect:{height:function(t,e){return i._orient(t,e)==="vertical"?5:20},width:function(t,e){return i._orient(t,e)==="vertical"?20:5}}};this._rectConfig={fill:y.constant("white"),stroke:y.constant("black"),strokeWidth:y.constant(1)};this._rectWidth=y.constant(50);this._whiskerConfig={};this._whiskerMode=["tukey","tukey"];this._x=y.accessor("x",250);this._y=y.accessor("y",250)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.render=function t(){var s=this;if(this._select===void 0){this.select(f.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node())}var o=[];var e=l.nest().key(function(t,e){return s._orient(t,e)==="vertical"?s._x(t,e):s._y(t,e)}).entries(this._data).map(function(r){r.data=y.merge(r.values);r.i=s._data.indexOf(r.values[0]);r.orient=s._orient(r.data,r.i);var t=r.values.map(r.orient==="vertical"?s._y:s._x);t.sort(function(t,e){return t-e});r.first=ct.quantile(t,.25);r.median=ct.quantile(t,.5);r.third=ct.quantile(t,.75);var e=s._whiskerMode;if(e[0]==="tukey"){r.lowerLimit=r.first-(r.third-r.first)*1.5;if(r.lowerLimit<ct.min(t)){r.lowerLimit=ct.min(t)}}else if(e[0]==="extent"){r.lowerLimit=ct.min(t)}else if(typeof e[0]==="number"){r.lowerLimit=ct.quantile(t,e[0])}if(e[1]==="tukey"){r.upperLimit=r.third+(r.third-r.first)*1.5;if(r.upperLimit>ct.max(t)){r.upperLimit=ct.max(t)}}else if(e[1]==="extent"){r.upperLimit=ct.max(t)}else if(typeof e[1]==="number"){r.upperLimit=ct.quantile(t,e[1])}var i=r.third-r.first;if(r.orient==="vertical"){r.height=i;r.width=s._rectWidth(r.data,r.i);r.x=s._x(r.data,r.i);r.y=r.first+i/2}else if(r.orient==="horizontal"){r.height=s._rectWidth(r.data,r.i);r.width=i;r.x=r.first+i/2;r.y=s._y(r.data,r.i)}r.values.forEach(function(t,e){var i=r.orient==="vertical"?s._y(t,e):s._x(t,e);if(i<r.lowerLimit||i>r.upperLimit){var n={};n.__d3plus__=true;n.data=t;n.i=e;n.outlier=s._outlier(t,e);if(r.orient==="vertical"){n.x=r.x;n.y=i;o.push(n)}else if(r.orient==="horizontal"){n.y=r.y;n.x=i;o.push(n)}}});r.__d3plus__=true;return r});this._box=(new O).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 O).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 i=t.x;var n=t.y;var r=t.first-t.lowerLimit;var s=t.upperLimit-t.third;if(t.orient==="vertical"){var o=n-t.height/2;var a=n+t.height/2;c.push({__d3plus__:true,data:t,i:e,x:i,y:o,length:r,orient:"top"},{__d3plus__:true,data:t,i:e,x:i,y:a,length:s,orient:"bottom"})}else if(t.orient==="horizontal"){var h=i+t.width/2;var l=i-t.width/2;c.push({__d3plus__:true,data:t,i:e,x:h,y:n,length:s,orient:"right"},{__d3plus__:true,data:t,i:e,x:l,y:n,length:r,orient:"left"})}});this._whisker=(new M).data(c).select(y.elem("g.d3plus-Box-Whisker",{parent:this._select}).node()).config(y.configPrep.bind(this)(this._whiskerConfig,"shape")).render();this._whiskerEndpoint=[];l.nest().key(function(t){return t.outlier}).entries(o).forEach(function(t){var e=t.key;s._whiskerEndpoint.push((new E[e]).data(t.values).select(y.elem("g.d3plus-Box-Outlier-"+e,{parent:s._select}).node()).config(y.configPrep.bind(s)(s._outlierConfig,"shape",e)).render())});return this};e.prototype.active=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)})}};e.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};e.prototype.hover=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)})}};e.prototype.medianConfig=function t(e){return arguments.length?(this._medianConfig=y.assign(this._medianConfig,e),this):this._medianConfig};e.prototype.orient=function t(e){return arguments.length?(this._orient=typeof e==="function"?e:y.constant(e),this):this._orient};e.prototype.outlier=function t(e){return arguments.length?(this._outlier=typeof e==="function"?e:y.constant(e),this):this._outlier};e.prototype.outlierConfig=function t(e){return arguments.length?(this._outlierConfig=y.assign(this._outlierConfig,e),this):this._outlierConfig};e.prototype.rectConfig=function t(e){return arguments.length?(this._rectConfig=y.assign(this._rectConfig,e),this):this._rectConfig};e.prototype.rectWidth=function t(e){return arguments.length?(this._rectWidth=typeof e==="function"?e:y.constant(e),this):this._rectWidth};e.prototype.select=function t(e){return arguments.length?(this._select=f.select(e),this):this._select};e.prototype.whiskerConfig=function t(e){return arguments.length?(this._whiskerConfig=y.assign(this._whiskerConfig,e),this):this._whiskerConfig};e.prototype.whiskerMode=function t(e){return arguments.length?(this._whiskerMode=e instanceof Array?e:[e,e],this):this._whiskerMode};e.prototype.x=function t(e){return arguments.length?(this._x=typeof e==="function"?e:y.accessor(e),this):this._x};e.prototype.y=function t(e){return arguments.length?(this._y=typeof e==="function"?e:y.accessor(e),this):this._y};return e}(y.BaseClass);var P=Math.PI;function R(t,e,i){if(i===void 0)i="circle";if(t<0){t=P*2+t}if(i==="square"){var n=45*(P/180);var r=0,s=0;if(t<P/2){var o=Math.tan(t);r+=t<n?e:e/o;s+=t<n?o*e:e}else if(t<=P){var a=Math.tan(P-t);r-=t<P-n?e/a:e;s+=t<P-n?e:a*e}else if(t<n+P){r-=e;s-=Math.tan(t-P)*e}else if(t<3*P/2){r-=e/Math.tan(t-P);s-=e}else if(t<2*P-n){r+=e/Math.tan(2*P-t);s-=e}else{r+=e;s-=Math.tan(2*P-t)*e}return[r,s]}else if(i==="circle"){return[e*Math.cos(t),e*Math.sin(t)]}else{return null}}var N=Math.PI;function L(t,e){if(e===void 0)e=20;var i=[],n=/([MLA])([^MLAZ]+)/gi;var r=n.exec(t);while(r!==null){if(["M","L"].includes(r[1])){i.push(r[2].split(",").map(Number))}else if(r[1]==="A"){var s=r[2].split(",").map(Number);var o=s.slice(s.length-2,s.length),a=i[i.length-1],h=s[0],l=x(a,o);var c=Math.acos((h*h+h*h-l*l)/(2*h*h));if(s[2]){c=N*2-c}var u=c/(c/(N*2)*(h*N*2)/e);var p=Math.atan2(-a[1],-a[0])-N;var _=u;while(_<c){i.push(R(s[4]?p+_:p-_,h));_+=u}i.push(o)}r=n.exec(t)}return i}var j=function(i){function t(){var r=this;i.call(this,"path");this._d=y.accessor("path");this._labelBounds=function(t,e,i){var n=_(i.points,{angle:r._labelConfig.rotate?r._labelConfig.rotate(t,e):0});return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}};this._name="Path";this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}if(i)t.__proto__=i;t.prototype=Object.create(i&&i.prototype);t.prototype.constructor=t;t.prototype._aes=function t(e,i){return{points:L(this._d(e,i))}};t.prototype.render=function t(e){i.prototype.render.call(this,e);this._enter.attr("opacity",0).attr("d",this._d).call(this._applyStyle.bind(this)).transition(this._transition).attr("opacity",1);this._update.transition(this._transition).call(this._applyStyle.bind(this)).attr("opacity",1).attr("d",this._d);this._exit.transition(this._transition).attr("opacity",0);return this};t.prototype.d=function t(e){return arguments.length?(this._d=typeof e==="function"?e:y.constant(e),this):this._d};return t}(e);t.Image=h;t.Shape=e;t.Area=w;t.Bar=k;t.Box=W;t.Circle=C;t.Line=A;t.Path=j;t.Rect=O;t.Whisker=M;t.largestRect=_;t.lineIntersection=m;t.path2polygon=L;t.pointDistance=x;t.pointDistanceSquared=pt;t.pointRotate=n;t.polygonInside=_t;t.polygonRayCast=ft;t.polygonRotate=dt;t.segmentBoxContains=b;t.segmentsIntersect=c;t.shapeEdgePoint=R;t.simplify=yt;Object.defineProperty(t,"__esModule",{value:true})}); |
@@ -131,3 +131,3 @@ import {extent, merge, range} from "d3-array"; | ||
var centroid = polygonCentroid(poly); | ||
if (isNaN(centroid[0]) || centroid[0] === Infinity || centroid[0] < 0) { | ||
if (isNaN(centroid[0]) || centroid[0] === Infinity || [-1, -0].includes(Math.sign(centroid[0]))) { | ||
if (options.verbose) { console.error("cannot find centroid", poly); } | ||
@@ -134,0 +134,0 @@ return null; |
{ | ||
"name": "d3plus-shape", | ||
"version": "0.16.4", | ||
"version": "0.16.5", | ||
"description": "Fancy SVG shapes for visualizations", | ||
@@ -5,0 +5,0 @@ "main": "build/d3plus-shape.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
801279