@d3plus/core 3.0.14 → 3.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -51
- package/es/src/charts/Sankey.js +37 -1
- package/es/src/charts/Viz.js +1 -1
- package/es/src/shapes/Shape.js +6 -6
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +37 -10
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +394 -376
- package/umd/d3plus-core.js +37 -10
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +132 -114
package/umd/d3plus-core.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.16
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
|
-
Copyright (c)
|
|
4
|
+
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
6
6
|
*/
|
|
7
|
-
(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){if("undefined"!=typeof window){try{if("undefined"==typeof SVGElement||Boolean(SVGElement.prototype.innerHTML))return}catch(t){return}function s(t){switch(t.nodeType){case 1:var i=t,e="";return e+="<"+i.tagName,i.hasAttributes()&&[].forEach.call(i.attributes,function(t){e+=" "+t.name+'="'+t.value+'"'}),e+=">",i.hasChildNodes()&&[].forEach.call(i.childNodes,function(t){e+=s(t)}),e+="</"+i.tagName+">";case 3:return t.textContent.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");case 8:return"\x3c!--"+t.nodeValue+"--\x3e"}}Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var i="";return[].forEach.call(this.childNodes,function(t){i+=s(t)}),i},set:function(t){for(;this.firstChild;)this.removeChild(this.firstChild);try{var i=new DOMParser,e=(i.async=!1,"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>"),s=i.parseFromString(e,"text/xml").documentElement;[].forEach.call(s.childNodes,function(t){this.appendChild(this.ownerDocument.importNode(t,!0))}.bind(this))}catch(t){throw new Error("Error parsing markup string")}}}),Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})}}),((t,i)=>{"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@d3plus/dom"),require("@d3plus/locales"),require("d3-array"),require("d3-collection"),require("d3-scale"),require("d3-shape"),require("open-color/open-color.js"),require("@d3plus/color"),require("@d3plus/data"),require("@d3plus/math"),require("@d3plus/format"),require("d3-time-format"),require("d3-selection"),require("d3-transition"),require("@d3plus/text"),require("d3-interpolate"),require("d3-color"),require("textures"),require("d3-interpolate-path"),require("d3-brush"),require("@popperjs/core"),require("d3-queue"),require("d3-zoom"),require("lrucache"),require("d3-geo"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-tile"),require("topojson-client"),require("d3-force"),require("d3-polygon"),require("d3-hierarchy"),require("d3-sankey")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","@d3plus/dom","@d3plus/locales","d3-array","d3-collection","d3-scale","d3-shape","open-color/open-color.js","@d3plus/color","@d3plus/data","@d3plus/math","@d3plus/format","d3-time-format","d3-selection","d3-transition","@d3plus/text","d3-interpolate","d3-color","textures","d3-interpolate-path","d3-brush","@popperjs/core","d3-queue","d3-zoom","lrucache","d3-geo","d3-geo-projection","d3-composite-projections","d3-tile","topojson-client","d3-force","d3-polygon","d3-hierarchy","d3-sankey"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus={},t.dom,t.locales,t.d3Array,t.d3Collection,t.scales,t.paths,t.pkg,t.color,t.data,t.math,t.format,t.d3TimeFormat,t.d3Selection,t.d3Transition,t.text,t.d3Interpolate,t.d3Color,t.textures,t.d3InterpolatePath,t.d3Brush,t.core,t.d3Queue,t.d3Zoom,t.lrucache,t.d3GeoCore,t.d3GeoProjection,t.d3CompositeProjections,t.d3Tile,t.topojsonClient,t.d3Force,t.d3Polygon,t.d3Hierarchy,t.d3Sankey)})(this,function(t,Pt,$,Dt,Ot,
|
|
7
|
+
(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){if("undefined"!=typeof window){try{if("undefined"==typeof SVGElement||Boolean(SVGElement.prototype.innerHTML))return}catch(t){return}function s(t){switch(t.nodeType){case 1:var i=t,e="";return e+="<"+i.tagName,i.hasAttributes()&&[].forEach.call(i.attributes,function(t){e+=" "+t.name+'="'+t.value+'"'}),e+=">",i.hasChildNodes()&&[].forEach.call(i.childNodes,function(t){e+=s(t)}),e+="</"+i.tagName+">";case 3:return t.textContent.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");case 8:return"\x3c!--"+t.nodeValue+"--\x3e"}}Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var i="";return[].forEach.call(this.childNodes,function(t){i+=s(t)}),i},set:function(t){for(;this.firstChild;)this.removeChild(this.firstChild);try{var i=new DOMParser,e=(i.async=!1,"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>"),s=i.parseFromString(e,"text/xml").documentElement;[].forEach.call(s.childNodes,function(t){this.appendChild(this.ownerDocument.importNode(t,!0))}.bind(this))}catch(t){throw new Error("Error parsing markup string")}}}),Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})}}),((t,i)=>{"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@d3plus/dom"),require("@d3plus/locales"),require("d3-array"),require("d3-collection"),require("d3-scale"),require("d3-shape"),require("open-color/open-color.js"),require("@d3plus/color"),require("@d3plus/data"),require("@d3plus/math"),require("@d3plus/format"),require("d3-time-format"),require("d3-selection"),require("d3-transition"),require("@d3plus/text"),require("d3-interpolate"),require("d3-color"),require("textures"),require("d3-interpolate-path"),require("d3-brush"),require("@popperjs/core"),require("d3-queue"),require("d3-zoom"),require("lrucache"),require("d3-geo"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-tile"),require("topojson-client"),require("d3-force"),require("d3-polygon"),require("d3-hierarchy"),require("d3-sankey")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","@d3plus/dom","@d3plus/locales","d3-array","d3-collection","d3-scale","d3-shape","open-color/open-color.js","@d3plus/color","@d3plus/data","@d3plus/math","@d3plus/format","d3-time-format","d3-selection","d3-transition","@d3plus/text","d3-interpolate","d3-color","textures","d3-interpolate-path","d3-brush","@popperjs/core","d3-queue","d3-zoom","lrucache","d3-geo","d3-geo-projection","d3-composite-projections","d3-tile","topojson-client","d3-force","d3-polygon","d3-hierarchy","d3-sankey"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus={},t.dom,t.locales,t.d3Array,t.d3Collection,t.scales,t.paths,t.pkg,t.color,t.data,t.math,t.format,t.d3TimeFormat,t.d3Selection,t.d3Transition,t.text,t.d3Interpolate,t.d3Color,t.textures,t.d3InterpolatePath,t.d3Brush,t.core,t.d3Queue,t.d3Zoom,t.lrucache,t.d3GeoCore,t.d3GeoProjection,t.d3CompositeProjections,t.d3Tile,t.topojsonClient,t.d3Force,t.d3Polygon,t.d3Hierarchy,t.d3Sankey)})(this,function(t,Pt,$,Dt,Ot,k,m,g,A,Lt,E,Tt,N,j,I,H,z,n,c,u,y,x,b,d,v,C,w,S,M,P,D,O,f,e){function L(e){var s=Object.create(null);return e&&Object.keys(e).forEach(function(t){var i;"default"!==t&&(i=Object.getOwnPropertyDescriptor(e,t),Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:function(){return e[t]}}))}),s.default=e,Object.freeze(s)}var $t=L(k),Et=L(m),C=L(C),w=L(w),S=L(S);
|
|
8
8
|
/**
|
|
9
9
|
@function accessor
|
|
10
10
|
@desc Wraps an object key in a simple accessor function.
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
@param {Object} [config = this._shapeConfig] The configuration object to parse.
|
|
113
113
|
@param {String} [type = "shape"] The event classifier to user for "on" events. For example, the default event type of "shape" will apply all events in the "on" config object with that key, like "click.shape" and "mouseleave.shape", in addition to any gloval events like "click" and "mouseleave".
|
|
114
114
|
@param {String} [nest] An optional nested key to bubble up to the parent config level.
|
|
115
|
-
*/function jt(t=this._shapeConfig,s="shape",i=!1){var e={duration:this._duration,on:{}};let h=n=>(t,i,e,s)=>{if(!n)return n;let h;for(;t.__d3plus__;)h&&(t.__d3plusParent__=h),i=(h=t).i,t=t.data||t.feature;return n.bind(this)(t,i,e||h,s)},n=(t,i)=>{for(var e in i)({}.hasOwnProperty.call(i,e)&&!e.includes(".")||e.includes("."+s))&&(t.on[e]=h(i[e]))},
|
|
115
|
+
*/function jt(t=this._shapeConfig,s="shape",i=!1){var e={duration:this._duration,on:{}};let h=n=>(t,i,e,s)=>{if(!n)return n;let h;for(;t.__d3plus__;)h&&(t.__d3plusParent__=h),i=(h=t).i,t=t.data||t.feature;return n.bind(this)(t,i,e||h,s)},n=(t,i)=>{for(var e in i)({}.hasOwnProperty.call(i,e)&&!e.includes(".")||e.includes("."+s))&&(t.on[e]=h(i[e]))},r=t=>t.map(t=>t instanceof Array?r(t):"object"==typeof t?a({},t):"function"==typeof t?h(t):t),a=(t,i)=>{for(var e in i)!{}.hasOwnProperty.call(i,e)||("on"===e?n(t,i[e]):"function"==typeof i[e]?t[e]=h(i[e]):i[e]instanceof Array?t[e]=r(i[e]):"object"==typeof i[e]?(t[e]||(t[e]={}),t[e].on={},a(t[e],i[e])):t[e]=i[e])};return a(e,t),this._on&&n(e,this._on),i&&t[i]&&(a(e,t[i]),t[i].on)&&n(e,t[i].on),e}
|
|
116
116
|
/**
|
|
117
117
|
@function constant
|
|
118
118
|
@desc Wraps non-function variables in a simple return function.
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
@param {Object} d
|
|
131
131
|
@param {Number} i
|
|
132
132
|
@private
|
|
133
|
-
*/function
|
|
133
|
+
*/function a(t,i,e){return i[t]||this["_"+t](i,e)}class V{
|
|
134
134
|
/**
|
|
135
135
|
@memberof Image
|
|
136
136
|
@desc Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
@@ -237,8 +237,8 @@
|
|
|
237
237
|
* @param {*} classNames
|
|
238
238
|
* @private
|
|
239
239
|
*/function Y(i,e){for(let t=0;t<e.length;t++){var s=e[t];for(let t=i.length-1;0<=t;t--)if(i[t].classList.contains(s))return t;// Return the index if found
|
|
240
|
-
}return
|
|
241
|
-
}class
|
|
240
|
+
}return-1;// Return -1 if no element is found with the class
|
|
241
|
+
}class r extends h{
|
|
242
242
|
/**
|
|
243
243
|
@memberof Shape
|
|
244
244
|
@desc Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
@@ -315,7 +315,7 @@ this._group.selectAll(`g.d3plus-${this._name}-shape, g.d3plus-${this._name}-imag
|
|
|
315
315
|
@memberof Shape
|
|
316
316
|
@desc Modifies existing shapes to show hover status.
|
|
317
317
|
@private
|
|
318
|
-
*/_renderHover(){let
|
|
318
|
+
*/_renderHover(){let 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,i){(t=t||{}).parentNode||(t.parentNode=this.parentNode);var e=t.parentNode,s=j.select(this).classed("d3plus-textBox")?"textBox":j.select(this).classed("d3plus-Image")?"Image":"Shape";if((t="textBox"==s?t.data:t).__d3plusShape__||t.__d3plus__)for(;t&&(t.__d3plusShape__||t.__d3plus__);)i=t.i,t=t.data;else i=r._data.indexOf(t);var h=!r._hover||"function"!=typeof r._hover||!r._hover(t,i),n=h?e:r._hoverGroup.node();n!==this.parentNode&&(s="textBox"==s?Y(n.childNodes,["d3plus-Image","d3plus-Shape"]):"Image"==s?Y(n.childNodes,["d3plus-Shape"]):-1,h?n.appendChild(this):-1===s?n.prepend(this):n.childNodes[s].after(this)),this.className.baseVal.includes("d3plus-Shape")&&(e===n?j.select(this).call(r._applyStyle.bind(r)):j.select(this).call(r._updateStyle.bind(r,j.select(this),r._hoverStyle)))}),
|
|
319
319
|
// this._renderImage();
|
|
320
320
|
// this._renderLabels();
|
|
321
321
|
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)}
|
|
@@ -323,12 +323,12 @@ this._group.selectAll(`g.d3plus-${this._name}-shape, g.d3plus-${this._name}-imag
|
|
|
323
323
|
@memberof Shape
|
|
324
324
|
@desc Adds background image to each shape group.
|
|
325
325
|
@private
|
|
326
|
-
*/_renderImage(){let o=[];this._update.merge(this._enter).data().forEach((s,h)=>{var n=this._aes(s,h);if(n.r||n.width&&n.height){let e=s;s.nested&&s.key&&s.values&&(e=s.values[0],h=this._data.indexOf(e));var s=n.r?2*n.r:n.height,
|
|
326
|
+
*/_renderImage(){let o=[];this._update.merge(this._enter).data().forEach((s,h)=>{var n=this._aes(s,h);if(n.r||n.width&&n.height){let e=s;s.nested&&s.key&&s.values&&(e=s.values[0],h=this._data.indexOf(e));var s=n.r?2*n.r:n.height,r=this._backgroundImage(e,h),a=n.r?2*n.r:n.width;if(r){let t=e.__d3plusShape__?e.translate?e.translate[0]:this._x(e.data,e.i):this._x(e,h),i=e.__d3plusShape__?e.translate?e.translate[1]:this._y(e.data,e.i):this._y(e,h);n.x&&(t+=n.x),n.y&&(i+=n.y),e.__d3plusShape__&&(h=(e=e.data).i),o.push({__d3plus__:!0,data:e,height:s,i:h,id:this._id(e,h),url:r,width:a,x:t+-a/2,y:i+-s/2})}}}),this._backgroundImageClass.data(o).duration(this._duration).opacity(this._nestWrapper(this._opacity)).pointerEvents("none").select(Pt.elem(`g.d3plus-${this._name}-image`,{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).render()}
|
|
327
327
|
/**
|
|
328
328
|
@memberof Shape
|
|
329
329
|
@desc Adds labels to each shape group.
|
|
330
330
|
@private
|
|
331
|
-
*/_renderLabels(){let _=[];this._update.merge(this._enter).data().forEach((t,i)=>{let e=t,s=(t.nested&&t.key&&t.values&&(e=t.values[0],i=this._data.indexOf(e)),this._label(e,i));if(this._labelBounds&&!1!==s&&null!=s){var h=this._labelBounds.bind(this)(e,i,this._aes(t,i));if(h){s.constructor!==Array&&(s=[s]);var n=e.__d3plusShape__?e.translate?e.translate[0]:this._x(e.data,e.i):this._x(e,i),
|
|
331
|
+
*/_renderLabels(){let _=[];this._update.merge(this._enter).data().forEach((t,i)=>{let e=t,s=(t.nested&&t.key&&t.values&&(e=t.values[0],i=this._data.indexOf(e)),this._label(e,i));if(this._labelBounds&&!1!==s&&null!=s){var h=this._labelBounds.bind(this)(e,i,this._aes(t,i));if(h){s.constructor!==Array&&(s=[s]);var n=e.__d3plusShape__?e.translate?e.translate[0]:this._x(e.data,e.i):this._x(e,i),r=e.__d3plusShape__?e.translate?e.translate[1]:this._y(e.data,e.i):this._y(e,i);e.__d3plusShape__&&(i=(e=e.data).i);for(let t=0;t<s.length;t++){var a=h.constructor===Array?h[t]:Object.assign({},h),o=this._rotate(e,i),l=e.labelConfig&&e.labelConfig.rotate?e.labelConfig.rotate:void 0!==h.angle?h.angle:0,o=(l+=o,0!==o?[-1*a.x||0,-1*a.y||0]:[a.width/2,a.height/2]);_.push({__d3plus__:!0,data:e,height:a.height,l:t,id:this._id(e,i)+"_"+t,r:l,rotateAnchor:o,text:s[t],width:a.width,x:n+a.x,y:r+a.y})}}}}),this._labelClass.data(_).duration(this._duration).fontOpacity(this._nestWrapper(this._opacity)).pointerEvents("none").rotate(t=>(t.__d3plus__?t:t.data).r).rotateAnchor(t=>(t.__d3plus__?t:t.data).rotateAnchor).select(Pt.elem(`g.d3plus-${this._name}-text`,{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).node()).config(jt.bind(this)(this._labelConfig)).render()}
|
|
332
332
|
/**
|
|
333
333
|
@memberof Shape
|
|
334
334
|
@desc Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
@@ -338,9 +338,9 @@ this._group.selectAll(`g.d3plus-${this._name}-shape, g.d3plus-${this._name}-imag
|
|
|
338
338
|
// Makes the update state of the group selection accessible.
|
|
339
339
|
this._group=Pt.elem(`g.d3plus-${this._name}-group`,{parent:this._select});var n=this._update=Pt.elem(`g.d3plus-${this._name}-shape`,{parent:this._group,update:{opacity:this._active?this._activeOpacity:1}}).selectAll(".d3plus-"+this._name).data(i,e);
|
|
340
340
|
// Orders and transforms the updating Shapes.
|
|
341
|
-
n.order(),(this._duration?n.transition(this._transition):n).call(this._applyTransform.bind(this));var
|
|
341
|
+
n.order(),(this._duration?n.transition(this._transition):n).call(this._applyTransform.bind(this));var r=(this._enter=n.enter().append(this._tagName).attr("class",(t,i)=>`d3plus-Shape d3plus-${this._name} d3plus-id-`+H.strip(this._nestWrapper(this._id)(t,i))).call(this._applyTransform.bind(this)).attr("aria-label",this._ariaLabel).attr("role",this._role).attr("opacity",this._nestWrapper(this._opacity))).merge(n);let a=r.attr("shape-rendering",this._nestWrapper(this._shapeRendering));(a=this._duration?a.attr("pointer-events","none").transition(this._transition).transition().delay(100).attr("pointer-events",this._pointerEvents):a).attr("opacity",this._nestWrapper(this._opacity));
|
|
342
342
|
// Makes the exit state of the group selection accessible.
|
|
343
|
-
var n=this._exit=n.exit(),n=((this._duration?n.transition().delay(this._duration):n).remove(),this._renderImage(),this._renderLabels(),this._hoverGroup=Pt.elem(`g.d3plus-${this._name}-hover`,{parent:this._group}),this._activeGroup=Pt.elem(`g.d3plus-${this._name}-active`,{parent:this._group}),this._group.selectAll(".d3plus-HitArea").data(this._hitArea&&Object.keys(this._on).length?i:[],e)),o=(n.order().call(this._applyTransform.bind(this)),"Line"===this._name),l=(o&&(l=this._curve.bind(this)(this.config()),o)&&this._path.curve(Et["curve"+l.charAt(0).toUpperCase()+l.slice(1)]).defined(this._defined).x(this._x).y(this._y),n.enter().append(o?"path":"rect").attr("class",(t,i)=>"d3plus-HitArea d3plus-id-"+H.strip(this._nestWrapper(this._id)(t,i))).attr("fill","black").attr("stroke","black").attr("pointer-events","painted").attr("opacity",0).call(this._applyTransform.bind(this)));let _=this;o=n.merge(l).each(function(t){var i=_._data.indexOf(t),e=_._hitArea(t,i,_._aes(t,i));return!e||"Line"===_._name&&10<parseFloat(_._strokeWidth(t,i))?j.select(this).remove():j.select(this).call(Pt.attrize,e)});return n.exit().remove(),this._applyEvents(this._hitArea?o:
|
|
343
|
+
var n=this._exit=n.exit(),n=((this._duration?n.transition().delay(this._duration):n).remove(),this._renderImage(),this._renderLabels(),this._hoverGroup=Pt.elem(`g.d3plus-${this._name}-hover`,{parent:this._group}),this._activeGroup=Pt.elem(`g.d3plus-${this._name}-active`,{parent:this._group}),this._group.selectAll(".d3plus-HitArea").data(this._hitArea&&Object.keys(this._on).length?i:[],e)),o=(n.order().call(this._applyTransform.bind(this)),"Line"===this._name),l=(o&&(l=this._curve.bind(this)(this.config()),o)&&this._path.curve(Et["curve"+l.charAt(0).toUpperCase()+l.slice(1)]).defined(this._defined).x(this._x).y(this._y),n.enter().append(o?"path":"rect").attr("class",(t,i)=>"d3plus-HitArea d3plus-id-"+H.strip(this._nestWrapper(this._id)(t,i))).attr("fill","black").attr("stroke","black").attr("pointer-events","painted").attr("opacity",0).call(this._applyTransform.bind(this)));let _=this;o=n.merge(l).each(function(t){var i=_._data.indexOf(t),e=_._hitArea(t,i,_._aes(t,i));return!e||"Line"===_._name&&10<parseFloat(_._strokeWidth(t,i))?j.select(this).remove():j.select(this).call(Pt.attrize,e)});return n.exit().remove(),this._applyEvents(this._hitArea?o:r),setTimeout(()=>{this._active?this._renderActive():this._hover&&this._renderHover(),t&&t()},this._duration+100),this}
|
|
344
344
|
/**
|
|
345
345
|
@memberof Shape
|
|
346
346
|
@desc If *value* is specified, sets the highlight accessor to the specified function and returns the current class instance.
|
|
@@ -621,7 +621,7 @@ this._renderHover(),this):this._hover}
|
|
|
621
621
|
@memberof Shape
|
|
622
622
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
623
623
|
@private
|
|
624
|
-
*/constructor(t="g"){super(),this._activeOpacity=.25,this._activeStyle={stroke:(t,i)=>{let e=this._fill(t,i);return["transparent","none"].includes(e)&&(e=this._stroke(t,i)),n.color(e).darker(1)},"stroke-width":(t,i)=>3*(this._strokeWidth(t,i)||1)},this._ariaLabel=Ht(""),this._backgroundImage=Ht(!1),this._backgroundImageClass=new V,this._data=[],this._duration=600,this._fill=Ht("black"),this._fillOpacity=Ht(1),this._hoverOpacity=.5,this._hoverStyle={stroke:(t,i)=>{let e=this._fill(t,i);return["transparent","none"].includes(e)&&(e=this._stroke(t,i)),n.color(e).darker(.5)},"stroke-width":(t,i)=>2*(this._strokeWidth(t,i)||1)},this._id=(t,i)=>void 0!==t.id?t.id:i,this._label=Ht(!1),this._labelClass=new l,this._labelConfig={fontColor:(t,i)=>A.colorContrast(this._fill(t,i)),fontSize:12,padding:5},this._name="Shape",this._opacity=Ht(1),this._pointerEvents=Ht("visiblePainted"),this._role=Ht("presentation"),this._rotate=Ht(0),this._rx=Ht(0),this._ry=Ht(0),this._scale=Ht(1),this._shapeRendering=Ht("geometricPrecision"),this._stroke=(t,i)=>n.color(this._fill(t,i)).darker(1).formatHex(),this._strokeDasharray=Ht("0"),this._strokeLinecap=Ht("butt"),this._strokeOpacity=Ht(1),this._strokeWidth=Ht(0),this._tagName=t,this._textAnchor=Ht("start"),this._texture=Ht(!1),this._textureDefault={},this._textureDefs={},this._vectorEffect=Ht("non-scaling-stroke"),this._verticalAlign=Ht("top"),this._x=s("x",0),this._y=s("y",0)}}class Nt extends
|
|
624
|
+
*/constructor(t="g"){super(),this._activeOpacity=.25,this._activeStyle={stroke:(t,i)=>{let e=this._fill(t,i);return["transparent","none"].includes(e)&&(e=this._stroke(t,i)),n.color(e).darker(1)},"stroke-width":(t,i)=>3*(this._strokeWidth(t,i)||1)},this._ariaLabel=Ht(""),this._backgroundImage=Ht(!1),this._backgroundImageClass=new V,this._data=[],this._duration=600,this._fill=Ht("black"),this._fillOpacity=Ht(1),this._hoverOpacity=.5,this._hoverStyle={stroke:(t,i)=>{let e=this._fill(t,i);return["transparent","none"].includes(e)&&(e=this._stroke(t,i)),n.color(e).darker(.5)},"stroke-width":(t,i)=>2*(this._strokeWidth(t,i)||1)},this._id=(t,i)=>void 0!==t.id?t.id:i,this._label=Ht(!1),this._labelClass=new l,this._labelConfig={fontColor:(t,i)=>A.colorContrast(this._fill(t,i)),fontSize:12,padding:5},this._name="Shape",this._opacity=Ht(1),this._pointerEvents=Ht("visiblePainted"),this._role=Ht("presentation"),this._rotate=Ht(0),this._rx=Ht(0),this._ry=Ht(0),this._scale=Ht(1),this._shapeRendering=Ht("geometricPrecision"),this._stroke=(t,i)=>n.color(this._fill(t,i)).darker(1).formatHex(),this._strokeDasharray=Ht("0"),this._strokeLinecap=Ht("butt"),this._strokeOpacity=Ht(1),this._strokeWidth=Ht(0),this._tagName=t,this._textAnchor=Ht("start"),this._texture=Ht(!1),this._textureDefault={},this._textureDefs={},this._vectorEffect=Ht("non-scaling-stroke"),this._verticalAlign=Ht("top"),this._x=s("x",0),this._y=s("y",0)}}class Nt extends r{
|
|
625
625
|
/**
|
|
626
626
|
@memberof Area
|
|
627
627
|
@desc Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
@@ -693,7 +693,7 @@ this._renderHover(),this):this._hover}
|
|
|
693
693
|
@memberof Area
|
|
694
694
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
695
695
|
@private
|
|
696
|
-
*/constructor(){super(),this._curve=Ht("linear"),this._defined=()=>!0,this._labelBounds=(t,i,e)=>{e=E.largestRect(e.points);return e?{angle:e.angle,width:e.width,height:e.height,x:e.cx-e.width/2-this._x(t,i),y:e.cy-e.height/2-this._y(t,i)}:null},this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this._name="Area",this._x=s("x"),this._x0=s("x"),this._x1=null,this._y=Ht(0),this._y0=Ht(0),this._y1=s("y")}}class K extends
|
|
696
|
+
*/constructor(){super(),this._curve=Ht("linear"),this._defined=()=>!0,this._labelBounds=(t,i,e)=>{e=E.largestRect(e.points);return e?{angle:e.angle,width:e.width,height:e.height,x:e.cx-e.width/2-this._x(t,i),y:e.cy-e.height/2-this._y(t,i)}:null},this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this._name="Area",this._x=s("x"),this._x0=s("x"),this._x1=null,this._y=Ht(0),this._y0=Ht(0),this._y1=s("y")}}class K extends r{
|
|
697
697
|
/**
|
|
698
698
|
@memberof Bar
|
|
699
699
|
@desc Draws the bars.
|
|
@@ -789,7 +789,7 @@ this._renderHover(),this):this._hover}
|
|
|
789
789
|
@memberof Bar
|
|
790
790
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
791
791
|
@private
|
|
792
|
-
*/constructor(){super("rect"),this._name="Bar",this._height=Ht(10),this._labelBounds=(t,i,e)=>({width:e.width,height:e.height,x:null!==this._x1?this._getX(t,i):-e.width/2,y:null===this._x1?this._getY(t,i):-e.height/2}),this._width=Ht(10),this._x=s("x"),this._x0=s("x"),this._x1=null,this._y=Ht(0),this._y0=Ht(0),this._y1=s("y")}}class Rt extends
|
|
792
|
+
*/constructor(){super("rect"),this._name="Bar",this._height=Ht(10),this._labelBounds=(t,i,e)=>({width:e.width,height:e.height,x:null!==this._x1?this._getX(t,i):-e.width/2,y:null===this._x1?this._getY(t,i):-e.height/2}),this._width=Ht(10),this._x=s("x"),this._x0=s("x"),this._x1=null,this._y=Ht(0),this._y0=Ht(0),this._y1=s("y")}}class Rt extends r{
|
|
793
793
|
/**
|
|
794
794
|
@memberof Circle
|
|
795
795
|
@desc Provides the default positioning to the <rect> elements.
|
|
@@ -822,7 +822,7 @@ this._renderHover(),this):this._hover}
|
|
|
822
822
|
@memberof Circle
|
|
823
823
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
824
824
|
@private
|
|
825
|
-
*/constructor(){super("circle"),this._labelBounds=(t,i,e)=>({width:1.5*e.r,height:1.5*e.r,x:.75*-e.r,y:.75*-e.r}),this._labelConfig=Pt.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this._name="Circle",this._r=s("r")}}class Ft extends
|
|
825
|
+
*/constructor(){super("circle"),this._labelBounds=(t,i,e)=>({width:1.5*e.r,height:1.5*e.r,x:.75*-e.r,y:.75*-e.r}),this._labelConfig=Pt.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this._name="Circle",this._r=s("r")}}class Ft extends r{
|
|
826
826
|
/**
|
|
827
827
|
@memberof Rect
|
|
828
828
|
@desc Draws the rectangles.
|
|
@@ -866,7 +866,7 @@ this._renderHover(),this):this._hover}
|
|
|
866
866
|
@memberof Rect
|
|
867
867
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
868
868
|
@private
|
|
869
|
-
*/constructor(){super("rect"),this._height=s("height"),this._labelBounds=(t,i,e)=>({width:e.width,height:e.height,x:-e.width/2,y:-e.height/2}),this._name="Rect",this._width=s("width")}}class It extends
|
|
869
|
+
*/constructor(){super("rect"),this._height=s("height"),this._labelBounds=(t,i,e)=>({width:e.width,height:e.height,x:-e.width/2,y:-e.height/2}),this._name="Rect",this._width=s("width")}}class It extends r{
|
|
870
870
|
/**
|
|
871
871
|
@memberof Line
|
|
872
872
|
@desc Filters/manipulates the data array before binding each point to an SVG group.
|
|
@@ -878,12 +878,12 @@ this._renderHover(),this):this._hover}
|
|
|
878
878
|
@desc Draws the lines.
|
|
879
879
|
@param {Function} [*callback*]
|
|
880
880
|
@chainable
|
|
881
|
-
*/render(t){super.render(t);let
|
|
881
|
+
*/render(t){super.render(t);let r=this;
|
|
882
882
|
/**
|
|
883
883
|
@desc Calculates the stroke-dasharray used for animations
|
|
884
884
|
@param {Object} *d* data point
|
|
885
885
|
@private
|
|
886
|
-
*/function i(i){i.initialLength=this.getTotalLength();let e=
|
|
886
|
+
*/function i(i){i.initialLength=this.getTotalLength();let e=r._strokeDasharray(i.values[0],r._data.indexOf(i.values[0])).split(" ").map(Number);1===e.length&&0===e[0]?e=[i.initialLength]:1===e.length?e.push(e[0]):e.length%2&&(e=e.concat(e));var s=[];let h=0;for(;h<i.initialLength;)for(let t=0;t<e.length;t++){var n=e[t];if(h+=n,s.push(n),h>=i.initialLength)break}1<s.length&&s.length%2&&s.pop(),s[s.length-1]+=i.initialLength-Dt.sum(s),s.length%2==0&&s.push(0),i.initialStrokeArray=s.join(" ")}t=this._curve.bind(this)(this.config()),t=Et["curve"+t.charAt(0).toUpperCase()+t.slice(1)],this._path.curve(t).defined(this._defined).x(this._x).y(this._y),t=this._enter.append("path").attr("transform",t=>`translate(${-t.xR[0]-t.width/2}, ${-t.yR[0]-t.height/2})`).attr("d",t=>this._path(t.values)).call(this._applyStyle.bind(this));let e=this._update.select("path").attr("stroke-dasharray",t=>r._strokeDasharray(t.values[0],r._data.indexOf(t.values[0])));return this._duration?(t.each(i).attr("stroke-dasharray",t=>t.initialStrokeArray+" "+t.initialLength).attr("stroke-dashoffset",t=>t.initialLength).transition(this._transition).attr("stroke-dashoffset",0),e=e.transition(this._transition).attrTween("d",function(t){return u.interpolatePath(j.select(this).attr("d"),r._path(t.values))}),this._exit.selectAll("path").each(i).attr("stroke-dasharray",t=>t.initialStrokeArray+" "+t.initialLength).transition(this._transition).attr("stroke-dashoffset",t=>-t.initialLength)):e=e.attr("d",t=>r._path(t.values)),e.attr("transform",t=>`translate(${-t.xR[0]-t.width/2}, ${-t.yR[0]-t.height/2})`).call(this._applyStyle.bind(this)),this}
|
|
887
887
|
/**
|
|
888
888
|
@memberof Line
|
|
889
889
|
@desc Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
@@ -913,9 +913,9 @@ this._renderHover(),this):this._hover}
|
|
|
913
913
|
@desc Draws the whisker.
|
|
914
914
|
@param {Function} [*callback*]
|
|
915
915
|
@chainable
|
|
916
|
-
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node());let
|
|
916
|
+
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").style("display","block").node());let a=[];this._data.forEach((t,i)=>{var e=this._orient(t,i),s=this._x(t,i),h=this._y(t,i);let n=s,r=("left"===e?n-=this._length(t,i):"right"===e&&(n+=this._length(t,i)),h);"top"===e?r-=this._length(t,i):"bottom"===e&&(r+=this._length(t,i)),a.push({__d3plus__:!0,data:t,i:i,id:i,x:s,y:h}),a.push({__d3plus__:!0,data:t,i:i,id:i,x:n,y:r})}),
|
|
917
917
|
// Draw whisker line.
|
|
918
|
-
this._line=(new It).data(
|
|
918
|
+
this._line=(new It).data(a).select(Pt.elem("g.d3plus-Whisker",{parent:this._select}).node()).config(jt.bind(this)(this._lineConfig,"shape")).render(t);t=this._data.map((t,i)=>{var e={__d3plus__:!0};e.data=t,e.i=i,e.endpoint=this._endpoint(t,i),e.length=this._length(t,i),e.orient=this._orient(t,i);let s=this._x(t,i),h=("left"===e.orient?s-=e.length:"right"===e.orient&&(s+=e.length),this._y(t,i));return"top"===e.orient?h-=e.length:"bottom"===e.orient&&(h+=e.length),e.x=s,e.y=h,e});
|
|
919
919
|
// Draw whisker endpoint.
|
|
920
920
|
return this._whiskerEndpoint=[],Ot.nest().key(t=>t.endpoint).entries(t).forEach(t=>{var i=t.key;this._whiskerEndpoint.push((new U[i]).data(t.values).select(Pt.elem("g.d3plus-Whisker-Endpoint-"+i,{parent:this._select}).node()).config({height:t=>"top"===t.orient||"bottom"===t.orient?5:20,width:t=>"top"===t.orient||"bottom"===t.orient?20:5}).config(jt.bind(this)(this._endpointConfig,"shape",i)).render())}),this}
|
|
921
921
|
/**
|
|
@@ -1015,7 +1015,7 @@ this._box=(new Ft).data(t).x(t=>t.x).y(t=>t.y).select(Pt.elem("g.d3plus-Box",{pa
|
|
|
1015
1015
|
this._median=(new Ft).data(t).x(t=>"vertical"===t.orient?t.x:t.median).y(t=>"vertical"===t.orient?t.median:t.y).height(t=>"vertical"===t.orient?1:t.height).width(t=>"vertical"===t.orient?t.width:1).select(Pt.elem("g.d3plus-Box-Median",{parent:this._select}).node()).config(jt.bind(this)(this._medianConfig,"shape")).render();
|
|
1016
1016
|
// Draw 2 lines using Whisker class.
|
|
1017
1017
|
// Construct coordinates for whisker startpoints and push it to the whiskerData.
|
|
1018
|
-
let o=[];return t.forEach((t,i)=>{var e,s,h=t.x,n=t.y,
|
|
1018
|
+
let o=[];return t.forEach((t,i)=>{var e,s,h=t.x,n=t.y,r=t.first-t.lowerLimit,a=t.upperLimit-t.third;"vertical"===t.orient?(e=n-t.height/2,s=n+t.height/2,o.push({__d3plus__:!0,data:t,i:i,x:h,y:e,length:r,orient:"top"},{__d3plus__:!0,data:t,i:i,x:h,y:s,length:a,orient:"bottom"})):"horizontal"===t.orient&&(e=h+t.width/2,s=h-t.width/2,o.push({__d3plus__:!0,data:t,i:i,x:e,y:n,length:a,orient:"right"},{__d3plus__:!0,data:t,i:i,x:s,y:n,length:r,orient:"left"}))}),
|
|
1019
1019
|
// Draw whiskers.
|
|
1020
1020
|
this._whisker=(new X).data(o).select(Pt.elem("g.d3plus-Box-Whisker",{parent:this._select}).node()).config(jt.bind(this)(this._whiskerConfig,"shape")).render(),
|
|
1021
1021
|
// Draw outliers.
|
|
@@ -1120,7 +1120,7 @@ this._whiskerEndpoint=[],Ot.nest().key(t=>t.outlier).entries(n).forEach(t=>{var
|
|
|
1120
1120
|
@memberof Box
|
|
1121
1121
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from BaseClass.
|
|
1122
1122
|
@private
|
|
1123
|
-
*/constructor(){super(),this._medianConfig={fill:Ht("black")},this._orient=s("orient","vertical"),this._outlier=s("outlier","Circle"),this._outlierConfig={Circle:{r:s("r",5)},Rect:{height:(t,i)=>"vertical"===this._orient(t,i)?5:20,width:(t,i)=>"vertical"===this._orient(t,i)?20:5}},this._rectConfig={fill:Ht("white"),stroke:Ht("black"),strokeWidth:Ht(1)},this._rectWidth=Ht(50),this._whiskerConfig={},this._whiskerMode=["tukey","tukey"],this._x=s("x",250),this._y=s("y",250)}}class B extends
|
|
1123
|
+
*/constructor(){super(),this._medianConfig={fill:Ht("black")},this._orient=s("orient","vertical"),this._outlier=s("outlier","Circle"),this._outlierConfig={Circle:{r:s("r",5)},Rect:{height:(t,i)=>"vertical"===this._orient(t,i)?5:20,width:(t,i)=>"vertical"===this._orient(t,i)?20:5}},this._rectConfig={fill:Ht("white"),stroke:Ht("black"),strokeWidth:Ht(1)},this._rectWidth=Ht(50),this._whiskerConfig={},this._whiskerMode=["tukey","tukey"],this._x=s("x",250),this._y=s("y",250)}}class B extends r{
|
|
1124
1124
|
/**
|
|
1125
1125
|
@memberof Path
|
|
1126
1126
|
@desc Given a specific data point and index, returns the aesthetic properties of the shape.
|
|
@@ -1148,28 +1148,28 @@ this._whiskerEndpoint=[],Ot.nest().key(t=>t.outlier).entries(n).forEach(t=>{var
|
|
|
1148
1148
|
@memberof Path
|
|
1149
1149
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
1150
1150
|
@private
|
|
1151
|
-
*/constructor(){super("path"),this._d=s("path"),this._labelBounds=(t,i,e)=>{e=E.largestRect(e.points,{angle:this._labelConfig.rotate?this._labelConfig.rotate(t,i):0});return!!e&&{angle:e.angle,width:e.width,height:e.height,x:e.cx-e.width/2,y:e.cy-e.height/2}},this._name="Path",this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var Wt=Object.freeze({__proto__:null,Area:Nt,Bar:K,Box:Q,Circle:Rt,Image:V,Line:It,Path:B,Rect:Ft,Shape:
|
|
1151
|
+
*/constructor(){super("path"),this._d=s("path"),this._labelBounds=(t,i,e)=>{e=E.largestRect(e.points,{angle:this._labelConfig.rotate?this._labelConfig.rotate(t,i):0});return!!e&&{angle:e.angle,width:e.width,height:e.height,x:e.cx-e.width/2,y:e.cy-e.height/2}},this._name="Path",this._labelConfig=Object.assign(this._labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var Wt=Object.freeze({__proto__:null,Area:Nt,Bar:K,Box:Q,Circle:Rt,Image:V,Line:It,Path:B,Rect:Ft,Shape:r,Whisker:X});let Z=g.theme,R=t=>t<0||Object.is(t,-0),F=t=>Math.pow(10,Math.floor(Math.log10(Math.abs(t))))*Math.pow(-1,R(t)),W=t=>Math.pow(10,Math.ceil(Math.log10(Math.abs(t))))*Math.pow(-1,R(t)),tt=t=>{var i,e=""+t;return e.includes("e-")||"0"===e?0:(i=e.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/))?+(""+i[1]+(+i[2]+1)):(i=e.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/))?+(""+i[1]+ +i[2]):t};
|
|
1152
1152
|
/* catches for -0 and less */
|
|
1153
1153
|
/**
|
|
1154
1154
|
* Calculates ticks from a given scale (negative and/or positive)
|
|
1155
1155
|
* @param {scale} scale A d3-scale object
|
|
1156
1156
|
* @private
|
|
1157
|
-
*/function it(t,e=!1){let s=[];var h=t.copy(),n=("time"===this._scale&&this._data.length&&(t=(n=Dt.extent(this._data)).map(t),h.domain(n).range(t)),h.domain());let
|
|
1157
|
+
*/function it(t,e=!1){let s=[];var h=t.copy(),n=("time"===this._scale&&this._data.length&&(t=(n=Dt.extent(this._data)).map(t),h.domain(n).range(t)),h.domain());let r=n[1]<n[0];t=
|
|
1158
1158
|
/**
|
|
1159
1159
|
* Calculates ticks from a given scale (negative and/or positive)
|
|
1160
1160
|
* @param {scale} scale A d3-scale object
|
|
1161
1161
|
* @private
|
|
1162
|
-
*/function(t,i=!1){var e=$t.scaleLinear().domain([200,1200]).range([8,28]),t=t.range(),t=Math.abs(t[1]-t[0]);let s=Math.floor(e(t));return"time"===this._scale&&(s=this._data&&this._data.length?(e=Dt.extent(this._data),t=this._data.reduce((t,i,e,s)=>t=e&&(i=Math.abs(i-s[e-1]))<t?i:t,1/0),e=Math.round((e[1]-e[0])/t),Dt.min([s*(i?2:.5),e])):i?2*s:s/2),Math.floor(s)}.bind(this)(h,e);if(e||"log"!==this._scale){if(s=h.ticks(t),!e&&!["log","time"].includes(this._scale)&&1<s.length){let e=Math.abs(2*tt(s[1]-s[0]));s=s.filter(t=>{var t=Math.abs(t)%e,i=tt(t);return i!==t?!i||i===e:0==t})}}else{var e=n.map(t=>Math.log10(t)%1==0?t:(
|
|
1162
|
+
*/function(t,i=!1){var e=$t.scaleLinear().domain([200,1200]).range([8,28]),t=t.range(),t=Math.abs(t[1]-t[0]);let s=Math.floor(e(t));return"time"===this._scale&&(s=this._data&&this._data.length?(e=Dt.extent(this._data),t=this._data.reduce((t,i,e,s)=>t=e&&(i=Math.abs(i-s[e-1]))<t?i:t,1/0),e=Math.round((e[1]-e[0])/t),Dt.min([s*(i?2:.5),e])):i?2*s:s/2),Math.floor(s)}.bind(this)(h,e);if(e||"log"!==this._scale){if(s=h.ticks(t),!e&&!["log","time"].includes(this._scale)&&1<s.length){let e=Math.abs(2*tt(s[1]-s[0]));s=s.filter(t=>{var t=Math.abs(t)%e,i=tt(t);return i!==t?!i||i===e:0==t})}}else{var e=n.map(t=>Math.log10(t)%1==0?t:(r?W:F)(t)),a=e[1]<e[0],e=e.map(t=>(R(t)?-1:1)*([-1,1].includes(t)||Math.abs(t)<1?1:Math.log10(Math.abs(t))));let i=Math.ceil((Math.abs(e[1]-e[0])+1)/(.65*t));s=i<=1&&e[0]===e[1]||a!=r?h.ticks(t).filter(t=>+(""+t).replace("0.","")%2==0):Dt.range(e[0],e[1],e[1]<e[0]?-1:1).concat([e[1]]).filter(t=>Math.abs(t)%i==0).map(t=>+(""+(R(t)?-1:1)*(t?Math.pow(10,Math.abs(t)):0<Math.sign(1/t)?1:-1)).replace(/9+/g,"1"))}
|
|
1163
1163
|
// for time scale, if data array has been provided, filter out ticks that are not in the array
|
|
1164
1164
|
if("time"===this._scale&&this._data.length){let e=this._data.map(Number);s=s.filter(t=>{let i=+t;return e.find(t=>t>=i-936e5&&t<=936e5+i)})}
|
|
1165
1165
|
// forces min/max into ticks, if not present
|
|
1166
|
-
return this._d3ScaleNegative&&R(n[
|
|
1166
|
+
return this._d3ScaleNegative&&R(n[r?1:0])!==s.some(t=>R(t))||s.map(Number).includes(+n[0])||s.unshift(n[0]),this._d3ScaleNegative&&R(n[r?0:1])!==s.some(t=>R(t))||s.map(Number).includes(+n[1])||s.push(n[1]),s}class o extends h{
|
|
1167
1167
|
/**
|
|
1168
1168
|
@memberof Axis
|
|
1169
1169
|
@desc Sets positioning for the axis bar.
|
|
1170
1170
|
@param {D3Selection} *bar*
|
|
1171
1171
|
@private
|
|
1172
|
-
*/_barPosition(t){var{height:i,x:e,y:s,opposite:h}=this._position,h=this._margin[h],i=["top","left"].includes(this._orient)?this._outerBounds[s]+this._outerBounds[i]-h:this._outerBounds[s]+h,h="band"===this._scale?this._d3Scale.step()-this._d3Scale.bandwidth():"point"===this._scale?this._d3Scale.step()*this._d3Scale.padding():0,n="band"===this._scale?this._d3Scale.step():"point"===this._scale?this._d3Scale.step()*this._d3Scale.padding():0,
|
|
1172
|
+
*/_barPosition(t){var{height:i,x:e,y:s,opposite:h}=this._position,h=this._margin[h],i=["top","left"].includes(this._orient)?this._outerBounds[s]+this._outerBounds[i]-h:this._outerBounds[s]+h,h="band"===this._scale?this._d3Scale.step()-this._d3Scale.bandwidth():"point"===this._scale?this._d3Scale.step()*this._d3Scale.padding():0,n="band"===this._scale?this._d3Scale.step():"point"===this._scale?this._d3Scale.step()*this._d3Scale.padding():0,r=(this._d3ScaleNegative?this._d3ScaleNegative.domain():[]).concat(this._d3Scale?this._d3Scale.domain():[]).sort((t,i)=>t-i);t.call(Pt.attrize,this._barConfig).attr(e+"1",this._getPosition(r[0])-h).attr(e+"2",this._getPosition(r[r.length-1])+n).attr(s+"1",i).attr(s+"2",i)}
|
|
1173
1173
|
/**
|
|
1174
1174
|
@memberof Axis
|
|
1175
1175
|
@desc Returns the scale's domain, taking into account negative and positive log scales.
|
|
@@ -1205,7 +1205,7 @@ t.includes(-i)&&t.includes(i)&&t.splice(t.indexOf(-i),1)}return t}
|
|
|
1205
1205
|
@desc Sets positioning for the grid lines.
|
|
1206
1206
|
@param {D3Selection} *lines*
|
|
1207
1207
|
@private
|
|
1208
|
-
*/_gridPosition(t,i=!1){let{height:e,x:s,y:h,opposite:n}=this._position,
|
|
1208
|
+
*/_gridPosition(t,i=!1){let{height:e,x:s,y:h,opposite:n}=this._position,r=this._margin[n],a=["top","left"].includes(this._orient)?this._outerBounds[h]+this._outerBounds[e]-r:this._outerBounds[h]+r,o=i&&this._lastScale||this._getPosition.bind(this),l=["top","left"].includes(this._orient)?r:-r,_="band"===this._scale?this._d3Scale.bandwidth()/2:0,d=t=>o(t.id)+_;t.call(Pt.attrize,this._gridConfig).attr(s+"1",d).attr(s+"2",d).attr(h+"1",a).attr(h+"2",i?a:a+l)}
|
|
1209
1209
|
/**
|
|
1210
1210
|
@memberof Axis
|
|
1211
1211
|
@desc Renders the current Axis to the page. If a *callback* is specified, it will be called once the legend is done drawing.
|
|
@@ -1215,11 +1215,11 @@ t.includes(-i)&&t.includes(i)&&t.splice(t.indexOf(-i),1)}return t}
|
|
|
1215
1215
|
/**
|
|
1216
1216
|
* Creates an SVG element to contain the axis if none
|
|
1217
1217
|
* has been specified using the "select" method.
|
|
1218
|
-
*/void 0===this._select&&this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node());let n=this._timeLocale||$.locale[this._locale]||$.locale["en-US"],{width:i,height:_,x:d,y:g,horizontal:c,opposite:u}=(N.timeFormatDefaultLocale(n).format(),this._position),e="d3plus-Axis-clip-"+this._uuid,p=["top","left"].includes(this._orient),f=this._padding,s=this._select,m=[f,this["_"+i]-f],h=I.transition().duration(this._duration),
|
|
1218
|
+
*/void 0===this._select&&this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node());let n=this._timeLocale||$.locale[this._locale]||$.locale["en-US"],{width:i,height:_,x:d,y:g,horizontal:c,opposite:u}=(N.timeFormatDefaultLocale(n).format(),this._position),e="d3plus-Axis-clip-"+this._uuid,p=["top","left"].includes(this._orient),f=this._padding,s=this._select,m=[f,this["_"+i]-f],h=I.transition().duration(this._duration),r="Circle"===this._shape?this._shapeConfig.r:"Rect"===this._shape?this._shapeConfig[i]:this._shapeConfig.strokeWidth,y="function"!=typeof r?()=>r:r,x=this._margin={top:0,right:0,bottom:0,left:0},b,v,C,w=this._tickFormat||(t=>{var i,e,s,h;return isNaN(t)||["band","ordinal","point"].includes(this._scale)?t:"time"===this._scale?(h=(this._data.length?this._data:this._domain).map(Pt.date).sort((t,i)=>+t-+i),Tt.formatDate(t,h,N.timeFormat).replace(/^Q/g,n.quarter)):"linear"===this._scale&&"smallest"===this._tickSuffix?({separator:e,suffixes:s}=h="object"==typeof this._locale?this._locale:$.formatLocale[this._locale],s=1e3<=t?s[this._tickUnit+8]:"",i=t/Math.pow(10,3*this._tickUnit),""+Tt.formatAbbreviate(i,h,`,.${i.toString().length}r`)+e+s):(i=(h=C[1]<C[0])?C.length-1:0,e=h?0:C.length-1,s="inside"===this._rounding?C.indexOf(t)===i?this._roundingInsideMinPrefix:C.indexOf(t)===e?this._roundingInsideMaxPrefix:"":"",h="inside"===this._rounding?C.indexOf(t)===i?this._roundingInsideMinSuffix:C.indexOf(t)===e?this._roundingInsideMaxSuffix:"":"",""+s+Tt.formatAbbreviate(t,this._locale)+h)});
|
|
1219
1219
|
/**
|
|
1220
1220
|
* (Re)calculates the internal d3 scale
|
|
1221
1221
|
* @param {} newRange
|
|
1222
|
-
*/function
|
|
1222
|
+
*/function a(s=this._range){
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Calculates the internal "range" array to use, including
|
|
1225
1225
|
* fallbacks if not specified with the "range" method.
|
|
@@ -1240,13 +1240,13 @@ t.includes(-i)&&t.includes(i)&&t.splice(t.indexOf(-i),1)}return t}
|
|
|
1240
1240
|
/**
|
|
1241
1241
|
* Sets up the initial d3 scale, using this._domain and the
|
|
1242
1242
|
* previously defined range variable.
|
|
1243
|
-
*/var s="scale"+this._scale.charAt(0).toUpperCase()+this._scale.slice(1);let h=this._domain.slice();if(this._d3Scale=$t[s]().domain("time"===this._scale?h.map(Pt.date):h).range(v),"none"!==this._rounding&&(s=()=>{var t=t=>{if(e){if(!t)return 0;var i=(""+t).match(/0\.(0*)/);if(i)return+`0.${Array(i[1].length+1).fill(0).join("")}1`}return(""+Math.round(Math.abs(t))).length};let e=h.every(t=>Math.abs(t)<1);var t=[t(h[0]),t(h[1])].filter(Boolean).sort(),i=h.some(t=>R(t))&&h.some(t=>0<t),i=1===t.length?t[0]:1<t[0]&&t[0]===t[1]?t[0]-1:"outside"!==this._rounding&&i?Dt.max(t):t[0]+(t[1]-t[0])/2;let s=i<1?tt(i):+("1"+Array(Math.floor(tt(i))-1).fill(0).join(""));s>=Math.abs(h[1]-h[0])&&(s/=2);t=h[1]<h[0],i=[Math["outside"===this._rounding?t?"ceil":"floor":t?"floor":"ceil"](h[0]/s)*s,Math["outside"===this._rounding?t?"floor":"ceil":t?"ceil":"floor"](h[1]/s)*s];"log"===this._scale&&(0===i[0]&&(i[0]=h[0]),0===i[1])&&(i[1]=h[1]),this._d3Scale.domain(i.map(tt))},"linear"===this._scale?s.bind(this)():"log"===this._scale&&(
|
|
1243
|
+
*/var s="scale"+this._scale.charAt(0).toUpperCase()+this._scale.slice(1);let h=this._domain.slice();if(this._d3Scale=$t[s]().domain("time"===this._scale?h.map(Pt.date):h).range(v),"none"!==this._rounding&&(s=()=>{var t=t=>{if(e){if(!t)return 0;var i=(""+t).match(/0\.(0*)/);if(i)return+`0.${Array(i[1].length+1).fill(0).join("")}1`}return(""+Math.round(Math.abs(t))).length};let e=h.every(t=>Math.abs(t)<1);var t=[t(h[0]),t(h[1])].filter(Boolean).sort(),i=h.some(t=>R(t))&&h.some(t=>0<t),i=1===t.length?t[0]:1<t[0]&&t[0]===t[1]?t[0]-1:"outside"!==this._rounding&&i?Dt.max(t):t[0]+(t[1]-t[0])/2;let s=i<1?tt(i):+("1"+Array(Math.floor(tt(i))-1).fill(0).join(""));s>=Math.abs(h[1]-h[0])&&(s/=2);t=h[1]<h[0],i=[Math["outside"===this._rounding?t?"ceil":"floor":t?"floor":"ceil"](h[0]/s)*s,Math["outside"===this._rounding?t?"floor":"ceil":t?"ceil":"floor"](h[1]/s)*s];"log"===this._scale&&(0===i[0]&&(i[0]=h[0]),0===i[1])&&(i[1]=h[1]),this._d3Scale.domain(i.map(tt))},"linear"===this._scale?s.bind(this)():"log"===this._scale&&(a=[],r=h[1]<h[0],a[0]=("outside"===this._rounding?R(h[0])?r?F:W:r?W:F:R(h[0])?r?W:F:r?F:W)(h[0]),a[1]=("inside"===this._rounding?R(h[1])?r?F:W:r?W:F:R(h[1])?r?W:F:r?F:W)(h[1]),n=a[1]<a[0],a[0]!==a[1]&&a.some(t=>10<Math.abs(t))&&n==r?this._d3Scale.domain(a):s.bind(this)())),this._d3Scale.padding&&this._d3Scale.padding(this._scalePadding),this._d3Scale.paddingInner&&this._d3Scale.paddingInner(this._paddingInner),this._d3Scale.paddingOuter&&this._d3Scale.paddingOuter(this._paddingOuter)
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Constructs a separate "negative only" scale for logarithmic
|
|
1246
1246
|
* domains, as they cannot pass zero.
|
|
1247
|
-
*/,this._d3ScaleNegative=null,"log"===this._scale){var n=this._d3Scale.domain();0===n[0]?(
|
|
1247
|
+
*/,this._d3ScaleNegative=null,"log"===this._scale){var n=this._d3Scale.domain();0===n[0]?(r=Dt.min([Dt.min(this._data),Math.abs(n[1])]),n[0]=0===r||1===r?1e-6:r<=1?F(r):1,R(n[1])&&(n[0]*=-1)):0===n[n.length-1]&&(a=Dt.min([Dt.min(this._data),Math.abs(n[0])]),n[n.length-1]=0===a||1===a?1e-6:a<=1?F(a):1,R(n[0]))&&(n[n.length-1]*=-1);let e=this._d3Scale.range();
|
|
1248
1248
|
// all negatives
|
|
1249
|
-
if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n).range(e),this._d3Scale=null;else if(0<n[0]&&0<n[n.length-1])this._d3Scale.domain(n).range(e);else{var s=n.map(t=>Math.log10(Math.abs(t))).map(t=>t||-1e-6),
|
|
1249
|
+
if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n).range(e),this._d3Scale=null;else if(0<n[0]&&0<n[n.length-1])this._d3Scale.domain(n).range(e);else{var s=n.map(t=>Math.log10(Math.abs(t))).map(t=>t||-1e-6),r=s[0]/Dt.sum(s)*(e[1]-e[0]);let t=Dt.min([Dt.min(this._data.filter(t=>0<=t)),Math.abs(n[1])]),i=(1===t&&(t=1e-6),Dt.min([Dt.min(this._data.filter(R)),Math.abs(n[0])]));1===i&&(i=1e-6);var a=0===t?1e-6:t<=1?F(t):1,s=0===i?-1e-6:i<=1?F(i):1,a=Dt.min([Math.abs(a),Math.abs(s)]);this._d3ScaleNegative=this._d3Scale.copy(),(R(n[0])?this._d3Scale:this._d3ScaleNegative).domain([R(n[0])?a:-a,n[1]]).range([e[0]+r,e[1]]),(R(n[0])?this._d3ScaleNegative:this._d3Scale).domain([n[0],R(n[0])?-a:a]).range([e[0],e[0]+r])}}
|
|
1250
1250
|
/**
|
|
1251
1251
|
* Determines the of values array to use
|
|
1252
1252
|
* for the "ticks" and the "labels"
|
|
@@ -1256,24 +1256,24 @@ if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n
|
|
|
1256
1256
|
*/if(C=(this._ticks?"time"===this._scale?this._ticks.map(Pt.date):this._ticks:(this._d3Scale||this._d3ScaleNegative).ticks?this._getTicks():this._domain).slice(),b=(this._labels?"time"===this._scale?this._labels.map(Pt.date):this._labels:(this._d3Scale||this._d3ScaleNegative).ticks?this._getLabels():C).slice(),"time"===this._scale&&(C=C.map(Number),b=b.map(Number)),C=C.sort((t,i)=>this._getPosition(t)-this._getPosition(i)),b=b.sort((t,i)=>this._getPosition(t)-this._getPosition(i)),"linear"===this._scale&&"smallest"===this._tickSuffix){s=b.filter(t=>1e3<=t);if(0<s.length){var o=Math.min(...s);let t=1;for(;t&&t<7;){if(!(1<=o/Math.pow(10,3*t)))break;this._tickUnit=t,t+=1}}}
|
|
1257
1257
|
/**
|
|
1258
1258
|
* Removes ticks when they overlap other ticks.
|
|
1259
|
-
*/let l=[];(this._availableTicks=C).forEach((t,i)=>{let e=y({id:t,tick:!0},i);"Circle"===this._shape&&(e*=2);i=this._getPosition(t);!l.length||Math.abs(E.closest(i,l)-i)>2*e?l.push(i):l.push(!1)}),C=C.filter((t,i)=>!1!==l[i]),this._visibleTicks=C}
|
|
1259
|
+
*/let l=[];(this._availableTicks=C).forEach((t,i)=>{let e=y({id:t,tick:!0},i);"Circle"===this._shape&&(e*=2);i=this._getPosition(t);!l.length||Math.abs(E.closest(i,l)-i)>2*e?l.push(i):l.push(!1)}),C=C.filter((t,i)=>!1!==l[i]),this._visibleTicks=C}a.bind(this)(),
|
|
1260
1260
|
/**
|
|
1261
1261
|
* Pre-calculates the size of the title, if defined, in order
|
|
1262
1262
|
* to adjust the internal margins.
|
|
1263
|
-
*/this._title&&({fontFamily:A,fontSize:M,lineHeight:z}=this._titleConfig,M=(A=H.textWrap().fontFamily("function"==typeof A?A():A).fontSize("function"==typeof M?M():M).lineHeight("function"==typeof z?z():z).width(v[v.length-1]-v[0]-2*f).height(this["_"+_]-this._tickSize-2*f))(this._title).lines.length,x[this._orient]=M*A.lineHeight()+f);let
|
|
1263
|
+
*/this._title&&({fontFamily:A,fontSize:M,lineHeight:z}=this._titleConfig,M=(A=H.textWrap().fontFamily("function"==typeof A?A():A).fontSize("function"==typeof M?M():M).lineHeight("function"==typeof z?z():z).width(v[v.length-1]-v[0]-2*f).height(this["_"+_]-this._tickSize-2*f))(this._title).lines.length,x[this._orient]=M*A.lineHeight()+f);let S="Circle"===this._shape?"function"==typeof this._shapeConfig.r?this._shapeConfig.r({tick:!0}):this._shapeConfig.r:"Rect"===this._shape?"function"==typeof this._shapeConfig[_]?this._shapeConfig[_]({tick:!0}):this._shapeConfig[_]:this._tickSize,o=y({tick:!0});"function"==typeof S&&(S=Dt.max(C.map(S))),"Rect"===this._shape&&(S/=2),"function"==typeof o&&(o=Dt.max(C.map(o))),"Circle"!==this._shape&&(o/=2)
|
|
1264
1264
|
/**
|
|
1265
1265
|
* Calculates the text wrapping and size of a given textData object.
|
|
1266
1266
|
* @param {Object} datum
|
|
1267
|
-
*/;let
|
|
1267
|
+
*/;let k=[];function l(t=1){let r=this._shapeConfig.labelConfig.fontSize,a=this._shapeConfig.labelConfig.fontFamily||H.fontFamily,o=this._shapeConfig.labelConfig.padding,e=(
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Calculates the space each label would take up, given
|
|
1270
1270
|
* the provided this._space size.
|
|
1271
|
-
*/
|
|
1272
|
-
/** Calculates label offsets */.bind(this)(t);return Object.assign(i,t)})).slice().reverse();
|
|
1271
|
+
*/k=b.map((t,i)=>{var e="function"==typeof a?a(t,i):a,s="function"==typeof o?o(t,i):o,h="function"==typeof r?r(t,i):r,n=this._getPosition(t);return{d:t,i:i,fF:e,fP:s,fS:h,lineHeight:this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):1.4*h,position:n,rotate:this._labelRotation}}),"band"===this._scale?this._d3Scale.bandwidth():k.reduce((t,i,e)=>{var i=i.position,s=e?i-(i-k[e-1].position):1===k.length?m[0]:i-(k[e+1].position-i),s=Math.abs(i-s),e=e==k.length-1?1===k.length?m[1]:i+(i-k[e-1].position):i-(i-k[e+1].position),i=Math.abs(i-e),e="point"===this._scale?1:2;return Dt.max([Dt.max([s,i])*e,t])},0)),l=(k=k.map(t=>{t.space=e-2*t.fP;var i=function(t){var{d:t,i,fF:e,fP:s,fS:h,rotate:n,space:r}=t,a=n?"width":"height",n=n?"height":"width",o=Dt.min([this._maxSize,this._width]),l=Dt.min([this._maxSize,this._height]);return(e=H.textWrap().fontFamily(e).fontSize(h).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):void 0))[n](c?r:o-S-f-this._margin.left-this._margin.right),e[a](c?l-S-f-this._margin.top-this._margin.bottom:r),(h=e(w(t))).lines=h.lines.filter(t=>""!==t),h.width=h.lines.length?Math.ceil(Dt.max(h.widths)):0,h.height=h.lines.length?Math.ceil(h.lines.length*e.lineHeight())+s:0,h}
|
|
1272
|
+
/** Calculates label offsets */.bind(this)(t);return Object.assign(i,t)})).slice().reverse();k.forEach(t=>{let{fP:i,i:e,position:s}=t;var h=c?"width":"height";let n=!!e&&l.find(t=>t.i<e&&!t.truncated);if(e===k.length-1)for(;n&&s-t[h]/2-i<n.position+n[h]/2;)n.truncated=!0,n=l.find(t=>t.i<e&&!t.truncated);t.truncated=!!n&&s-t[h]/2-i<n.position+n[h]/2}),1<t&&function(h=[]){let n=0;h.forEach(t=>{var i=h[t.i-1],e=t.rotate&&c||!t.rotate&&!c?"width":"height",s=t.rotate&&c||!t.rotate&&!c?"height":"width";i?i.position+i[s]/2>t.position-t[s]/2&&(n=n?(t.offset=i[e],0):1):n=1})}.bind(this)(k)}l.bind(this)();var z=this._labelOffset&&k.some(t=>t.truncated),M=(z&&l.bind(this)(2)
|
|
1273
1273
|
/**
|
|
1274
1274
|
* "spillover" will contain the pixel spillover of the first and last label,
|
|
1275
1275
|
* and then adjust the scale range accordingly.
|
|
1276
|
-
*/,[0,1].map(t=>{var i,e,s,h=
|
|
1276
|
+
*/,[0,1].map(t=>{var i,e,s,h=k[t?k.length-1:0];return!h||({height:h,position:i,rotate:s,width:e}=h,t=t?m[1]:m[0],s=(s||!c?h:e)/2,Math.abs(i-t)>=s)?0:Math.abs(s-(i-t))})),[A,B]=v,M=[A+M[0],B-M[1]];this._range&&(void 0!==this._range[0]&&(M[0]=this._range[0]),void 0!==this._range[this._range.length-1])&&(M[1]=this._range[this._range.length-1]),M[0]===A&&M[1]===B||(a.bind(this)(M),l.bind(this)(z?2:1));let P=Dt.max(k,t=>t.height)||0,D=(this._labelRotation=c&&void 0===this._labelRotation?k.some(t=>{var{i:t,height:i,position:e,truncated:s}=t,h=k[t-1];return s||t&&h.position+h.height/2>e-i/2}):this._labelRotation,this._labelOffset?Dt.max(k,t=>t.offset||0):0);k.forEach(t=>t.offset=t.offset?D:0);A="Line"===this._shape?0:S;let O=this._outerBounds={[_]:(Dt.max(k,t=>Math.ceil(t[t.rotate||!c?"width":"height"]+t.offset))||0)+(k.length?f:0),[i]:m[m.length-1]-m[0],[d]:m[0]};O[_]=Dt.max([this._minSize,O[_]]),x[this._orient]+=S,x[u]=void 0!==this._gridSize?Dt.max([this._gridSize,A]):this["_"+_]-x[this._orient]-O[_]-f,O[_]+=x[u]+x[this._orient],O[g]="start"===this._align?this._padding:"end"===this._align?this["_"+_]-O[_]-this._padding:this["_"+_]/2-O[_]/2;B=Pt.elem("g#d3plus-Axis-"+this._uuid,{parent:s}),this._group=B,M=Pt.elem("g.grid",{parent:B}).selectAll("line").data((0!==this._gridSize?this._grid||"log"===this._scale&&!this._gridLog?b:C:[]).map(t=>({id:t})),t=>t.id),M.exit().transition(h).attr("opacity",0).call(this._gridPosition.bind(this)).remove(),M.enter().append("line").attr("opacity",0).attr("clip-path",`url(#${e})`).call(this._gridPosition.bind(this),!0).merge(M).transition(h).attr("opacity",1).call(this._gridPosition.bind(this)),z=b.filter((t,i)=>k[i].lines.length&&!C.includes(t));let L=k.some(t=>t.rotate),T=C.concat(z).map(i=>{var t=k.find(t=>t.d===i),e=this._getPosition(i),s=t?t.space:0,h=t?t.lines.length:1,n=t?t.lineHeight:1,r=t?t.fP:0,a=t&&this._labelOffset?t.offset:0,o=c?s:O.width-x[this._position.opposite]-S-x[this._orient]+f,l=x[u],a=(S+a)*(p?-1:1),l=p?O[g]+O[_]-l:O[g]+l;return{id:i,labelBounds:L&&t?{x:-t.width/2+t.fS/4,y:"bottom"===this._orient?a+(t.width-n*h)/2+r:2*a-(t.width+n*h)/2+r,width:t.width,height:t.height}:{x:c?-s/2:"left"===this._orient?-o-f+a:a+f,y:c?"bottom"===this._orient?a+r:a-P-r:-s/2,width:c?s:o,height:c?P:s},rotate:!!t&&t.rotate,size:b.includes(i)||"log"===this._scale&&Math.log10(Math.abs(i))%1==0?a:C.includes(i)?Math.ceil(a/2):this._data.find(t=>+t===i)?Math.ceil(a/4):0,text:!((t||{}).truncated||!b.includes(i))&&w(i),tick:C.includes(i),[d]:e+("band"===this._scale?this._d3Scale.bandwidth()/2:0),[g]:l}});"Line"===this._shape&&(T=T.concat(T.map(t=>{var i=Object.assign({},t);return i[g]+=t.size,i}))),(new Wt[this._shape]).data(T).duration(this._duration).labelConfig({ellipsis:t=>t&&t.length?t+"...":"",rotate:t=>t.rotate?-90:0}).select(Pt.elem("g.ticks",{parent:B}).node()).config(jt.bind(this)(this._shapeConfig)).labelConfig({padding:0}).render();A=B.selectAll("line.bar").data([null]);return A.enter().append("line").attr("class","bar").attr("opacity",0).call(this._barPosition.bind(this)).merge(A).transition(h).attr("opacity",1).call(this._barPosition.bind(this)),this._titleClass.data(this._title?[{text:this._title}]:[]).duration(this._duration).height(x[this._orient]).rotate("left"===this._orient?-90:"right"===this._orient?90:0).select(Pt.elem("g.d3plus-Axis-title",{parent:B}).node()).text(t=>t.text).verticalAlign("middle").width(v[v.length-1]-v[0]).x(c?v[0]:"left"===this._orient?O.x+x.left/2-(v[v.length-1]-v[0])/2:O.x+O.width-x.right/2-(v[v.length-1]-v[0])/2).y(c?"bottom"===this._orient?O.y+O.height-x.bottom:O.y:v[0]+(v[v.length-1]-v[0])/2-x[this._orient]/2).config(jt.bind(this)(this._titleConfig)).render(),this._lastScale=this._getPosition.bind(this),t&&setTimeout(t,this._duration+100),this}
|
|
1277
1277
|
/**
|
|
1278
1278
|
@memberof Axis
|
|
1279
1279
|
@desc If *value* is specified, sets the horizontal alignment to the specified value and returns the current class instance.
|
|
@@ -1532,7 +1532,7 @@ if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n
|
|
|
1532
1532
|
@memberof AxisTop
|
|
1533
1533
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
|
|
1534
1534
|
@private
|
|
1535
|
-
*/constructor(){super(),this.orient("top")}}class
|
|
1535
|
+
*/constructor(){super(),this.orient("top")}}class rt extends h{_fetchConfig(t,i,e){var s=(void 0!==this._shapeConfig[t]?this._shapeConfig:this._shapeConfig.labelConfig)[t];return s||"lineHeight"!==t?"function"==typeof s?s(i,e):s:1.4*this._fetchConfig("fontSize",i,e)}_rowHeight(t){return Dt.max(t.map(t=>t.height).concat(t.map(t=>t.shapeHeight)))+this._padding}_rowWidth(e){return Dt.sum(e.map((t,i)=>{i=this._padding*(i===e.length-1?0:t.width?2:1);return t.shapeWidth+t.width+i}))}
|
|
1536
1536
|
/**
|
|
1537
1537
|
@memberof Legend
|
|
1538
1538
|
@desc Renders the current Legend to the page. If a *callback* is specified, it will be called once the legend is done drawing.
|
|
@@ -1542,9 +1542,9 @@ if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n
|
|
|
1542
1542
|
// Legend Container <g> Groups
|
|
1543
1543
|
this._group=Pt.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=Pt.elem("g.d3plus-Legend-title",{parent:this._group}),this._shapeGroup=Pt.elem("g.d3plus-Legend-shape",{parent:this._group});let l=this._height;if(this._titleHeight=0,this._titleWidth=0,this._title){var i=this._titleConfig.fontFamily||this._titleClass.fontFamily()(),e=this._titleConfig.fontSize||this._titleClass.fontSize()();let t=this._titleConfig.lineHeight||this._titleClass.lineHeight();t=t?t():1.4*e;i=H.textWrap().fontFamily(i).fontSize(e).lineHeight(t).width(this._width).height(this._height)(this._title);this._titleHeight=t+i.lines.length+this._padding,this._titleWidth=Dt.max(i.widths),l-=this._titleHeight}
|
|
1544
1544
|
// Calculate Text Sizes
|
|
1545
|
-
this._lineData=this._data.map((s,h)=>{var n=this._label(s,h),
|
|
1545
|
+
this._lineData=this._data.map((s,h)=>{var n=this._label(s,h),r=this._shape(s,h),a=this._fetchConfig("r",s,h);let o={data:s,i:h,id:this._id(s,h),shape:r,shapeR:a,shapeWidth:"Circle"===r?2*a:this._fetchConfig("width",s,h),shapeHeight:"Circle"===r?2*a:this._fetchConfig("height",s,h),y:0};if(n){let i=this._fetchConfig("fontFamily",s,h),t=this._fetchConfig("lineHeight",s,h),e=this._fetchConfig("fontSize",s,h);r=l-(this._data.length+1)*this._padding,a=this._width,s=H.textWrap().fontFamily(i).fontSize(e).lineHeight(t).width(a).height(r)(n);(o=Object.assign(o,s)).width=Math.ceil(Dt.max(o.lines.map(t=>Pt.textWidth(t,{"font-family":i,"font-size":e}))))+10,o.height=Math.ceil(o.lines.length*(t+1)),o.og={height:o.height,width:o.width},o.f=i,o.s=e,o.lh=t}else o.sentence=!1,o.words=[],o.height=0,o.width=0;return o});let s,o=this._width-2*this._padding;if(s=this._rowWidth(this._lineData),"column"===this._direction||s>o){let r=1,a=[],t=Dt.max(this._lineData.map(t=>t.words.length));if(this._wrapLines=function(){if(!(++r>t)){var s=1===r?this._lineData.slice():this._lineData.filter(t=>t.width+t.shapeWidth+this._padding*(t.width?2:1)>o&&t.words.length>=r).sort((t,i)=>i.sentence.length-t.sentence.length);if(s.length&&l>s[0].height*r){let e=!1;for(let t=0;t<s.length;t++){let i=s[t];var h=i.og.height*r,n=i.og.width*(1/r*1.5),n=H.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(n).height(h)(i.sentence);if(n.truncated){e=!0;break}i.width=Math.ceil(Dt.max(n.lines.map(t=>Pt.textWidth(t,{"font-family":i.f,"font-size":i.s}))))+i.s,i.height=n.lines.length*(i.lh+1)}e||this._wrapRows()}else a=[]}},this._wrapRows=function(){a=[];let i=1,e=0;for(let t=0;t<this._lineData.length;t++){var s=this._lineData[t],h=s.width+this._padding*(s.width?2:1)+s.shapeWidth;if(Dt.sum(a.map(t=>Dt.max(t,t=>Dt.max([t.height,t.shapeHeight]))))>l){a=[];break}if(h>o){a=[],this._wrapLines();break}e+h<o?e+=h:"column"!==this._direction&&(e=h,i++),a[i-1]||(a[i-1]=[]),a[i-1].push(s),"column"===this._direction&&(e=0,i++)}},this._wrapRows(),!a.length||Dt.sum(a,this._rowHeight.bind(this))+this._padding>l){s=Dt.sum(this._lineData.map(t=>t.shapeWidth+this._padding))-this._padding;for(let t=0;t<this._lineData.length;t++)this._lineData[t].width=0,this._lineData[t].height=0;this._wrapRows()}a.length&&Dt.sum(a,this._rowHeight.bind(this))+this._padding<l&&(a.forEach((t,i)=>{t.forEach(t=>{i&&(t.y=Dt.sum(a.slice(0,i),this._rowHeight.bind(this)))})}),s=Dt.max(a,this._rowWidth.bind(this)))}e=Dt.max(this._lineData,(t,i)=>Dt.max([t.height,this._fetchConfig("height",t.data,i)])+t.y)+this._titleHeight,i=Dt.max([s,this._titleWidth]);this._outerBounds.width=i,this._outerBounds.height=e;let h=this._padding,n=this._padding,r=("center"===this._align?h=(this._width-i)/2:"right"===this._align&&(h=this._width-this._padding-i),"middle"===this._verticalAlign?n=(this._height-e)/2:"bottom"===this._verticalAlign&&(n=this._height-this._padding-e),this._outerBounds.x=h,this._outerBounds.y=n,this._titleClass.data(this._title?[{text:this._title}]:[]).duration(this._duration).select(this._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[this._align]).width(this._width-2*this._padding).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render(),this._shapes=[],jt.bind(this)(this._shapeConfig,"legend")),a={id:t=>t.id,label:t=>t.label,lineHeight:t=>t.lH},_=this._data.map((t,i)=>({__d3plus__:!0,data:t,i:i,id:this._id(t,i),label:!!this._lineData[i].width&&this._label(t,i),lH:this._fetchConfig("lineHeight",t,i),shape:this._shape(t,i)}));
|
|
1546
1546
|
// Legend Shapes
|
|
1547
|
-
return this._shapes=[],["Circle","Rect"].forEach(i=>{this._shapes.push((new Wt[i]).parent(this).data(_.filter(t=>t.shape===i)).duration(this._duration).labelConfig({padding:0}).select(this._shapeGroup.node()).verticalAlign("top").config(Pt.assign({},a
|
|
1547
|
+
return this._shapes=[],["Circle","Rect"].forEach(i=>{this._shapes.push((new Wt[i]).parent(this).data(_.filter(t=>t.shape===i)).duration(this._duration).labelConfig({padding:0}).select(this._shapeGroup.node()).verticalAlign("top").config(Pt.assign({},r,a)).render())}),t&&setTimeout(t,this._duration+100),this}
|
|
1548
1548
|
/**
|
|
1549
1549
|
@memberof Legend
|
|
1550
1550
|
@desc If *value* is specified, sets the active method for all shapes to the specified function and returns the current class instance. If *value* is not specified, returns the current active method.
|
|
@@ -1661,15 +1661,15 @@ return this._shapes=[],["Circle","Rect"].forEach(i=>{this._shapes.push((new Wt[i
|
|
|
1661
1661
|
@memberof Legend
|
|
1662
1662
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
1663
1663
|
@private
|
|
1664
|
-
*/constructor(){super(),this._titleClass=new l,this._align="center",this._data=[],this._direction="row",this._duration=600,this._height=200,this._id=s("id"),this._label=s("id"),this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._padding=5,this._shape=Ht("Rect"),this._shapes=[],this._shapeConfig={fill:s("color"),height:Ht(12),hitArea:(t,i)=>{var i=this._lineData[i],e=Dt.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:e,x:-i.shapeWidth/2,y:-e/2}},labelBounds:(t,i)=>{i=this._lineData[i];let e=i.shapeWidth/2;"Circle"===i.shape&&(e-=i.shapeR/2);var s=Dt.max([i.shapeHeight,i.height]),h=this._rtl?i.shapeWidth+i.width+2*this._padding:0;return{width:i.width,height:s,x:e+5-h,y:-s/2}},labelConfig:{fontColor:Ht(A.colorDefaults.dark),fontFamily:this._titleClass.fontFamily(),fontResize:!1,fontSize:Ht(10),verticalAlign:"middle"},opacity:1,r:Ht(6),width:Ht(12),x:(t,i)=>{var e=this._lineData[i];let s=e.y;var h="left"===this._align||"right"===this._align&&"column"===this._direction?0:"center"===this._align?(this._outerBounds.width-this._rowWidth(this._lineData.filter(t=>s===t.y)))/2:this._outerBounds.width-this._rowWidth(this._lineData.filter(t=>s===t.y)),i=this._lineData.slice(0,i).filter(t=>s===t.y),n=this._rtl?e.width+this._padding:0;return this._rowWidth(i)+this._padding*(i.length?e.sentence?2:1:0)+this._outerBounds.x+e.shapeWidth/2+h+n},y:(t,i)=>{let e=this._lineData[i];return e.y+this._titleHeight+this._outerBounds.y+Dt.max(this._lineData.filter(t=>e.y===t.y).map(t=>t.height).concat(this._data.map((t,i)=>this._fetchConfig("height",t,i))))/2}},this._titleConfig={fontSize:12},this._verticalAlign="middle",this._width=400}}class
|
|
1664
|
+
*/constructor(){super(),this._titleClass=new l,this._align="center",this._data=[],this._direction="row",this._duration=600,this._height=200,this._id=s("id"),this._label=s("id"),this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._padding=5,this._shape=Ht("Rect"),this._shapes=[],this._shapeConfig={fill:s("color"),height:Ht(12),hitArea:(t,i)=>{var i=this._lineData[i],e=Dt.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:e,x:-i.shapeWidth/2,y:-e/2}},labelBounds:(t,i)=>{i=this._lineData[i];let e=i.shapeWidth/2;"Circle"===i.shape&&(e-=i.shapeR/2);var s=Dt.max([i.shapeHeight,i.height]),h=this._rtl?i.shapeWidth+i.width+2*this._padding:0;return{width:i.width,height:s,x:e+5-h,y:-s/2}},labelConfig:{fontColor:Ht(A.colorDefaults.dark),fontFamily:this._titleClass.fontFamily(),fontResize:!1,fontSize:Ht(10),verticalAlign:"middle"},opacity:1,r:Ht(6),width:Ht(12),x:(t,i)=>{var e=this._lineData[i];let s=e.y;var h="left"===this._align||"right"===this._align&&"column"===this._direction?0:"center"===this._align?(this._outerBounds.width-this._rowWidth(this._lineData.filter(t=>s===t.y)))/2:this._outerBounds.width-this._rowWidth(this._lineData.filter(t=>s===t.y)),i=this._lineData.slice(0,i).filter(t=>s===t.y),n=this._rtl?e.width+this._padding:0;return this._rowWidth(i)+this._padding*(i.length?e.sentence?2:1:0)+this._outerBounds.x+e.shapeWidth/2+h+n},y:(t,i)=>{let e=this._lineData[i];return e.y+this._titleHeight+this._outerBounds.y+Dt.max(this._lineData.filter(t=>e.y===t.y).map(t=>t.height).concat(this._data.map((t,i)=>this._fetchConfig("height",t,i))))/2}},this._titleConfig={fontSize:12},this._verticalAlign="middle",this._width=400}}class at extends h{
|
|
1665
1665
|
/**
|
|
1666
1666
|
@memberof ColorScale
|
|
1667
1667
|
@desc Renders the current ColorScale to the page. If a *callback* is specified, it will be called once the ColorScale is done drawing.
|
|
1668
1668
|
@param {Function} [*callback* = undefined]
|
|
1669
1669
|
@chainable
|
|
1670
|
-
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node());var
|
|
1670
|
+
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node());var a=["bottom","top"].includes(this._orient),o=a?"height":"width",l=a?"width":"height",_=a?"x":"y",d=a?"y":"x";
|
|
1671
1671
|
// Shape <g> Group
|
|
1672
|
-
this._group=Pt.elem("g.d3plus-ColorScale",{parent:this._select});let s=this._data.map(this._value).filter(t=>null!==t&&"number"==typeof t).sort((t,i)=>t-i);var g=this._domain||Dt.extent(s);let i=g[0]<this._midpoint;var c=g[1]>this._midpoint,u=i&&c;let n=Dt.min([this._buckets instanceof Array?this._buckets.length:this._buckets,u&&"jenks"!==this._scale?2*Math.floor(Lt.unique(s).length/2)-1:Lt.unique(s).length]),p=u&&(!this._color||this._color instanceof Array&&!this._color.includes(this._colorMid))?void 0:this._color,f,m;if(!p||p instanceof Array||(p=Dt.range(0,n,1).map(t=>A.colorLighter(p,(t+1)/n)).reverse()),"jenks"===this._scale){var y=Dt.min([p?p.length:n,n,s.length]);let t=[];m=this._buckets instanceof Array?this._buckets:(t=u&&this._centered?(b=Math.floor(y/2),
|
|
1672
|
+
this._group=Pt.elem("g.d3plus-ColorScale",{parent:this._select});let s=this._data.map(this._value).filter(t=>null!==t&&"number"==typeof t).sort((t,i)=>t-i);var g=this._domain||Dt.extent(s);let i=g[0]<this._midpoint;var c=g[1]>this._midpoint,u=i&&c;let n=Dt.min([this._buckets instanceof Array?this._buckets.length:this._buckets,u&&"jenks"!==this._scale?2*Math.floor(Lt.unique(s).length/2)-1:Lt.unique(s).length]),p=u&&(!this._color||this._color instanceof Array&&!this._color.includes(this._colorMid))?void 0:this._color,f,m;if(!p||p instanceof Array||(p=Dt.range(0,n,1).map(t=>A.colorLighter(p,(t+1)/n)).reverse()),"jenks"===this._scale){var y=Dt.min([p?p.length:n,n,s.length]);let t=[];m=this._buckets instanceof Array?this._buckets:(t=u&&this._centered?(b=Math.floor(y/2),r=y%2,x=s.filter(t=>t<this._midpoint),S=Dt.deviation(x),C=s.concat(this._midpoint).filter(t=>t>=this._midpoint),v=S<(w=Dt.deviation(C))?1:0,w=E.ckmeans(x,Dt.min([b+r*(w<S?1:0),x.length])),S=E.ckmeans(C,Dt.min([b+r*v,C.length])),w.concat(S)):E.ckmeans(s,y)).map(t=>t[0]);var x=new Set(m);if(m.length!==x.size&&(f=Array.from(x)),!p)if(u){p=[this._colorMin,this._colorMid,this._colorMax];let e=m.slice(0,y).filter((t,i)=>t<this._midpoint&&m[i+1]<=this._midpoint);var b=m.slice(0,y).filter((t,i)=>t<=this._midpoint&&m[i+1]>this._midpoint);let s=m.slice(0,y).filter(t=>t>this._midpoint);var r=e.map((t,i)=>i?A.colorLighter(p[0],i/e.length):p[0]),v=b.map(()=>p[1]),C=s.map((t,i)=>i===s.length-1?p[2]:A.colorLighter(p[2],1-(i+1)/s.length));p=r.concat(v).concat(C)}else p=Dt.range(0,n,1).map(t=>A.colorLighter(this._colorMax,t/n)).reverse();p=[(p=m.length<=y?p.slice(-m.length):p)[0]].concat(p),this._colorScale=k.scaleThreshold().domain(m).range(p)}else{let h=this._buckets instanceof Array?this._buckets:void 0;if(u&&!p){let i=Math.floor(n/2),e=z.interpolateRgb.gamma(2.2)(this._colorMin,this._colorMid);var w=Dt.range(0,i,1).map(t=>e(t/i)),S=(n%2?[0]:[]).map(()=>this._colorMid);let s=z.interpolateRgb.gamma(2.2)(this._colorMax,this._colorMid);var x=Dt.range(0,i,1).map(t=>s(t/i)).reverse();p=w.concat(S).concat(x),h||(b=(p.length-1)/2,h=[g[0],this._midpoint,g[1]],h=Dt.range(g[0],this._midpoint,-(g[0]-this._midpoint)/b).concat(Dt.range(this._midpoint,g[1],(g[1]-this._midpoint)/b)).concat([g[1]]))}else p||("buckets"===this._scale||"quantile"===this._scale?(p=Dt.range(0,n,1).map(t=>A.colorLighter(i?this._colorMin:this._colorMax,t/n)),c&&(p=p.reverse())):p=i?[this._colorMin,A.colorLighter(this._colorMin,.8)]:[A.colorLighter(this._colorMax,.8),this._colorMax]),h=h||("quantile"===this._scale?(r=1/(p.length-1),Dt.range(0,1+r/2,r).map(t=>Dt.quantile(s,t))):u&&this._color&&this._centered?(v=p.indexOf(this._colorMid),C=(this._midpoint-g[0])/v,y=(g[1]-this._midpoint)/(p.length-v),w=Dt.range(g[0],this._midpoint,C),S=Dt.range(this._midpoint,g[1]+y/2,y),w.concat(S)):(x=(g[1]-g[0])/(p.length-1),Dt.range(g[0],g[1]+x/2,x)));if("buckets"===this._scale||"quantile"===this._scale)m=h,p=[p[0]].concat(p);else if("log"===this._scale){b=h.filter(t=>t<0);if(b.length){let i=b[0],e=b.map(t=>-Math.pow(Math.abs(i),t/i));b.forEach((t,i)=>{h[h.indexOf(t)]=e[i]})}c=h.filter(t=>0<t);if(c.length){let i=c[c.length-1],e=c.map(t=>Math.pow(i,t/i));c.forEach((t,i)=>{h[h.indexOf(t)]=e[i]})}h.includes(0)&&(h[h.indexOf(0)]=1)}this._colorScale=("buckets"===this._scale||"quantile"===this._scale?k.scaleThreshold:k.scaleLinear)().domain(h).range(p)}this._colorScale.clamp&&this._colorScale.clamp(!0);r=this._bucketAxis||!["buckets","jenks","quantile"].includes(this._scale),u=I.transition().duration(this._duration),v={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:u,update:{opacity:1}},C=Pt.elem("g.d3plus-ColorScale-labels",Object.assign({condition:r},v)),y=Pt.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:r},v)),w=Pt.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!r},v));if(r){S={x:0,y:0};let e=g.slice();this._bucketAxis&&(x=e[e.length-1],b=e[e.length-2],u=1<=(c=x?x/10:b/10)||c<=-1?Math.round(c).toString().length-1:-1*c.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,g=Math.pow(10,u),e[e.length-1]=x+g);b=Pt.assign({domain:a?e:e.slice().reverse(),duration:this._duration,height:this._height,labels:f||m,orient:this._orient,padding:this._padding,scale:"log"===this._scale?"log":"linear",ticks:m,width:this._width},this._axisConfig),c=Pt.assign({height:this["_"+o]/2,width:this["_"+l]/2},this._labelConfig),u=(this._labelClass.config(c),[]),x=(a&&this._labelMin&&((x={"font-family":this._labelClass.fontFamily()(this._labelMin),"font-size":this._labelClass.fontSize()(this._labelMin),"font-weight":this._labelClass.fontWeight()(this._labelMin)})["font-family"]instanceof Array&&(x["font-family"]=x["font-family"][0]),g=Pt.textWidth(this._labelMin,x))&&g<this["_"+l]/2&&(u.push(this._labelMin),g+=this._padding,a&&(S.x+=g),b[l]-=g),a&&this._labelMax&&((x={"font-family":this._labelClass.fontFamily()(this._labelMax),"font-size":this._labelClass.fontSize()(this._labelMax),"font-weight":this._labelClass.fontWeight()(this._labelMax)})["font-family"]instanceof Array&&(x["font-family"]=x["font-family"][0]),g=Pt.textWidth(this._labelMax,x))&&g<this["_"+l]/2&&(u.push(this._labelMax),g+=this._padding,a||(S.y+=g),b[l]-=g),this._axisTest.select(Pt.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(b).duration(0).render(),this._axisTest.outerBounds()),g=(this._outerBounds[l]=this["_"+l]-2*this._padding,this._outerBounds[o]=x[o]+this._size,this._outerBounds[_]=this._padding,this._outerBounds[d]=this._padding,"middle"===this._align?this._outerBounds[d]=(this["_"+o]-this._outerBounds[o])/2:"end"===this._align&&(this._outerBounds[d]=this["_"+o]-this._padding-this._outerBounds[o]),this._outerBounds[d]+(["bottom","right"].includes(this._orient)?this._size:0)-(b.padding||this._axisClass.padding())),g=`translate(${S.x+(a?0:g)}, ${S.y+(a?g:0)})`;this._axisClass.select(Pt.elem("g.d3plus-ColorScale-axis",Pt.assign(v,{condition:!0,enter:{transform:g},update:{transform:g}})).node()).config(b).align("start").render();let s=this._axisTest._getPosition.bind(this._axisTest);g=this._axisTest._getRange();let t=this._group.selectAll("defs").data([0]);b=t.enter().append("defs"),b=(b.append("linearGradient").attr("id","gradient-"+this._uuid),(t=b.merge(t)).select("linearGradient").attr(_+"1",a?"0%":"100%").attr(_+"2",a?"100%":"0%").attr(d+"1","0%").attr(d+"2","0%"),t.select("linearGradient").selectAll("stop").data(p));let h=this._colorScale.domain(),n=k.scaleLinear().domain(g).range(a?[0,100]:[100,0]),r=(b.enter().append("stop").merge(b).attr("offset",(t,i)=>`${i<=h.length-1?n(s(h[i])):100}%`).attr("stop-color",String),(t,i)=>{i=m[i+1]||e[e.length-1];return Math.abs(s(i)-s(t))}),i=Pt.assign({duration:this._duration,fill:m?t=>this._colorScale(t):`url(#gradient-${this._uuid})`,[_]:m?(t,i)=>s(t)+r(t,i)/2-(["left","right"].includes(this._orient)?r(t,i):0):g[0]+(g[1]-g[0])/2+S[_],[d]:this._outerBounds[d]+(["top","left"].includes(this._orient)?x[o]:0)+this._size/2+S[d],[l]:m?r:g[1]-g[0],[o]:this._size},this._rectConfig);this._rectClass.data(m||[0]).id((t,i)=>i).select(y.node()).config(i).render(),c.height=this._outerBounds[o],c.width=this._outerBounds[l],this._labelClass.config(c).data(u).select(C.node()).x(t=>t===this._labelMax?i.x+i.width/2+this._padding:this._outerBounds.x).y(t=>i.y-this._labelClass.fontSize()(t)/2).text(t=>t).rotate(a?0:"right"===this._orient?90:-90).render()}else{Pt.elem("g.d3plus-ColorScale-axis",Object.assign({condition:r},v));let t=m.reduce((t,i,e)=>{i=this._bucketFormat.bind(this)(i,e,m,s);return t.push({color:p[e+1],id:i}),t},[]);a||(t=t.reverse());b=Pt.assign({align:a?"center":{start:"left",middle:"center",end:"right"}[this._align],direction:a?"row":"column",duration:this._duration,height:this._height,padding:this._padding,shapeConfig:Pt.assign({duration:this._duration},this._axisConfig.shapeConfig||{}),title:this._axisConfig.title,titleConfig:this._axisConfig.titleConfig||{},width:this._width,verticalAlign:a?{start:"top",middle:"middle",end:"bottom"}[this._align]:"middle"},this._legendConfig);this._legendClass.data(t).select(w.node()).config(b).render(),this._outerBounds=this._legendClass.outerBounds()}return t&&setTimeout(t,this._duration+100),this}
|
|
1673
1673
|
/**
|
|
1674
1674
|
@memberof ColorScale
|
|
1675
1675
|
@desc The [ColorScale](http://d3plus.org/docs/#ColorScale) is constructed by combining an [Axis](http://d3plus.org/docs/#Axis) for the ticks/labels and a [Rect](http://d3plus.org/docs/#Rect) for the actual color box (or multiple boxes, as in a jenks scale). Because of this, there are separate configs for the [Axis](http://d3plus.org/docs/#Axis) class used to display the text ([axisConfig](http://d3plus.org/docs/#ColorScale.axisConfig)) and the [Rect](http://d3plus.org/docs/#Rect) class used to draw the color breaks ([rectConfig](http://d3plus.org/docs/#ColorScale.rectConfig)). This method acts as a pass-through to the config method of the [Axis](http://d3plus.org/docs/#Axis). An example usage of this method can be seen [here](http://d3plus.org/examples/d3plus-legend/colorScale-dark/).
|
|
@@ -1852,7 +1852,7 @@ this._group=Pt.elem("g.d3plus-ColorScale",{parent:this._select});let s=this._dat
|
|
|
1852
1852
|
@memberof ColorScale
|
|
1853
1853
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
1854
1854
|
@private
|
|
1855
|
-
*/constructor(){super(),this._axisClass=new o,this._axisConfig={gridSize:0},this._axisTest=new o,this._align="middle",this._buckets=5,this._bucketAxis=!1,this._bucketFormat=(i,t,e,s)=>{var h=this._axisConfig.tickFormat||Tt.formatAbbreviate;let n=e[t+1];var
|
|
1855
|
+
*/constructor(){super(),this._axisClass=new o,this._axisConfig={gridSize:0},this._axisTest=new o,this._align="middle",this._buckets=5,this._bucketAxis=!1,this._bucketFormat=(i,t,e,s)=>{var h=this._axisConfig.tickFormat||Tt.formatAbbreviate;let n=e[t+1];var r=!!t&&e[t-1],e=t===e.length-1;return i===n||e?(e=e&&i<Dt.max(s)?"+":"",h(i)+e):(e=1<=(e=n?n/100:i/100)||e<=-1?Math.round(e).toString().length-1:-1*e.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,e=Math.pow(10,e),r=h(r===i&&1===t?Dt.min([i+e,s.find(t=>i<t&&t<n)]):i),h=h(i&&1===t?n:Dt.max([n-e,s.reverse().find(t=>i<t&&t<n)])),this._bucketJoiner(r,h))},this._bucketJoiner=(t,i)=>t!==i?t+" - "+i:""+t,this._centered=!0,this._color=["#54478C","#2C699A","#0DB39E","#83E377","#EFEA5A"],this._colorMax=A.colorDefaults.on,this._colorMid=A.colorDefaults.light,this._colorMin=A.colorDefaults.off,this._data=[],this._duration=600,this._height=200,this._labelClass=new l,this._labelConfig={fontColor:A.colorDefaults.dark,fontSize:12},this._legendClass=new rt,this._legendConfig={shapeConfig:{stroke:A.colorDefaults.dark,strokeWidth:1}},this._midpoint=0,this._orient="bottom",this._outerBounds={width:0,height:0,x:0,y:0},this._padding=5,this._rectClass=(new Ft).parent(this),this._rectConfig={stroke:"#999",strokeWidth:1},this._scale="linear",this._size=10,this._value=s("value"),this._width=400}}class ot{
|
|
1856
1856
|
/**
|
|
1857
1857
|
@memberof Message
|
|
1858
1858
|
@desc Removes the message from the page.
|
|
@@ -1878,27 +1878,27 @@ this._group=Pt.elem("g.d3plus-ColorScale",{parent:this._select});let s=this._dat
|
|
|
1878
1878
|
@memberof TextBox
|
|
1879
1879
|
@desc Renders the text boxes. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
1880
1880
|
@param {Function} [*callback* = undefined]
|
|
1881
|
-
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").node());let
|
|
1881
|
+
*/render(t){void 0===this._select&&this.select(j.select("body").append("svg").style("width",window.innerWidth+"px").style("height",window.innerHeight+"px").node());let S=this;var i=this._select.selectAll(".d3plus-textBox").data(this._data.reduce((u,p,f)=>{let m=this._text(p,f);if(void 0!==m){m=H.trim(m);let e=this._fontResize(p,f),s=this._lineHeight(p,f)/this._fontSize(p,f),h=e?this._fontMax(p,f):this._fontSize(p,f),n=e?h*s:this._lineHeight(p,f),r=1,a=[],t,o,l={"font-family":Pt.fontExists(this._fontFamily(p,f)),"font-size":h,"font-weight":this._fontWeight(p,f),"line-height":n};var y,x,b,v=Pt.parseSides(this._padding(p,f)),C=this._height(p,f)-(v.top+v.bottom),w=this._width(p,f)-(v.left+v.right);let _=H.textWrap().fontFamily(l["font-family"]).fontSize(h).fontWeight(l["font-weight"]).lineHeight(n).maxLines(this._maxLines(p,f)).height(C).overflow(this._overflow(p,f)).width(w).split(this._split),d=this._fontMax(p,f),g=this._fontMin(p,f),i=this._verticalAlign(p,f),c=this._split(m,f);w>g&&(C>n||e&&C>g*s)&&(e&&(t=Pt.textWidth(c,l),x=1.165+w/C*.1,b=w*C,y=Dt.max(t),x=Dt.sum(t,t=>t*n)*x,(w<y||b<x)&&(b=Math.sqrt(b/x),x=Dt.min([b,w/y]),h=Math.floor(h*x)),b=Math.floor(.8*C),h>b)&&(h=b),
|
|
1882
1882
|
/**
|
|
1883
1883
|
Figures out the lineData to be used for wrapping.
|
|
1884
1884
|
@private
|
|
1885
|
-
*/function t(){var i=()=>{
|
|
1885
|
+
*/function t(){var i=()=>{r<1?a=[S._ellipsis("",r)]:a[r-1]=S._ellipsis(a[r-1],r)};
|
|
1886
1886
|
// Constraint the font size
|
|
1887
|
-
h=Dt.max([h,g]),h=Dt.min([h,d]),e&&(n=h*s,_.fontSize(h).lineHeight(n),l["font-size"]=h,l["line-height"]=n),o=_(m),
|
|
1887
|
+
h=Dt.max([h,g]),h=Dt.min([h,d]),e&&(n=h*s,_.fontSize(h).lineHeight(n),l["font-size"]=h,l["line-height"]=n),o=_(m),a=o.lines.filter(t=>""!==t),r=a.length,o.truncated&&(e?--h<g?(h=g,i):t:i)()}()),a.length&&(y=r*n,b=0!==(x=this._rotate(p,f))||"top"===i?0:"middle"===i?C/2-y/2:C-y,b-=.1*n,u.push({aH:this._ariaHidden(p,f),data:p,i:f,lines:a,fC:this._fontColor(p,f),fStroke:this._fontStroke(p,f),fSW:this._fontStrokeWidth(p,f),fF:l["font-family"],fO:this._fontOpacity(p,f),fW:l["font-weight"],id:this._id(p,f),tA:this._textAnchor(p,f),vA:this._verticalAlign(p,f),widths:o.widths,fS:h,lH:n,w:w,h:C,r:x,x:this._x(p,f)+v.left,y:this._y(p,f)+b+v.top}))}return u},[]),t=>this._id(t.data,t.i));let h=this._select.transition().duration(this._duration);
|
|
1888
1888
|
/**
|
|
1889
1889
|
* Applies translate and rotate to a text element.
|
|
1890
1890
|
* @param {D3Selection} text
|
|
1891
1891
|
* @private
|
|
1892
|
-
*/function e(t){t.attr("transform",(t,i)=>{i=
|
|
1892
|
+
*/function e(t){t.attr("transform",(t,i)=>{i=S._rotateAnchor(t,i);return`translate(${t.x}, ${t.y}) rotate(${t.r}, ${i[0]}, ${i[1]})`})}0===this._duration?i.exit().remove():(i.exit().transition().delay(this._duration).remove(),i.exit().selectAll("text").transition(h).attr("opacity",0).style("opacity",0));var s=i.enter().append("g").attr("class","d3plus-textBox").attr("id",t=>"d3plus-textBox-"+H.strip(t.id)).call(e).merge(i);let n=Pt.rtl();s.order().style("pointer-events",t=>this._pointerEvents(t.data,t.i)).each(function(e){
|
|
1893
1893
|
/**
|
|
1894
1894
|
Sets the inner text content of each <text> element.
|
|
1895
1895
|
@private
|
|
1896
|
-
*/function t(t){let h=!1;t[
|
|
1897
|
-
var i=new RegExp(/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g);return t.match(i)?t=t.replace(i,(t,i,e)=>(h=!!
|
|
1896
|
+
*/function t(t){let h=!1;t[S._html?"html":"text"](s=>{let t=H.trimRight(s).replace(/&([^;&]*)/g,(t,i)=>"amp"===i?t:"&"+i).replace(/<([^A-z^/]+)/g,(t,i)=>"<"+i).replace(/<$/g,"<").replace(/(<[^>^/]+>)([^<^>]+)$/g,(t,i,e)=>""+i+e+i.replace("<","</")).replace(/^([^<^>]+)(<\/[^>]+>)/g,(t,i,e)=>""+e.replace("</","<")+i+e);// ands start tag to lines after mid-HTML break
|
|
1897
|
+
var i=new RegExp(/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g);return t.match(i)?t=t.replace(i,(t,i,e)=>(h=!!S._html[i]&&i)?(i=S._html[h],s.includes(`</${h}>`)&&(h=!1),`<tspan style="${i}">${e}</tspan>`):e):h.length&&(t=`<tspan style="${S._html[h]}">${t}</tspan>`),t})}
|
|
1898
1898
|
/**
|
|
1899
1899
|
Styles to apply to each <text> element.
|
|
1900
1900
|
@private
|
|
1901
|
-
*/function i(t){t.attr("aria-hidden",e.aH).attr("dir",n?"rtl":"ltr").attr("fill",e.fC).attr("stroke",e.fStroke).attr("stroke-width",e.fSW).attr("text-anchor",e.tA).attr("font-family",e.fF).style("font-family",e.fF).attr("font-size",e.fS+"px").style("font-size",e.fS+"px").attr("font-weight",e.fW).style("font-weight",e.fW).attr("x",`${"middle"===e.tA?e.w/2:n?"start"===e.tA?e.w:0:"end"===e.tA?e.w:2*Math.sin(Math.PI*e.r/180)}px`).attr("y",(t,i)=>0===e.r||"top"===e.vA?(i+1)*e.lH-(e.lH-e.fS)+"px":"middle"===e.vA?(e.h+e.fS)/2-(e.lH-e.fS)+(i-e.lines.length/2+.5)*e.lH+"px":e.h-2*(e.lH-e.fS)-(e.lines.length-(i+1))*e.lH+2*Math.cos(Math.PI*e.r/180)+"px")}var s=j.select(this).selectAll("text").data(e.lines);(0===
|
|
1901
|
+
*/function i(t){t.attr("aria-hidden",e.aH).attr("dir",n?"rtl":"ltr").attr("fill",e.fC).attr("stroke",e.fStroke).attr("stroke-width",e.fSW).attr("text-anchor",e.tA).attr("font-family",e.fF).style("font-family",e.fF).attr("font-size",e.fS+"px").style("font-size",e.fS+"px").attr("font-weight",e.fW).style("font-weight",e.fW).attr("x",`${"middle"===e.tA?e.w/2:n?"start"===e.tA?e.w:0:"end"===e.tA?e.w:2*Math.sin(Math.PI*e.r/180)}px`).attr("y",(t,i)=>0===e.r||"top"===e.vA?(i+1)*e.lH-(e.lH-e.fS)+"px":"middle"===e.vA?(e.h+e.fS)/2-(e.lH-e.fS)+(i-e.lines.length/2+.5)*e.lH+"px":e.h-2*(e.lH-e.fS)-(e.lines.length-(i+1))*e.lH+2*Math.cos(Math.PI*e.r/180)+"px")}var s=j.select(this).selectAll("text").data(e.lines);(0===S._duration?(s.call(t).call(i),s.exit().remove(),s.enter().append("text").attr("dominant-baseline","alphabetic").style("baseline-shift","0%").attr("unicode-bidi","bidi-override").call(t)):(s.call(t).transition(h).call(i),s.exit().transition(h).attr("opacity",0).remove(),s.enter().append("text").attr("dominant-baseline","alphabetic").style("baseline-shift","0%").attr("opacity",0).style("opacity",0).call(t).call(i).merge(s).transition(h).delay(S._delay))).call(i).attr("opacity",e.fO).style("opacity",e.fO)}).transition(h).call(e);var r=Object.keys(this._on),a=r.reduce((t,e)=>(t[e]=(t,i)=>this._on[e](t.data,i),t),{});for(let t=0;t<r.length;t++)s.on(r[t],a[r[t]]);return t&&setTimeout(t,this._duration+100),this}
|
|
1902
1902
|
/**
|
|
1903
1903
|
@memberof TextBox
|
|
1904
1904
|
@desc If *value* is specified, sets the aria-hidden attribute to the specified function or string and returns the current class instance.
|
|
@@ -2163,7 +2163,7 @@ var i=new RegExp(/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g);return t.match(i)?t=t.rep
|
|
|
2163
2163
|
*/_updateDomain(i){var e=j.pointers(i,this._select.node());let s=i.selection&&this._brushing||!e.length?i.selection:[e[0][0],e[0][0]];s=(s="ticks"===this._buttonBehaviorCurrent?s.map(this._d3Scale.invert):s).map(Number),"brush"===i.type&&this._brushing&&"buttons"===this._buttonBehaviorCurrent&&(e=i.selection.map(t=>Math.abs(t-i.sourceEvent.offsetX)),s=e[1]<=e[0]?[i.selection[0],i.sourceEvent.offsetX].sort((t,i)=>t-i):[i.sourceEvent.offsetX,i.selection[1]].sort((t,i)=>t-i));e="ticks"===this._buttonBehaviorCurrent?this._availableTicks.map(Number):this._d3Scale.range();if("ticks"===this._buttonBehaviorCurrent){
|
|
2164
2164
|
// find closest min and max ticks from data
|
|
2165
2165
|
// and their indices in the ticks Array
|
|
2166
|
-
let t=Pt.date(E.closest(s[0],e));var h=e.indexOf(+t);let i=Pt.date(E.closest(s[1],e));var n=e.indexOf(+i),
|
|
2166
|
+
let t=Pt.date(E.closest(s[0],e));var h=e.indexOf(+t);let i=Pt.date(E.closest(s[1],e));var n=e.indexOf(+i),r=Math.abs(n-h),a=this._brushMin()-1;
|
|
2167
2167
|
// using the indices, determine if the 2 ends of the brush
|
|
2168
2168
|
// are too close to each other. "ticksApart" always needs to
|
|
2169
2169
|
// be less than the current current brushMin minus 1. For
|
|
@@ -2171,9 +2171,9 @@ let t=Pt.date(E.closest(s[0],e));var h=e.indexOf(+t);let i=Pt.date(E.closest(s[1
|
|
|
2171
2171
|
// values need to be "1" space apart from eachother.
|
|
2172
2172
|
// if the min and max are not far enough apart to satisfy
|
|
2173
2173
|
// brushMin, then forcibly extend the domain.
|
|
2174
|
-
a
|
|
2174
|
+
r<a&&(
|
|
2175
2175
|
// push the maxDomain out as far as possible to account for brushMin
|
|
2176
|
-
n=Dt.min([e.length-1,n+(r
|
|
2176
|
+
n=Dt.min([e.length-1,n+(a-r)]),i=e[n],(r=Math.abs(n-h))<a)&&(h=Dt.max([0,h-(a-r)]),t=e[h]),s[0]=t,s[1]=i}else s[0]=E.closest(s[0],e),s[1]=E.closest(s[1],e);
|
|
2177
2177
|
// if the brush event has finished, update the current "selection" value
|
|
2178
2178
|
n=+s[0]==+s[1];return"brush"!==i.type&&"end"!==i.type||(this._selection="ticks"===this._buttonBehaviorCurrent?n?s[0]:s:n?Pt.date(this._availableTicks[e.indexOf(s[0])]):[Pt.date(this._availableTicks[e.indexOf(s[0])]),Pt.date(this._availableTicks[e.indexOf(s[1])])]),s}
|
|
2179
2179
|
/**
|
|
@@ -2186,9 +2186,9 @@ n=+s[0]==+s[1];return"brush"!==i.type&&"end"!==i.type||(this._selection="ticks"=
|
|
|
2186
2186
|
@desc Draws the timeline.
|
|
2187
2187
|
@param {Function} [*callback* = undefined]
|
|
2188
2188
|
@chainable
|
|
2189
|
-
*/render(t){var{height:i,y:e}=this._position;this._ticks&&(this._ticks=this._ticks.map(Pt.date)),this._data&&(this._data=this._data.map(Pt.date));let s=this._ticks||this._domain.map(Pt.date),h=(this._ticks||(n=
|
|
2189
|
+
*/render(t){var{height:i,y:e}=this._position;this._ticks&&(this._ticks=this._ticks.map(Pt.date)),this._data&&(this._data=this._data.map(Pt.date));let s=this._ticks||this._domain.map(Pt.date),h=(this._ticks||(n=k.scaleTime().domain(s).range([0,this._width]),s=n.ticks()),this._timeLocale||$.locale[this._locale]||$.locale["en-US"]),o=(void 0===this._userFormat&&(this._userFormat=this._tickFormat||!1),this._tickFormat=this._userFormat||(t=>Tt.formatDate(t,s).replace(/^Q/g,h.quarter)));if(
|
|
2190
2190
|
// Measures size of ticks
|
|
2191
|
-
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let
|
|
2191
|
+
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let a=0;s.forEach((t,i)=>{var{fontFamily:e,fontSize:s}=this._shapeConfig.labelConfig;let h="function"==typeof e?e(t,i):e,n="function"==typeof s?s(t,i):s;e=H.textWrap().fontFamily(h).fontSize(n).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):void 0)(o(t));let r=e.lines.length?Math.ceil(Dt.max(e.lines.map(t=>Pt.textWidth(t,{"font-family":h,"font-size":n}))))+n/4:0;r%2&&r++,a<r&&(a=r+2*this._buttonPadding)}),this._ticksWidth=a*s.length}var n=this._playButton?this._playButtonConfig.width||this._buttonHeight:0,r=this._width-n,r=(this._buttonBehaviorCurrent="auto"===this._buttonBehavior?this._ticksWidth<r?"buttons":"ticks":this._buttonBehavior,this._hiddenHandles="buttons"===this._buttonBehaviorCurrent&&!this._brushing);if("buttons"===this._buttonBehaviorCurrent){this._scale="ordinal";let e=k.scaleTime().domain(this._domain.map(Pt.date)).ticks().map(Number);this._domain=this._ticks||Array.from(Array(e[e.length-1]-e[0]+1),(t,i)=>e[0]+i).map(Pt.date),this._ticks=this._domain;var a=.5*this._ticksWidth/this._ticks.length,l=this._width-this._ticksWidth-n;this._paddingLeft="middle"===this._buttonAlign?l/2+n:"end"===this._buttonAlign?l+n:n,this._range=[this._paddingLeft+a,this._paddingLeft+this._ticksWidth-a]}else this._scale="time",this._domain=Dt.extent(s),this._range=[n?1.5*n:void 0,void 0],this._paddingLeft=n;super.render(t);let _=this._outerBounds[e],d=this._d3Scale.range();l=this._brush=y.brushX().extent([[d[0],_],[d[d.length-1],_+this._outerBounds[i]]]).filter(this._brushFilter).handleSize(r?0:this._handleSize).on("start",this._brushStart.bind(this)).on("brush",this._brushBrush.bind(this)).on("end",this._brushEnd.bind(this)),a="ticks"===this._buttonBehaviorCurrent?this._availableTicks:d,t=[this._brushMin()>a.length?a[0]:a[a.length-this._brushMin()],a[a.length-1]],e=void 0===this._selection?t:this._selection instanceof Array?"buttons"===this._buttonBehaviorCurrent?this._selection.map(Pt.date).map(t=>d[this._ticks.map(Number).indexOf(+t)]):this._selection.map(Pt.date):"buttons"===this._buttonBehaviorCurrent?[d[this._ticks.map(Number).indexOf(+this._selection)]]:[this._selection],1===e.length&&e.push(e[0]),this._updateBrushLimit(e),this._brushGroup=Pt.elem("g.brushGroup",{parent:this._group}),this._brushGroup.call(l).transition(this._transition).call(l.move,"ticks"===this._buttonBehaviorCurrent?this._updateBrushLimit(e):e),this._outerBounds.y-=this._handleSize/2,this._outerBounds.height+=this._handleSize/2,i=Pt.elem("g.d3plus-Timeline-play",{parent:this._group});
|
|
2192
2192
|
// data Array to be used when detecting the default value
|
|
2193
2193
|
return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-n,y:"buttons"===this._buttonBehaviorCurrent?"middle"===this._align?this._height/2-this._buttonHeight/2:"start"===this._align?this._margin.top:this._height-this._buttonHeight-this._margin.bottom:this._outerBounds.y,width:n,height:this._buttonHeight}]:[]).select(i.node()).config(jt.bind(this)(this._playButtonConfig)).render(),this}
|
|
2194
2194
|
/**
|
|
@@ -2319,7 +2319,7 @@ if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playB
|
|
|
2319
2319
|
/**
|
|
2320
2320
|
Sets styles for both enter and update.
|
|
2321
2321
|
@private
|
|
2322
|
-
*/function
|
|
2322
|
+
*/function r(t){t.style("background",o._background).style(o._prefix+"border-radius",o._borderRadius).style("pointer-events",o._pointerEvents).style("padding",o._padding).style("width",o._width).style("height",o._height).style("border",o._border)}Pt.stylize(h,this._tooltipStyle),e("title"),e("body");var a=s.append("table").attr("class","d3plus-tooltip-table"),l=h.select(".d3plus-tooltip-table"),l=(Pt.stylize(l,this._tableStyle),a.append("thead").attr("class","d3plus-tooltip-thead"),h.select(".d3plus-tooltip-thead")),l=(Pt.stylize(l,this._theadStyle),l.selectAll("tr").data([0])),_=l.enter().append("tr"),l=(l.exit().remove(),l.merge(_)),_=(Pt.stylize(l,this._trStyle),l.selectAll("th").data(this._thead)),l=(_.enter().append("th").merge(_).html(n),_.exit().remove(),a.append("tbody").attr("class","d3plus-tooltip-tbody"),h.select(".d3plus-tooltip-tbody")),_=(Pt.stylize(l,this._tbodyStyle),l.selectAll("tr").data(this._tbody)),a=_.enter().append("tr"),l=(_.exit().remove(),_.merge(a)),_=(Pt.stylize(l,this._trStyle),l.selectAll("td").data(t=>t));return _.enter().append("td").merge(_).html(n),Pt.stylize(_,this._tdStyle),e("footer"),e("arrow"),s.attr("id",(t,i)=>"d3plus-tooltip-"+(t?this._id(t,i):"")).call(r).each((t,i)=>{var e=o._id(t,i),s=document.getElementById("d3plus-tooltip-"+e),h=document.getElementById("d3plus-tooltip-arrow-"+e);let n=h.offsetHeight;var r=h.getBoundingClientRect().height/2,a=(h.style.bottom=`-${n/2}px`,o._position(t,i)),a=Array.isArray(a)?{getBoundingClientRect:gt(a)}:a;this._popperClasses[e]=x.createPopper(a,s,{placement:"top",modifiers:[{name:"arrow",options:{element:h}},{name:"offset",options:{offset:[0,o._offset(t,i)+r]}},{name:"preventOverflow",options:{boundary:"scrollParent",padding:5}},{name:"flip",options:{behavior:"flip",boundary:"viewport",fallbackPlacements:["bottom"],padding:5}},{name:"update",enabled:!0,phase:"afterWrite",fn(t){var t=t.state,i=t.elements.arrow,e=t.styles.arrow,t=t.modifiersData.flip._skip,s=parseFloat(i.style.borderRightWidth,10);t?(i.style.transform=e.transform+"rotate(225deg)",i.style.top=`-${n/2+s}px`):(i.style.transform=e.transform+"rotate(45deg)",i.style.bottom=`-${n/2+s}px`)}}],removeOnDestroy:!0})}),h.each((t,i)=>{var e=o._id(t,i),t=o._position(t,i),i=this._popperClasses[e];i&&(i.state.elements.reference.getBoundingClientRect=Array.isArray(t)?gt(t):t,i.update())}).call(r),i.exit().each((t,i)=>{t=o._id(t,i),i=this._popperClasses[t];i&&(i.destroy(),delete this._popperClasses[t])}).remove(),t&&setTimeout(t,100),this}
|
|
2323
2323
|
/**
|
|
2324
2324
|
@memberof Tooltip
|
|
2325
2325
|
@desc Sets the inner HTML content of the arrow element, which by default is empty.
|
|
@@ -2551,7 +2551,7 @@ if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playB
|
|
|
2551
2551
|
@function _drawColorScale
|
|
2552
2552
|
@desc Renders the color scale if this._colorScale is not falsey.
|
|
2553
2553
|
@private
|
|
2554
|
-
*/function ut(){var t=Array.from(Dt.rollup(this._data,t=>Lt.merge(t,this._aggs),(t,i)=>`${this._time?this._time(t,i):"all"}-`+this._ids(t,i).join("_")).values());let i=this._colorScalePosition.bind(this)(this.config());[!1,"top","bottom","left","right"].includes(i)||(i="bottom");var e=["top","bottom"].includes(i),s=this._colorScale&&i,h=this._colorScalePadding()?this._padding:{top:0,right:0,bottom:0,left:0},n=this._width-(this._margin.left+this._margin.right+h.left+h.right),
|
|
2554
|
+
*/function ut(){var t=Array.from(Dt.rollup(this._data,t=>Lt.merge(t,this._aggs),(t,i)=>`${this._time?this._time(t,i):"all"}-`+this._ids(t,i).join("_")).values());let i=this._colorScalePosition.bind(this)(this.config());[!1,"top","bottom","left","right"].includes(i)||(i="bottom");var e=["top","bottom"].includes(i),s=this._colorScale&&i,h=this._colorScalePadding()?this._padding:{top:0,right:0,bottom:0,left:0},n=this._width-(this._margin.left+this._margin.right+h.left+h.right),r=e?Dt.min([this._colorScaleMaxSize,n]):this._width-(this._margin.left+this._margin.right),a=this._height-(this._margin.bottom+this._margin.top+h.bottom+h.top),o=e?this._height-(this._margin.bottom+this._margin.top):Dt.min([this._colorScaleMaxSize,a]),n={opacity:i?1:0,transform:`translate(${e?this._margin.left+h.left+(n-r)/2:this._margin.left}, ${e?this._margin.top:this._margin.top+h.top+(a-o)/2})`},h=Pt.elem("g.d3plus-viz-colorScale",{condition:s&&!this._colorScaleConfig.select,enter:n,parent:this._select,duration:this._duration,update:n}).node();this._colorScale&&(a=t.filter((t,i)=>{t=this._colorScale(t,i);return null!=t}),this._colorScaleClass.align({bottom:"end",left:"start",right:"end",top:"start"}[i]||"bottom").duration(this._duration).data(a).height(o).locale(this._locale).orient(i).select(h).value(this._colorScale).width(r).config(this._colorScaleConfig).render(),s)&&(n=this._colorScaleClass.outerBounds(),!this._colorScaleConfig.select)&&n.height&&(this._margin[i]+=e?n.height+2*this._legendClass.padding():n.width+2*this._legendClass.padding())}let pt=["fill","opacity","texture"];
|
|
2555
2555
|
/**
|
|
2556
2556
|
@function legendLabel
|
|
2557
2557
|
@desc Default label function for the legend.
|
|
@@ -2562,7 +2562,7 @@ if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playB
|
|
|
2562
2562
|
@desc Renders the legend if this._legend is not falsy.
|
|
2563
2563
|
@param {Array} data The filtered data array to be displayed.
|
|
2564
2564
|
@private
|
|
2565
|
-
*/function mt(t=[]){let e=[],s=(t,i,e)=>{var s=this._shape(t,i),s=("fill"===e&&"Line"===s&&(e="stroke"),(this._shapeConfig[s]&&this._shapeConfig[s][e]?this._shapeConfig[s]:this._shapeConfig)[e]);return"function"==typeof s?s.bind(this)(t,i):s};var i=(i,e)=>pt.map(t=>s(i,e,t)).join("_"),t=this._colorScale?t.filter((t,i)=>void 0===this._colorScale(t,i)):t,h=(Dt.rollup(t,t=>e.push(Lt.merge(t,this._aggs)),i),e.sort(this._legendSort),e.map((t,i)=>this._ids(t,i).slice(0,this._drawDepth+1)));for(let i=this._legendDepth=0;i<=this._drawDepth;i++){var n=h.map(t=>t[i]);if(!n.some(t=>t instanceof Array)&&Array.from(new Set(n)).length===e.length){this._legendDepth=i;break}}let
|
|
2565
|
+
*/function mt(t=[]){let e=[],s=(t,i,e)=>{var s=this._shape(t,i),s=("fill"===e&&"Line"===s&&(e="stroke"),(this._shapeConfig[s]&&this._shapeConfig[s][e]?this._shapeConfig[s]:this._shapeConfig)[e]);return"function"==typeof s?s.bind(this)(t,i):s};var i=(i,e)=>pt.map(t=>s(i,e,t)).join("_"),t=this._colorScale?t.filter((t,i)=>void 0===this._colorScale(t,i)):t,h=(Dt.rollup(t,t=>e.push(Lt.merge(t,this._aggs)),i),e.sort(this._legendSort),e.map((t,i)=>this._ids(t,i).slice(0,this._drawDepth+1)));for(let i=this._legendDepth=0;i<=this._drawDepth;i++){var n=h.map(t=>t[i]);if(!n.some(t=>t instanceof Array)&&Array.from(new Set(n)).length===e.length){this._legendDepth=i;break}}let r=(t,i)=>{let e=this._id(t,i);return e instanceof Array&&(e=e[0]),this._hidden.includes(e)||this._solo.length&&!this._solo.includes(e)};var t=this._legendClass.outerBounds(),a=this.config();let o=this._legendPosition.bind(this)(a);[!1,"top","bottom","left","right"].includes(o)||(o="bottom");var l=["top","bottom"].includes(o),_=this._legendPadding()?this._padding:{top:0,right:0,bottom:0,left:0},d={transform:`translate(${l?this._margin.left+_.left:this._margin.left}, ${l?this._margin.top:this._margin.top+_.top})`},a=this._legend.bind(this)(a,e),d=Pt.elem("g.d3plus-viz-legend",{condition:a&&!this._legendConfig.select,enter:d,parent:this._select,duration:this._duration,update:d}).node();this._legendClass.id(i).align(l?"center":o).direction(l?"row":"column").duration(this._duration).data(a?e:[]).height(l?this._height-(this._margin.bottom+this._margin.top):this._height-(this._margin.bottom+this._margin.top+_.bottom+_.top)).locale(this._locale).parent(this).select(d).shape((t,i)=>"Circle"===this._shape(t,i)?"Circle":"Rect").verticalAlign(l?o:"middle").width(l?this._width-(this._margin.left+this._margin.right+_.left+_.right):this._width-(this._margin.left+this._margin.right)).shapeConfig(jt.bind(this)(this._shapeConfig,"legend")).shapeConfig({fill:(t,i)=>r(t,i)?this._hiddenColor(t,i):s(t,i,"fill"),labelConfig:{fontOpacity:(t,i)=>r(t,i)?this._hiddenOpacity(t,i):1}}).config(this._legendConfig).render(),!this._legendConfig.select&&t.height&&(this._margin[o]+=l?t.height+2*this._legendClass.padding():t.width+2*this._legendClass.padding())}
|
|
2566
2566
|
/**
|
|
2567
2567
|
@function _drawSubtitle
|
|
2568
2568
|
@desc Draws a subtitle if this._subtitle is defined.
|
|
@@ -2585,11 +2585,11 @@ if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playB
|
|
|
2585
2585
|
@name zoomControls
|
|
2586
2586
|
@desc Sets up initial zoom events and controls.
|
|
2587
2587
|
@private
|
|
2588
|
-
*/function bt(){if(this._container&&this._zoomGroup){let t=this._zoomHeight||this._height-this._margin.top-this._margin.bottom,i=this,e=this._zoomWidth||this._width-this._margin.left-this._margin.right,s=(this._zoomBehavior.extent([[0,0],[e,t]]).scaleExtent([1,this._zoomMax]).translateExtent([[0,0],[e,t]]).on("zoom",t=>Ct.bind(this)(t.transform)),this._zoomToBounds=
|
|
2588
|
+
*/function bt(){if(this._container&&this._zoomGroup){let t=this._zoomHeight||this._height-this._margin.top-this._margin.bottom,i=this,e=this._zoomWidth||this._width-this._margin.left-this._margin.right,s=(this._zoomBehavior.extent([[0,0],[e,t]]).scaleExtent([1,this._zoomMax]).translateExtent([[0,0],[e,t]]).on("zoom",t=>Ct.bind(this)(t.transform)),this._zoomToBounds=St.bind(this),j.select(this._select.node().parentNode).selectAll("div.d3plus-zoom-control").data(this._zoom?[0]:[]));var h=s.enter().append("div").attr("class","d3plus-zoom-control"),h=(s.exit().remove(),s=s.merge(h).style("position","absolute").style("top",this._margin.top+"px").style("left",this._margin.left+"px"),h.append("div").attr("class","zoom-control zoom-in"),s.select(".zoom-in").on("click",wt.bind(this,this._zoomFactor)).html("+"),h.append("div").attr("class","zoom-control zoom-out"),s.select(".zoom-out").on("click",wt.bind(this,1/this._zoomFactor)).html("-"),h.append("div").attr("class","zoom-control zoom-reset"),s.select(".zoom-reset").on("click",wt.bind(this,0)).html("↺"),h.append("div").attr("class","zoom-control zoom-brush"),s.select(".zoom-brush").on("click",function(){j.select(this).classed("active",!xt).call(Pt.stylize,xt?i._zoomControlStyle||{}:i._zoomControlStyleActive||{}),vt.bind(i)(!xt)}).html("¤"),s.selectAll(".zoom-control").call(Pt.stylize,i._zoomControlStyle).on("mouseenter",function(){j.select(this).call(Pt.stylize,i._zoomControlStyleHover||{})}).on("mouseleave",function(){j.select(this).call(Pt.stylize,j.select(this).classed("active")?i._zoomControlStyleActive||{}:i._zoomControlStyle||{})}),this._zoomBrush.extent([[0,0],[e,t]]).filter(t=>!t.button&&t.detail<2).handleSize(this._zoomBrushHandleSize).on("start",
|
|
2589
2589
|
/**
|
|
2590
2590
|
@desc Triggered on brush "start".
|
|
2591
2591
|
@private
|
|
2592
|
-
*/function(){
|
|
2592
|
+
*/function(){kt.bind(this)()}
|
|
2593
2593
|
/**
|
|
2594
2594
|
@desc Overrides the default brush styles.
|
|
2595
2595
|
@private
|
|
@@ -2597,12 +2597,12 @@ if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playB
|
|
|
2597
2597
|
/**
|
|
2598
2598
|
@desc Triggered on brush "brush".
|
|
2599
2599
|
@private
|
|
2600
|
-
*/function(){
|
|
2600
|
+
*/function(){kt.bind(this)()}
|
|
2601
2601
|
/**
|
|
2602
2602
|
@desc Triggered on brush "end".
|
|
2603
2603
|
@private
|
|
2604
2604
|
*/.bind(this)).on("end",function(t){t.selection&&(// Only transition after input.
|
|
2605
|
-
this._brushGroup.call(this._zoomBrush.move,null),
|
|
2605
|
+
this._brushGroup.call(this._zoomBrush.move,null),St.bind(this)(t.selection))}.bind(this)),this._container.selectAll("g.brush").data([0]));this._brushGroup=h.enter().append("g").attr("class","brush").merge(h).call(this._zoomBrush),vt.bind(this)(),this._renderTiles&&this._renderTiles(d.zoomTransform(this._container.node()),0)}}
|
|
2606
2606
|
/**
|
|
2607
2607
|
@name zoomEvents
|
|
2608
2608
|
@desc Handles adding/removing zoom event listeners.
|
|
@@ -2627,7 +2627,7 @@ this._brushGroup.call(this._zoomBrush.move,null),kt.bind(this)(t.selection))}.bi
|
|
|
2627
2627
|
@param {Array} *bounds*
|
|
2628
2628
|
@param {Number} [*duration* = 0]
|
|
2629
2629
|
@private
|
|
2630
|
-
*/function
|
|
2630
|
+
*/function St(s,t=this._duration){var h=this._zoomBehavior.scaleExtent(),n=d.zoomTransform(this._container.node());if(s){var[r,a]=this._zoomBehavior.translateExtent()[1],o=s[1][0]-s[0][0],l=s[1][1]-s[0][1];let t=Math.min(h[1],1/Math.max(o/r,l/a)),i,e;o/l<r/a?(t*=(a-2*this._zoomPadding)/a,i=(r-o*t)/2/t,e=this._zoomPadding/t):(t*=(r-2*this._zoomPadding)/r,e=(a-l*t)/2/t,i=this._zoomPadding/t),n.x=(n.x-s[0][0]+i)*(n.k*t/n.k),n.y=(n.y-s[0][1]+e)*(n.k*t/n.k),n.k*=t,0<n.x?n.x=0:n.x<r*-n.k+r&&(n.x=r*-n.k+r),0<n.y?n.y=0:n.y<a*-n.k+a&&(n.y=a*-n.k+a)}else n.k=h[0],n.x=0,n.y=0;Ct.bind(this)(n,t)}function kt(){this._brushGroup.selectAll(".selection").call(Pt.attrize,this._zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(Pt.attrize,this._zoomBrushHandleStyle||{})}
|
|
2631
2631
|
/**
|
|
2632
2632
|
@name _drawAttribution
|
|
2633
2633
|
@desc Draws absolute positioned attribution text.
|
|
@@ -2946,7 +2946,7 @@ return j.select("body").on("touchstart."+this._uuid,
|
|
|
2946
2946
|
@desc If *value* is specified, sets the hover method to the specified function and returns the current class instance.
|
|
2947
2947
|
@param {Function} [*value*]
|
|
2948
2948
|
@chainable
|
|
2949
|
-
*/hover(i){let s=this._hover=i;if(1!==this._shapeConfig.hoverOpacity){if("function"==typeof i){let t=Dt.merge(this._shapes.map(t=>t.data()));t=t.concat(this._legendClass.data());i=i?t.filter(i):[];let e=[];i.map(this._ids).forEach(i=>{for(let t=1;t<=i.length;t++)e.push(JSON.stringify(i.slice(0,t)))}),(e=e.filter((t,i)=>e.indexOf(t)===i)).length&&(s=(t,i)=>e.includes(JSON.stringify(this._ids(t,i))))}this._shapes.forEach(t=>t.hover(s)),this._legend&&this._legendClass.hover(s)}return this}
|
|
2949
|
+
*/hover(i){let s=this._hover=i;if(1!==this._shapeConfig.hoverOpacity&&void 0!==i){if("function"==typeof i){let t=Dt.merge(this._shapes.map(t=>t.data()));t=t.concat(this._legendClass.data());i=i?t.filter(i):[];let e=[];i.map(this._ids).forEach(i=>{for(let t=1;t<=i.length;t++)e.push(JSON.stringify(i.slice(0,t)))}),(e=e.filter((t,i)=>e.indexOf(t)===i)).length&&(s=(t,i)=>e.includes(JSON.stringify(this._ids(t,i))))}this._shapes.forEach(t=>t.hover(s)),this._legend&&this._legendClass.hover(s)}return this}
|
|
2950
2950
|
/**
|
|
2951
2951
|
@memberof Viz
|
|
2952
2952
|
@desc If *value* is specified, sets the label accessor to the specified function or string and returns the current class instance.
|
|
@@ -3275,7 +3275,7 @@ return j.select("body").on("touchstart."+this._uuid,
|
|
|
3275
3275
|
@memberof Viz
|
|
3276
3276
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
3277
3277
|
@private
|
|
3278
|
-
*/constructor(){super(),this._aggs={},this._ariaHidden=!0,this._attribution=!1,this._attributionStyle={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)",display:"block",font:"400 11px/11px "+H.fontFamilyStringify(H.fontFamily),margin:"5px",opacity:.75,padding:"4px 6px 3px"},this._backClass=(new l).on("click",()=>{(this._history.length?this.config(this._history.pop()):this.depth(this._drawDepth-1).filter(!1)).render()}).on("mousemove",()=>this._backClass.select().style("cursor","pointer")),this._backConfig={fontSize:10,padding:5,resize:!1},this._cache=!0,this._color=(t,i)=>this._groupBy[0](t,i),this._colorDefaults={...A.colorDefaults,scale:
|
|
3278
|
+
*/constructor(){super(),this._aggs={},this._ariaHidden=!0,this._attribution=!1,this._attributionStyle={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)",display:"block",font:"400 11px/11px "+H.fontFamilyStringify(H.fontFamily),margin:"5px",opacity:.75,padding:"4px 6px 3px"},this._backClass=(new l).on("click",()=>{(this._history.length?this.config(this._history.pop()):this.depth(this._drawDepth-1).filter(!1)).render()}).on("mousemove",()=>this._backClass.select().style("cursor","pointer")),this._backConfig={fontSize:10,padding:5,resize:!1},this._cache=!0,this._color=(t,i)=>this._groupBy[0](t,i),this._colorDefaults={...A.colorDefaults,scale:k.scaleOrdinal().range(A.colorDefaults.scale.range())},this._colorScaleClass=new at,this._colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},this._colorScalePadding=At,this._colorScalePosition=()=>this._width>1.5*this._height?"right":"bottom",this._colorScaleMaxSize=600,this._data=[],this._dataCutoff=100,this._detectResize=!0,this._detectResizeDelay=400,this._detectVisible=!0,this._detectVisibleInterval=1e3,this._downloadButton=!1,this._downloadConfig={type:"png"},this._downloadPosition="top",this._duration=600,this._fontFamily=H.fontFamily,this._hidden=[],this._hiddenColor=Ht("#aaa"),this._hiddenOpacity=Ht(.5),this._history=[],this._groupBy=[s("id")],this._legend=(t,i)=>{var e=Dt.max(i,(t,i)=>{t=this._groupBy[this._legendDepth].bind(this)(t,i);return t instanceof Array?t.length:1});return 1<i.length&&e<=2},this._legendClass=new rt,this._legendConfig={label:ft.bind(this),shapeConfig:{ariaLabel:ft.bind(this),labelConfig:{fontColor:void 0,fontResize:!1,padding:0}}},this._legendFilterInvert=Ht(!1),this._legendPadding=At,this._legendPosition=()=>this._width>1.5*this._height?"right":"bottom",this._legendSort=(t,i)=>this._drawLabel(t).localeCompare(this._drawLabel(i)),this._legendTooltip={},this._loadingHTML=()=>`
|
|
3279
3279
|
<div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">
|
|
3280
3280
|
<strong>${this._translate("Loading Visualization")}</strong>
|
|
3281
3281
|
<sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${this._translate("Powered by D3plus")}</a></sub>
|
|
@@ -3310,22 +3310,22 @@ return j.select("body").on("touchstart."+this._uuid,
|
|
|
3310
3310
|
var e=Object.keys(this._on).some(t=>// all valid click event keys,
|
|
3311
3311
|
["click","click.shape"].includes(t)&&// truthy values (no nulls),
|
|
3312
3312
|
this._on[t]&&// and it is not our default click.shape function
|
|
3313
|
-
this._on[t].toString()!==i),n=this._on["click.shape"]&&this._on["click.shape"].toString()===i,
|
|
3313
|
+
this._on[t].toString()!==i),n=this._on["click.shape"]&&this._on["click.shape"].toString()===i,r=this._drawDepth<this._groupBy.length-1,e=(
|
|
3314
3314
|
// only show the hand cursor when the shape has a click event
|
|
3315
|
-
this._select.style("cursor",e||n&&
|
|
3315
|
+
this._select.style("cursor",e||n&&r?"pointer":"auto"),h.touches?[h.touches[0].clientX,h.touches[0].clientY]:[h.clientX,h.clientY]);
|
|
3316
3316
|
// does the shape still have our default "click.shape" event?
|
|
3317
3317
|
// (if the user only sets "click", both functions will fire)
|
|
3318
|
-
this._tooltipClass.data([s||t]).footer(!(!n||!
|
|
3318
|
+
this._tooltipClass.data([s||t]).footer(!(!n||!r)&&this._translate("Click to Expand")).title(this._drawLabel).position(e).config(jt.bind(this)(this._tooltipConfig)).render()}}.bind(this),"mousemove.legend":function(e,s,h,n){var n=n.touches?[n.touches[0].clientX,n.touches[0].clientY]:[n.clientX,n.clientY],r=Dt.merge(this._legendClass.data().map((t,i)=>{let e=this._id(t,i);return e=e instanceof Array?e:[e]})).length;if(e&&this._tooltip(e,s)){let t=this._id(e,s);t instanceof Array&&(t=t[0]);s=this._translate;let i=Mt.bind(this).toString();
|
|
3319
3319
|
// does the legend have any user-defined click events?
|
|
3320
|
-
var
|
|
3320
|
+
var a=Object.keys(this._on).some(t=>// all valid click event keys,
|
|
3321
3321
|
["click","click.legend"].includes(t)&&// truthy values (no nulls),
|
|
3322
3322
|
this._on[t]&&// and it is not our default click.legend function
|
|
3323
|
-
this._on[t].toString()!==i),o=this._on["click.legend"]&&this._on["click.legend"].toString()===i,l=this._drawDepth<this._groupBy.length-1,
|
|
3323
|
+
this._on[t].toString()!==i),o=this._on["click.legend"]&&this._on["click.legend"].toString()===i,l=this._drawDepth<this._groupBy.length-1,a=(
|
|
3324
3324
|
// only show the hand cursor when the shape has a click event
|
|
3325
|
-
this._select.style("cursor",
|
|
3325
|
+
this._select.style("cursor",a||o&&l?"pointer":"auto"),this._legendFilterInvert.bind(this)()),l=this._solo.includes(t),_=this._hidden.includes(t);
|
|
3326
3326
|
// does the legend still have our default "click.legend" event?
|
|
3327
3327
|
// (if the user only sets "click", both functions will fire)
|
|
3328
|
-
this._tooltipClass.data([h||e]).footer(!!o&&(
|
|
3328
|
+
this._tooltipClass.data([h||e]).footer(!!o&&(a?this._solo.length&&!l||_?s("Click to Highlight"):1===this._solo.length&&l||this._hidden.length===r-1?s("Click to Show All"):s("Click to Highlight")+"<br />"+s("Shift+Click to Hide"):this._solo.length&&!l||_?s("Click to Show")+"<br />"+s("Shift+Click to Highlight"):1===this._solo.length&&l||this._hidden.length===r-1?s("Click to Show All"):s("Click to Hide")+"<br />"+s("Shift+Click to Highlight"))).title(this._legendConfig.label?this._legendClass.label():ft.bind(this)).position(n).config(jt.bind(this)(this._tooltipConfig)).config(jt.bind(this)(this._legendTooltip)).render()}}.bind(this)},this._queue=[],this._resizeObserver=new ResizeObserver(((e,s)=>{let h;return function(...t){let i=this;clearTimeout(h),h=setTimeout(()=>e.apply(i,t),s)}})(()=>{this._setSVGSize(),this.render(this._callback)},this._detectResizeDelay)),this._scrollContainer="undefined"==typeof window?"":window,this._shape=Ht("Rect"),this._shapes=[],this._shapeConfig={ariaLabel:(t,i)=>this._drawLabel(t,i),fill:(i,e)=>{for(;i.__d3plus__&&i.data;)e=(i=i.data).i;if(this._colorScale){let t=this._colorScale(i,e);var s,h;if(null!=t)return s=this._colorScaleClass._colorScale,h=this._colorScaleClass.color(),s?s.domain().length?s(t):s.range()[s.range().length-1]:h instanceof Array?h[h.length-1]:h}let t=this._color(i,e);return n.color(t)?t:A.colorAssign("string"==typeof t?t:JSON.stringify(t),this._colorDefaults)},labelConfig:{fontColor:(t,i)=>{t="function"==typeof this._shapeConfig.fill?this._shapeConfig.fill(t,i):this._shapeConfig.fill;return A.colorContrast(t)}},opacity:Ht(1),stroke:(t,i)=>{t="function"==typeof this._shapeConfig.fill?this._shapeConfig.fill(t,i):this._shapeConfig.fill;return n.color(t).darker(.25)},role:"presentation",strokeWidth:Ht(0)},this._solo=[],this._subtitleClass=new l,this._subtitleConfig={ariaHidden:!0,fontSize:12,padding:5,resize:!1,textAnchor:"middle"},this._subtitlePadding=At,this._svgDesc="",this._svgTitle="",this._timeline=!0,this._timelineClass=(new dt).align("end"),this._timelineConfig={padding:5},this._timelinePadding=At,this._threshold=Ht(1e-4),this._thresholdKey=void 0,this._thresholdName=()=>this._translate("Values"),this._titleClass=new l,this._titleConfig={ariaHidden:!0,fontSize:16,padding:5,resize:!1,textAnchor:"middle"},this._titlePadding=At,this._tooltip=Ht(!0),this._tooltipClass=new ct,this._tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},this._totalClass=new l,this._totalConfig={fontSize:10,padding:5,resize:!1,textAnchor:"middle"},this._totalFormat=t=>this._translate("Total")+": "+Tt.formatAbbreviate(t,this._locale),this._totalPadding=At,this._zoom=!1,this._zoomBehavior=d.zoom(),this._zoomBrush=y.brush(),this._zoomBrushHandleSize=1,this._zoomBrushHandleStyle={fill:"#444"},this._zoomBrushSelectionStyle={fill:"#777","stroke-width":0},this._zoomControlStyle={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.75)",color:"rgba(0, 0, 0, 0.75)",display:"block",font:"900 15px/21px "+H.fontFamilyStringify(H.fontFamily),height:"20px",margin:"5px",opacity:.75,padding:0,"text-align":"center",width:"20px"},this._zoomControlStyleActive={background:"rgba(0, 0, 0, 0.75)",color:"rgba(255, 255, 255, 0.75)",opacity:1},this._zoomControlStyleHover={cursor:"pointer",opacity:1},this._zoomFactor=2,this._zoomMax=16,this._zoomPadding=20,this._zoomPan=!0,this._zoomScroll=!0}}
|
|
3329
3329
|
/**
|
|
3330
3330
|
@module discreteBuffer
|
|
3331
3331
|
@desc Adds left/right padding to a point or time scale.
|
|
@@ -3344,7 +3344,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3344
3344
|
/**
|
|
3345
3345
|
@module numericBuffer
|
|
3346
3346
|
@private
|
|
3347
|
-
*/function p(n,a,
|
|
3347
|
+
*/function p(n,r,a,o,t,i,l,_){if(void 0===a||isNaN(i[0])||isNaN(i[1]))return i;if(_&&(i=i.slice().reverse(),t=t.slice().reverse()),i[0]===i[1])i=i.slice(),"log"===r?(i=[Gt(i[0]),Vt(i[0])])[1]<i[0]&&i.reverse():(t=Math.abs(parseFloat(i[0].toPrecision(1).replace(/[0-9]{1}$/,"1"))),i[0]-=t,i[1]+=t),n.domain(_?i.slice().reverse():i);else{var e=i[0]===i[1]?10:Math.abs(Math.log(i[1]-i[0])/100),s=()=>{let e=n.copy(),s=!1;if("log"===r){let t=n.domain().slice(),i=n.range().slice();_&&(t=t.reverse(),i=i.reverse()),(s=t[0]*t[1]<0)&&(h=(h=k.scaleLog().domain([1e-6,Math.abs(t[l])]).range([0,1])(Math.abs(t[l?0:1])))/(h+1)*(i[1]-i[0]),t=(0===l?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),i=0===l?[i[0],i[0]+h]:[i[0]+h,i[1]]),e=k.scaleLog().domain(t).range(i)}let t=!1;var h=e.range();let i;return i="log"===r&&s?e(Math.abs(a)):e(a),_?0===l?t=i+o>h[l]:1===l&&(t=i-o<h[l]):0===l?t=i-o<h[l]:1===l&&(t=i+o>h[l]),t};if(n.invert&&s())if("log"===r){let t=0;for(;t<10&&s();){var h=(0===l?-1:1)*(i[l]<0?-1:1);i[l]+=i[l]*e*h,n.domain(_?i.slice().reverse():i),t++}}else 0===l?(t=n.invert(n(a)+(o+10)*(_?1:-1)))<i[l]&&(i[l]=t,n.domain(_?i.slice().reverse():i)):1===l&&(t=n.invert(n(a)+(o+10)*(_?-1:1)))>i[l]&&(i[l]=t,n.domain(_?i.slice().reverse():i))}return _?i.reverse():i}
|
|
3348
3348
|
/**
|
|
3349
3349
|
@module circleBuffer
|
|
3350
3350
|
@desc Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3354,7 +3354,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3354
3354
|
@param {Object} [config]
|
|
3355
3355
|
@param {Number} [buffer] Defaults to the radius of the largest Circle.
|
|
3356
3356
|
@private
|
|
3357
|
-
*/let Yt=g.theme,Kt=new It,Ut=new l,Xt={Bar:function({data:t,x:i,y:e,x2:s,y2:h,buffer:n=10}){let
|
|
3357
|
+
*/let Yt=g.theme,Kt=new It,Ut=new l,Xt={Bar:function({data:t,x:i,y:e,x2:s,y2:h,buffer:n=10}){let r=s?"x2":"x",a=h?"y2":"y";var o,h=(s="x"===this._discrete?e:i).domain().slice();let l="x"===this._discrete;l&&h.reverse();let _,d,g=(_=this._stacked?(o=Ot.nest().key(t=>t[this._discrete]+"_"+t.group).entries(t).map(t=>t.values.map(t=>t[l?a:r])),d=o.map(t=>Dt.sum(t.filter(t=>0<t))),o.map(t=>Dt.sum(t.filter(t=>t<0)))):(o=t.map(t=>t[l?a:r]),d=o.filter(t=>0<t),o.filter(t=>t<0)),s(Dt.max(d))),c=((l?g<s(0):g>s(0))&&(g+=l?-n:n),g=s.invert(g),s(Dt.min(_)));return(l?c>s(0):c<s(0))&&(c+=l?n:-n),c=s.invert(c),g>h[1]&&(h[1]=g),c<h[0]&&(h[0]=c),l&&h.reverse(),s.domain(h),[i,e]}
|
|
3358
3358
|
/**
|
|
3359
3359
|
@module boxBuffer
|
|
3360
3360
|
@desc Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3364,7 +3364,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3364
3364
|
@param {Object} [config]
|
|
3365
3365
|
@param {Number} [buffer = 10]
|
|
3366
3366
|
@private
|
|
3367
|
-
*/,Box:function({data:t,x:i,y:e,x2:s,y2:h,buffer:n=10}){let
|
|
3367
|
+
*/,Box:function({data:t,x:i,y:e,x2:s,y2:h,buffer:n=10}){let r=s?"x2":"x",a=h?"y2":"y",o=(s="x"===this._discrete?e:i,h=s.domain().slice(),"x"===this._discrete);o&&h.reverse();let l,_;l=this._stacked?(d=Ot.nest().key(t=>t[this._discrete]).entries(t).map(t=>t.values.map(t=>t[o?a:r])),_=d.map(t=>Dt.sum(t.filter(t=>0<t))),d.map(t=>Dt.sum(t.filter(t=>t<0)))):_=t.map(t=>t[o?a:r]);var d=s(Dt.max(_)),t=(d+=o?-n:n,d=s.invert(d),s(Dt.min(l)));return t+=o?n:-n,t=s.invert(t),d>h[1]&&(h[1]=d),t<h[0]&&(h[0]=t),o&&h.reverse(),s.domain(h),[i,e]},Circle:function({data:t,x:e,y:s,x2:i,y2:h,yScale:n,xScale:r,config:a,buffer:o}){e=e.copy(),s=s.copy();let l=i?"x2":"x",_=h?"y2":"y",d=e.domain().slice(),g=s.domain().slice(),c=e.range(),u=s.range();return!e.invert&&e.padding&&qt(e,t,this._discrete),!s.invert&&s.padding&&qt(s,t,this._discrete),(e.invert||s.invert)&&t.forEach(t=>{var i=o||2*a.r(t.data,t.i);e.invert&&(d=p(e,r,t[l],i,c,d,0,!1),d=p(e,r,t[l],i,c,d,1,!1)),s.invert&&(g=p(s,n,t[_],i,u,g,0,!0),g=p(s,n,t[_],i,u,g,1,!0))}),[e,s]}
|
|
3368
3368
|
/**
|
|
3369
3369
|
@module lineBuffer
|
|
3370
3370
|
@desc Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3374,7 +3374,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3374
3374
|
@param {Object} [config]
|
|
3375
3375
|
@param {Number} [buffer] Defaults to the radius of the largest Circle.
|
|
3376
3376
|
@private
|
|
3377
|
-
*/,Line:function({data:t,x:i,y:e,x2:s,y2:h}){let n=s?"x2":"x",
|
|
3377
|
+
*/,Line:function({data:t,x:i,y:e,x2:s,y2:h}){let n=s?"x2":"x",r=h?"y2":"y";return s="x"===this._discrete?e:i,h=s.domain().slice(),"x"===this._discrete&&h.reverse(),t=t.map(t=>t["x"===this._discrete?r:n]),(t=s.invert(s(Dt.max(t))+("x"===this._discrete?-10:10)))>h[1]&&(h[1]=t),"x"===this._discrete&&h.reverse(),s.domain(h),[i,e]}
|
|
3378
3378
|
/**
|
|
3379
3379
|
@module rectBuffer
|
|
3380
3380
|
@desc Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3384,7 +3384,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3384
3384
|
@param {Object} [config]
|
|
3385
3385
|
@param {Number} [buffer] Defaults to the width/height of the largest Rect.
|
|
3386
3386
|
@private
|
|
3387
|
-
*/,Rect:function({data:t,x:e,y:s,x2:i,y2:h,yScale:n,xScale:
|
|
3387
|
+
*/,Rect:function({data:t,x:e,y:s,x2:i,y2:h,yScale:n,xScale:r,config:a}){e=e.copy(),s=s.copy();let o=i?"x2":"x",l=h?"y2":"y",_=e.domain().slice(),d=s.domain().slice(),g=e.range(),c=s.range();return!e.invert&&e.padding&&qt(e,t,this._discrete),!s.invert&&s.padding&&qt(s,t,this._discrete),(e.invert||s.invert)&&t.forEach(t=>{var i;e.invert&&(i=a.width(t.data,t.i),_=p(e,r,t[o],i,g,_,0,!1),_=p(e,r,t[o],i,g,_,1,!1)),s.invert&&(i=a.height(t.data,t.i),d=p(s,n,t[l],i,c,d,0,!0),d=p(s,n,t[l],i,c,d,1,!0))}),[e,s]}};
|
|
3388
3388
|
/**
|
|
3389
3389
|
@desc Logic for determining default sizes of shapes using the sizeScaleD3 internal function.
|
|
3390
3390
|
@private
|
|
@@ -3404,7 +3404,7 @@ this._tooltipClass.data([h||e]).footer(!!o&&(r?this._solo.length&&!l||_?s("Click
|
|
|
3404
3404
|
/**
|
|
3405
3405
|
@desc Logic for determining default sum of shapes using the stackSum function used in d3Shape.
|
|
3406
3406
|
@private
|
|
3407
|
-
*/function ii(a
|
|
3407
|
+
*/function ii(r,a){var o;if(0<(o=r.length)){let i,e,s,h,n;var l=r[a[0]].length;for(let t=0;t<l;++t)for(n=h=0,s=0;s<o;++s)0<=(e=(i=r[a[s]][t])[1]-i[0])?(i[0]=n,i[1]=n+=e):e<0?(i[1]=h,i[0]=h+=e):i[0]=n}}
|
|
3408
3408
|
/**
|
|
3409
3409
|
* Determines if a Bar label should be placed outside of the Bar.
|
|
3410
3410
|
* @param {@} d
|
|
@@ -3428,20 +3428,20 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3428
3428
|
/**
|
|
3429
3429
|
Extends the draw behavior of the abstract Viz class.
|
|
3430
3430
|
@private
|
|
3431
|
-
*/_draw(
|
|
3432
|
-
/* Determines whether or not any of the x or y axes are a "time" axis. */var
|
|
3431
|
+
*/_draw(rt){if(this._filteredData.length||this._annotations.length){
|
|
3432
|
+
/* Determines whether or not any of the x or y axes are a "time" axis. */var at=!!this._time&&this._time(this._filteredData[0],0);let s=this._x2Time=at&&this._x2(this._filteredData[0],0)===at,h=this._xTime=at&&this._x(this._filteredData[0],0)===at,E=this._y2Time=at&&this._y2(this._filteredData[0],0)===at,j=this._yTime=at&&this._y(this._filteredData[0],0)===at,H=h||s||j||E,R=(t,i)=>`${!H&&this._time?this._time(t,i):"time"}_`+(this._stacked?""+(1<this._groupBy.length?this._ids(t,i).slice(0,-1).join("_"):"group"):""+this._ids(t,i).join("_"));var at=(t,i)=>{t={__d3plus__:!0,data:t,group:R(t,i),i:i,hci:this._confidence&&this._confidence[1]&&this._confidence[1](t,i),id:this._ids(t,i).slice(0,this._drawDepth+1).join("_"),lci:this._confidence&&this._confidence[0]&&this._confidence[0](t,i),shape:this._shape(t,i),x:h?Pt.date(this._x(t,i)):this._x(t,i),x2:s?Pt.date(this._x2(t,i)):this._x2(t,i),y:j?Pt.date(this._y(t,i)):this._y(t,i),y2:E?Pt.date(this._y2(t,i)):this._y2(t,i)};return t.discrete="Bar"===t.shape?t[this._discrete]+"_"+t.group:""+t[this._discrete],t.id="Bar"===t.shape?t.id+"_"+t[this._discrete]:t.id,t};let r=this._formattedData=this._filteredData.map(at),a=this._axisPersist?this._data.map(at):r;this._size?(at=Dt.extent(a,t=>this._size(t.data)),this._sizeScaleD3=$t["scale"+this._sizeScale.charAt(0).toUpperCase()+this._sizeScale.slice(1)]().domain(at).range([at[0]===at[1]?this._sizeMax:Dt.min([this._sizeMax/2,this._sizeMin]),this._sizeMax])):this._sizeScaleD3=()=>this._sizeMin;var at=a.some(t=>void 0!==t.x2),ot=a.some(t=>void 0!==t.y2);let t=this._height-this._margin.top-this._margin.bottom,c=this._discrete?"x"===this._discrete?"y":"x":void 0,F=this._discrete?"x"===this._discrete?"y2":"x2":void 0,W=[c,F].filter(t=>t),i=this._select,e=this._transition,x=this._width-this._margin.left-this._margin.right;
|
|
3433
3433
|
/**
|
|
3434
3434
|
* @desc Returns all unique values for a given axis.
|
|
3435
3435
|
* @param {String} axis
|
|
3436
3436
|
* @returns {Array}
|
|
3437
3437
|
* @private
|
|
3438
|
-
*/var lt=At.bind(this)("x"),_t=At.bind(this)("x2"),dt=At.bind(this)("y"),gt=At.bind(this)("y2");let N,u,p,f;if(this._stacked){var ct=
|
|
3438
|
+
*/var lt=At.bind(this)("x"),_t=At.bind(this)("x2"),dt=At.bind(this)("y"),gt=At.bind(this)("y2");let N,u,p,f;if(this._stacked){var ct=a.filter(t=>["Area","Bar"].includes(t.shape));let h=Ot.nest().key(t=>t.group).entries(ct).reduce((t,i)=>(t[i.key]||(t[i.key]=0),t[i.key]+=Dt.sum(i.values,t=>t[c]),t),{}),e=(a.sort((t,i)=>{var e,s;return this[`_${this._discrete}Sort`]?this[`_${this._discrete}Sort`](t.data,i.data):(e=t[this._discrete])-(s=i[this._discrete])!=0?e-s:t.group!==i.group?h[i.group]-h[t.group]:i[c]-t[c]}),N=Array.from(new Set(a.map(t=>t.discrete))),f=Array.from(new Set(a.map(t=>t.id))),(p=Ot.nest().key(t=>t.discrete).entries(a).map(t=>t.values)).forEach(s=>{let h=Array.from(new Set(s.map(t=>t.id)));h.length<f.length&&f.forEach(i=>{var t,e;h.includes(i)||"Area"===(t=a.filter(t=>t.id===i)[0]).shape&&(e=R(t.data,t.i),e={__d3plus__:!0,data:t.data,discrete:"Bar"===t.shape?s[0][this._discrete]+"_"+e:""+s[0][this._discrete],group:e,id:t.id,ids:i,shape:t.shape,[this._discrete]:s[0][this._discrete],[c]:0},r.push(e))})}),this[`_${this._discrete}Sort`]?r.sort((t,i)=>this[`_${this._discrete}Sort`](t.data,i.data)):r.sort((t,i)=>t[this._discrete]-i[this._discrete]),this._stackOrder);e instanceof Array?f.sort((t,i)=>e.indexOf(t)-e.indexOf(i)):e===Et.stackOrderNone&&f.sort((t,i)=>t.localeCompare(i)),p=Et.stack().keys(f).offset(this._stackOffset).order(e instanceof Array?Et.stackOrderNone:e).value((t,i)=>{t=t.filter(t=>t.id===i);return t.length?t[0][c]:0})(p);ct="x"===this._discrete?lt:dt;u={[this._discrete]:this[`_${this._discrete}Time`]?Dt.extent(ct):ct,[c]:[Dt.min(p.map(t=>Dt.min(t.map(t=>t[0])))),Dt.max(p.map(t=>Dt.max(t.map(t=>t[1]))))]}}else{let e=this._discrete||"x";this[`_${this._discrete}Sort`]?a.sort((t,i)=>this[`_${this._discrete}Sort`](t.data,i.data)):a.sort((t,i)=>t[e]-i[e]),u={x:!h&&"x"===this._discrete||this._xSort?lt:Dt.extent(lt),x2:!s&&"x"===this._discrete||this._x2Sort?_t:Dt.extent(_t),y:!j&&"y"===this._discrete||this._ySort?dt:Dt.extent(dt),y2:!E&&"y"===this._discrete||this._y2Sort?gt:Dt.extent(gt)}}
|
|
3439
3439
|
/**
|
|
3440
3440
|
* Determins default scale type and domain for a given axis.
|
|
3441
3441
|
* @param {String} axis
|
|
3442
3442
|
* @private
|
|
3443
|
-
*/let[I,m,q,G]=Bt.bind(this)("x"),[V,y,Y,K]=Bt.bind(this)("y");ct=(i,t)=>{var e,s=this[`_${i}Config`].scale;return"auto"===s?this._discrete===i?t:(e=
|
|
3444
|
-
/** */function t(e,s,h){if(e.defaultY||(e.defaultY=this._yAxis._getPosition(e.value)),s){var n=h[s-1],{fontSize:
|
|
3443
|
+
*/let[I,m,q,G]=Bt.bind(this)("x"),[V,y,Y,K]=Bt.bind(this)("y");ct=(i,t)=>{var e,s=this[`_${i}Config`].scale;return"auto"===s?this._discrete===i?t:(e=a.map(t=>t[i]),3<Dt.deviation(e)/Dt.mean(e)?"log":"linear"):s||t};let n=this._yConfigScale=ct("y",y).toLowerCase(),o=this._y2ConfigScale=ct("y2",K).toLowerCase(),l=this._xConfigScale=ct("x",m).toLowerCase(),_=this._x2ConfigScale=ct("x2",G).toLowerCase(),b=(u={x:I,x2:q||I,y:V,y2:Y||V},Object.keys(u).forEach(i=>{"log"===this[`_${i}ConfigScale`]&&u[i].includes(0)&&(Dt.min(u[i])<0?u[i][1]=Dt.max(r.map(t=>t[i]).filter(t=>![NaN,void 0,!1].includes(t))):u[i][0]=Dt.min(a.map(t=>t[i]).filter(t=>![NaN,void 0,!1].includes(t))))}),W.forEach(t=>{var i;this[`_${t}Config`].domain?(i=this[`_${t}Config`].domain,"x"===this._discrete&&i.reverse(),u[t]=i):t&&void 0!==this._baseline&&(i=this._baseline,u[t]&&u[t][0]>i?u[t][0]=i:u[t]&&u[t][1]<i&&(u[t][1]=i))}),$t["scale"+m]().domain(u.x).range(Dt.range(0,1+x,x/(u.x.length-1)))),U=$t["scale"+G]().domain(u.x2).range(Dt.range(0,1+x,x/(u.x2.length-1))),v=$t["scale"+y]().domain(u.y.reverse()).range(Dt.range(0,1+t,t/(u.y.length-1))),X=$t["scale"+K]().domain(u.y2.reverse()).range(Dt.range(0,1+t,t/(u.y2.length-1)));ct=Ot.nest().key(t=>t.shape).entries(r).sort((t,i)=>this._shapeSort(t.key,i.key));"Point"!==("x"===this._discrete?y:m)&&Ot.nest().key(t=>t.shape).entries(a).forEach(t=>{var i;["Bar","Box"].includes(t.key)&&qt("x"===this._discrete?b:v,r,this._discrete),this._buffer[t.key]&&(i=this._buffer[t.key].bind(this)({data:t.values,x:b,y:v,yScale:n,xScale:l,config:this._shapeConfig[t.key]}),b=i[0],v=i[1],i=this._buffer[t.key].bind(this)({data:t.values,x:U,y:X,yScale:o,xScale:_,x2:!0,y2:!0,config:this._shapeConfig[t.key]}),U=i[0],X=i[1])});let C=b.domain(),J=U.domain(),w=v.domain(),d=X.domain();var ut={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},_t=at?{data:_t}:ut,gt=ot?{data:gt}:ut,ut=("x"!==this._discrete||this._width>this._discreteCutoff)&&this._width>this._xCutoff,pt=("y"!==this._discrete||this._height>this._discreteCutoff)&&this._height>this._yCutoff,dt={data:dt,locale:this._locale,rounding:this._yDomain?"none":"outside",scalePadding:v.padding?v.padding():0},ft=(!ut&&pt&&(dt.barConfig={stroke:"transparent"},dt.tickSize=0,dt.shapeConfig={labelBounds:(t,i)=>{var{width:t,y:e}=t.labelBounds,s=this._height/2;return{x:i?-s:0,y:e,width:t,height:s}},labelConfig:{padding:0,rotate:0},labelRotation:!1}),Pt.elem("g.d3plus-plot-test",{enter:{opacity:0},parent:this._select})),mt=jt.bind(this)(this._shapeConfig,"shape","Bar");let Q=void 0!==mt.label?"function"==typeof mt.label?mt.label:Ht(mt.label):this._drawLabel,g=a.map(t=>Q(t.data,t.i)).filter(t=>"number"==typeof t||t).map(String),S=Lt.unique(a.map(t=>t.x2)),k=(S="Point"===G&&S.every(t=>g.includes(""+t))?[]:null,Lt.unique(a.map(t=>t.x))),Z=(k="Point"===m&&k.every(t=>g.includes(""+t))?[]:null,Lt.unique(a.map(t=>t.y2))),z=(Z="Point"===K&&Z.every(t=>g.includes(""+t))?[]:null,Lt.unique(a.map(t=>t.y)));z="Point"===y&&z.every(t=>g.includes(""+t))?[]:null,pt&&this._yTest.domain(w).height(t).maxSize(x/2).range([void 0,void 0]).select(ft.node()).ticks(z).width(x).config(dt).config(this._yConfig).scale(n).render();var mt=this._yTest.outerBounds(),yt=mt.width?mt.width+this._yTest.padding():void 0,xt=(ot&&this._y2Test.domain(d).height(t).range([void 0,void 0]).select(ft.node()).ticks(Z).width(x).config(dt).config(gt).config(this._y2Config).scale(o).render(),this._y2Test.outerBounds()),bt=xt.width?xt.width+this._y2Test.padding():void 0,lt={data:lt,locale:this._locale,rounding:this._xDomain?"none":"outside",scalePadding:b.padding?b.padding():0};!pt&&ut&&(lt.barConfig={stroke:"transparent"},lt.tickSize=0,lt.shapeConfig={labelBounds:(t,i)=>{var{height:t,y:e}=t.labelBounds,s=this._width/2;return{x:i?-s:0,y:e,width:s,height:t}},labelConfig:{padding:0,rotate:0,textAnchor:t=>k&&t.id===k[0]?"start":"end"},labelRotation:!1});let M=void 0;ut&&this._xTest.domain(C).height(t).maxSize(t/2).range([void 0,M]).select(ft.node()).ticks(k).width(x).config(lt).config(this._xConfig).scale(l).render();let tt,A=[],it=this._lineLabels&&!ot;if(it){var vt=r.filter(t=>"Line"===t.shape&&("function"!=typeof this._lineLabels||this._lineLabels(t.data,t.i))),vt=Ot.nest().key(t=>t.id).entries(vt);if(vt.length){var Ct=jt.bind(this)(this._shapeConfig,"shape","Line"),wt=(Kt.config(Ct),Kt.labelConfig());let d=void 0!==wt.fontColor?wt.fontColor:Ut.fontColor(),g=void 0!==wt.fontSize?wt.fontSize:Ut.fontSize(),c=void 0!==wt.fontWeight?wt.fontWeight:Ut.fontWeight(),u=void 0!==wt.fontFamily?wt.fontFamily:Ut.fontFamily(),p=void 0!==wt.padding?wt.padding:Ut.padding(),f=Ct.label||this._drawLabel,m=t=>("log"===l&&0===t&&(t=C[0]<0?this._xTest._d3Scale.domain()[1]:this._xTest._d3Scale.domain()[0]),this._xTest._getPosition.bind(this._xTest)(t)),y=t=>("log"===n&&0===t&&(t=w[0]<0?this._yTest._d3Scale.domain()[1]:this._yTest._d3Scale.domain()[0]),this._yTest._getPosition.bind(this._yTest)(t)),i=(A=vt.map(t=>{let i=t.values[t.values.length-1],e;for(;i.__d3plus__&&i.data;)i=i.data,e=i.i;var s="function"==typeof f?f(i,e):f,h="function"==typeof d?d(i,e):d,n="function"==typeof g?g(i,e):g,r="function"==typeof c?c(i,e):c;let a="function"==typeof u?u(i,e):u;a instanceof Array&&(a=a.map(t=>`'${t}'`).join(", "));var o="function"==typeof p?p(i,e):p,s=Pt.textWidth(s,{"font-size":n,"font-family":a,"font-weight":r}),r=t.values.map(t=>[m(t.x),y(t.y)]);let l=Dt.max(t.values.map(t=>m(t.x)));var _=t.values.find(t=>m(t.x)===l).y;return{id:t.key,labelWidth:s+2*o,spaceNeeded:s+4*o,value:_,yEstimate:y(_),padding:o,fontSize:n,fontColor:h,maxX:l,xValue:Dt.max(t.values,t=>t.x),coords:r}}).sort((t,i)=>w[1]>w[0]?t.value-i.value:i.value-t.value).filter((t,i,e)=>{let{fontSize:s,id:h,labelWidth:n,maxX:r,yEstimate:a}=t;return 0===e.filter(i=>i.id!==h&&i.coords.some(t=>(t[0]>r||t[0]===r&&i.maxX!==r)&&t[0]<=r+n&&t[1]<=a+.75*s&&t[1]>=a-.75*s)).length}),Dt.max(A,t=>t.maxX));tt=Dt.max(A.map(t=>t.labelWidth));wt=i===this._xTest._getRange.bind(this._xTest)()[1]?Dt.max(A.filter(t=>t.maxX===i),t=>t.spaceNeeded):0;wt&&(Ct=Dt.min([wt,x/4]),M=x-Ct-this._margin.right)}}ut&&M&&this._xTest.domain(C).height(t).maxSize(t/2).range([void 0,M]).select(ft.node()).ticks(k).width(x).config(lt).config(this._xConfig).scale(l).render(),at&&this._x2Test.domain(J).height(t).range([void 0,M]).select(ft.node()).ticks(S).width(x).config(lt).tickSize(0).config(_t).config(this._x2Config).scale(_).render();vt=this._xTest._getRange(),wt=this._x2Test._getRange(),Ct=this._x2Test.outerBounds();let B=at?Ct.height+this._x2Test.padding():0;var Ct=Dt.max([yt,vt[0],wt[0]]),St=(ut&&this._xTest.range([Ct,void 0]).render(),pt?this._yTest.shapeConfig().labelConfig.fontSize()/2:0),kt=Dt.max([bt,x-vt[1],x-wt[1]]),zt=this._xTest.outerBounds().height+(pt?this._xTest.padding():0),rt=(this._padding.left+=Ct,this._padding.right+=kt,this._padding.bottom+=zt,this._padding.top+=B+St,super._draw(rt),this._margin.left+this._margin.right),Mt=this._margin.top+this._margin.bottom;let P=[B,t-(zt+St+Mt)],D=(pt&&this._yTest.domain(w).height(t).maxSize(x/2).range(P).select(ft.node()).ticks(z).width(x).config(dt).config(this._yConfig).scale(n).render(),yt=(mt=this._yTest.outerBounds()).width?mt.width+this._yTest.padding():void 0,Ct=Dt.max([yt,vt[0],wt[0]]),ot&&this._y2Test.config(dt).domain(d).gridSize(0).height(t).range(P).select(ft.node()).width(x-Dt.max([0,kt-bt])).title(!1).config(this._y2Config).config(gt).scale(o).render(),bt=(xt=this._y2Test.outerBounds()).width?xt.width+this._y2Test.padding():void 0,kt=Dt.max([0,bt,x-vt[1],x-wt[1]]),[Ct,x-(kt+rt)]);mt=Pt.elem("g.d3plus-plot-background",{parent:i,transition:e}),ft=`translate(${this._margin.left}, ${this._margin.top+B+St})`,xt=`translate(${this._margin.left}, ${this._margin.top+St})`,vt=Pt.elem("g.d3plus-plot-x-axis",{parent:i,transition:e,enter:{transform:ft},update:{transform:ft,opacity:ut?1:0}}),wt=at&&Pt.elem("g.d3plus-plot-x2-axis",{parent:i,transition:e,enter:{transform:xt},update:{transform:xt}}),rt=`translate(${this._margin.left+(yt<Ct?Ct-yt:0)}, ${this._margin.top+St})`,ut=Pt.elem("g.d3plus-plot-y-axis",{parent:i,transition:e,enter:{transform:rt},update:{transform:rt,opacity:pt?1:0}}),xt=`translate(-${this._margin.right}, ${this._margin.top+St})`,Ct=ot&&Pt.elem("g.d3plus-plot-y2-axis",{parent:i,transition:e,enter:{transform:xt},update:{transform:xt}});this._xAxis.domain(C).height(t-(B+St+Mt)).maxSize(t/2).range(D).select(vt.node()).ticks(k).width(x).config(lt).config(this._xConfig).scale(l).render(),at&&this._x2Axis.domain(J).height(t-(zt+St+Mt)).range(D).select(wt.node()).ticks(S).width(x).config(lt).config(_t).config(this._x2Config).scale(_).render(),this._xFunc=b=(t,i)=>("x2"===i?("log"===_&&0===t&&(t=J[0]<0?this._x2Axis._d3Scale.domain()[1]:this._x2Axis._d3Scale.domain()[0]),this._x2Axis._getPosition.bind(this._x2Axis)):("log"===l&&0===t&&(t=C[0]<0?this._xAxis._d3Scale.domain()[1]:this._xAxis._d3Scale.domain()[0]),this._xAxis._getPosition.bind(this._xAxis)))(t),P=[this._xAxis.outerBounds().y+B,t-(zt+St+Mt)],this._yAxis.domain(w).height(t).maxSize(x/2).range(P).select(ut.node()).ticks(z).width(D[D.length-1]).config(dt).config(this._yConfig).scale(n).render(),ot&&this._y2Axis.config(dt).domain(ot?d:w).gridSize(0).height(t).range(P).select(Ct.node()).width(x-Dt.max([0,kt-bt])).title(!1).config(this._y2Config).config(gt).scale(o).render();let et={},O=(A&&(Ot.nest().key(t=>t.xValue).entries(A).forEach(({values:t})=>{var i=Dt.max(t.map(t=>t.fontSize));let l=Dt.range(P[0],P[1],i).reverse(),_=(P[1]-P[0])/8;t.forEach(
|
|
3444
|
+
/** */function t(e,s,h){if(e.defaultY||(e.defaultY=this._yAxis._getPosition(e.value)),s){var n=h[s-1],{fontSize:r,padding:a}=e,o=e.newY||e.defaultY;let i=n.newY||n.defaultY;o-r/2-a<i&&(o=l.find(t=>t<i),e.defaultY-o<_)&&(n.newY=o,s)&&t(n,s-1,h)}}.bind(this))}),et=A.reduce((t,i)=>(i.newY&&(t[i.id]=i.newY),t),{})),this._yFunc=v=(t,i)=>"y2"===i?("log"===o&&0===t&&(t=d[1]<0?this._y2Axis._d3ScaleNegative.domain()[0]:this._y2Axis._d3Scale.domain()[1]),this._y2Axis._getPosition.bind(this._y2Axis)(t)-B):("log"===n&&0===t&&(t=w[1]<0?this._yAxis._d3ScaleNegative.domain()[0]:this._yAxis._d3Scale.domain()[1]),this._yAxis._getPosition.bind(this._yAxis)(t)-B),this._xAxis.barConfig()["stroke-width"]);O&&(O/=2),(new Ft).data([{}]).select(mt.node()).x(D[0]+(D[1]-D[0])/2).width(D[1]-D[0]).y(this._margin.top+St+P[0]+(P[1]-P[0])/2).height(P[1]-P[0]).config(this._backgroundConfig).render();yt=A.filter(t=>void 0!==t.newY);if(yt.length){rt=Pt.elem("g.d3plus-plot-connectors",{parent:i,transition:e,enter:{transform:ft},update:{transform:ft}}).node();let t=yt.map(t=>Pt.assign({x:this._xAxis._getPosition.bind(this._xAxis)(t.xValue),y:t.defaultY},t)).concat(yt.map(t=>Pt.assign({x:this._xAxis._getPosition.bind(this._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t)));(new It).config({data:t,stroke:t=>t.fontColor,x:t=>t.x,y:t=>t.y}).config(this._labelConnectorConfig).select(rt).render()}let st=Pt.elem("g.d3plus-plot-annotations",{parent:i,transition:e,enter:{transform:ft},update:{transform:ft}}).node();pt=Pt.elem("g.d3plus-plot-shapes",{parent:i,transition:e,enter:{transform:ft},update:{transform:ft}}).node();let ht=Pt.elem("g.d3plus-plot-annotations-front",{parent:i,transition:e,enter:{transform:ft},update:{transform:ft}}).node(),L=(Object.keys(this._previousAnnotations).forEach(i=>{let e="front"===i?ht:st;var t=this._annotations.filter(t=>"back"===i&&!t.layer||t.layer===i);let s=t.map(t=>t.shape);t.forEach(t=>{(new Wt[t.shape]).duration(this._duration).config(t).config({x:t=>t.x2?b(t.x2,"x2"):b(t.x),x0:"x"===this._discrete?t=>t.x2?b(t.x2,"x2"):b(t.x):b(u.x[0]),x1:"x"===this._discrete?null:t=>t.x2?b(t.x2,"x2"):b(t.x),y:t=>t.y2?v(t.y2,"y2"):v(t.y),y0:"y"===this._discrete?t=>t.y2?v(t.y2,"y2"):v(t.y):v(u.y[1])-O,y1:"y"===this._discrete?null:t=>t.y2?v(t.y2,"y2"):v(t.y)-O}).select(e).render()}),this._previousAnnotations[i].filter(t=>!s.includes(t)).forEach(t=>{(new Wt[t]).data([]).select(e).render()}),this._previousAnnotations[i]=s}),this._discrete||"x"),T={discrete:this._discrete,duration:this._duration,label:t=>this._drawLabel(t.data,t.i),select:pt,x:t=>void 0!==t.x2?b(t.x2,"x2"):b(t.x),x0:"x"===L?t=>t.x2?b(t.x2,"x2"):b(t.x):b("number"==typeof this._baseline?this._baseline:u.x[0]),x1:"x"===L?null:t=>t.x2?b(t.x2,"x2"):b(t.x),y:t=>void 0!==t.y2?v(t.y2,"y2"):v(t.y),y0:"y"===L?t=>t.y2?v(t.y2,"y2"):v(t.y):v("number"==typeof this._baseline?this._baseline:u.y[1])-O,y1:"y"===L?null:t=>t.y2?v(t.y2,"y2"):v(t.y)-O},nt=Object.keys(this._on),$=(ct.forEach(n=>{var r=Object.assign({},T);if(this._stacked&&["Area","Bar"].includes(n.key)){let s="x"===c?b:v;r[""+c]=r[c+"0"]=t=>{var i=f.indexOf(t.id),e=N.indexOf(t.discrete),t=t[c]<0?1:0;return 0<=i?s(p[i][e][t]):s(u[c]["x"===c?0:1])},r[c+"1"]=t=>{var i=f.indexOf(t.id),e=N.indexOf(t.discrete),t=t[c]<0?0:1;return 0<=i?s(p[i][e][t]):s(u[c]["x"===c?0:1])}}var a=(new Wt[n.key]).config(r).data(n.values);if("Bar"===n.key){let t,i="x"===this._discrete?b:v;var r="x"===this._discrete?m:y,o="x"===this._discrete?C:w,l="x"===this._discrete?D:P;t="Point"!==r&&2===o.length?((r=Array.from(new Set(n.values.map(t=>i(t[this._discrete]))))).unshift(l[0]-r[0]-l[0]),r.push(l[1]+l[1]-r[r.length-1]),r.reduce((t,i,e,s)=>t=e&&(i=Math.abs(i-s[e-1]))<t?i:t,1/0)):1<o.length?i(o[1])-i(o[0]):l[l.length-1]-l[0],this._groupPadding<t&&(t-=this._groupPadding);let s=t||1;r=Ot.nest().key(t=>t[this._discrete]).key(t=>t.group).entries(n.values),o=Dt.merge(r.map(t=>t.values.map(t=>t.key)));let h=Array.from(new Set(o));if(1===Dt.max(r.map(t=>t.values.length)))a[this._discrete]((t,i)=>T[this._discrete](t,i));else{s=(s-this._barPadding*h.length-1)/h.length;l=t/2-s/2;let e=$t.scaleLinear().domain([0,h.length-1]).range([-l,l]);a[this._discrete]((t,i)=>T[this._discrete](t,i)+e(h.indexOf(t.group)))}a.width(s),a.height(s)}else if("Line"===n.key){if(a.duration(1.5*x),this._confidence){o=Object.assign({},T),r=this._discrete||"x";let i="x"===r?"y":"x",e="x"===r?v:b;o[i+"0"]=t=>e(this._confidence[0]?t.lci:t[i]),o[i+"1"]=t=>e(this._confidence[1]?t.hci:t[i]);l=(new Nt).config(o).data(n.values),r=Object.assign(this._shapeConfig,this._confidenceConfig);l.config(Pt.assign(jt.bind(this)(r,"shape","Line"),jt.bind(this)(r,"shape","Area"))).render(),this._shapes.push(l)}a.config({discrete:T.discrete||"x",label:!!it&&((e,t)=>{if("function"!=typeof this._lineLabels||this._lineLabels(e.data,e.i)){var s=A.find(t=>t.id===e.id);if(s){let i=s.newY||s.defaultY;s=A.filter(t=>t.newY===i);return 1<s.length?s[0].id===e.id&&`+${Tt.formatAbbreviate(s.length,this._locale)} `+this._translate("more"):this._drawLabel(e,t)}}return!1}),labelBounds:!!it&&((t,i,e)=>{var[s,h]=e.points[0],[e,n]=e.points[e.points.length-1],r=this._height/4;return{x:e-s,y:n-h-r/2-(et[t.id]?n-et[t.id]:0),width:tt,height:r}})})}let _=nt.filter(t=>t.includes("."+n.key)),d=nt.filter(t=>!t.includes(".")),g=nt.filter(t=>t.includes(".shape"));for(let h=0;h<d.length;h++)a.on(d[h],(t,i,e,s)=>this._on[d[h]](t.data,t.i,e,s));for(let h=0;h<g.length;h++)a.on(g[h],(t,i,e,s)=>this._on[g[h]](t.data,t.i,e,s));for(let h=0;h<_.length;h++)a.on(_[h],(t,i,e,s)=>this._on[_[h]](t.data,t.i,e,s));o=jt.bind(this)(this._shapeConfig,"shape",n.key);if(void 0===this._shapeConfig.duration&&delete o.duration,a.config(o).render(),this._shapes.push(a),"Line"===n.key){var t=(new Rt).data(this._lineMarkers?n.values:[]).config(T).config(this._lineMarkerConfig).id(t=>t.id+"_"+t.discrete);for(let h=0;h<d.length;h++)t.on(d[h],(t,i,e,s)=>this._on[d[h]](t.data,t.i,e,s));for(let h=0;h<g.length;h++)t.on(g[h],(t,i,e,s)=>this._on[g[h]](t.data,t.i,e,s));for(let h=0;h<_.length;h++)t.on(_[h],(t,i,e,s)=>this._on[_[h]](t.data,t.i,e,s));t.render(),this._shapes.push(t)}}),ct.map(t=>t.key));function At(e){let s=this[`_${e}Time`];var t=s?r:a,i=t.filter(t=>![NaN,void 0,!1].includes(t[e]));if(!i.length)return[];let h="number"==typeof i[0][e],n=this._discrete===e?Ot.nest().key(t=>t[e]).rollup(t=>1===t.length?t[0].data:Lt.merge(t.map(t=>t.data),this._aggs)).entries(i).sort((t,i)=>this[`_${e}Sort`]?this[`_${e}Sort`](t.value,i.value):(s||h?parseFloat(t.key,10):t.key)-(s||h?parseFloat(i.key,10):i.key)).map(t=>s?Pt.date(t.key):h?parseFloat(t.key,10):t.key):Lt.unique(i.sort((t,i)=>this[`_${e}Sort`]?this[`_${e}Sort`](t.data,i.data):t[e]-i[e]).map(t=>t[e]),t=>""+t);return n=this._discrete!==e.charAt(0)&&this._confidence&&(this._confidence[0]&&(n=n.concat(t.map(t=>t.lci))),this._confidence[1])?n.concat(t.map(t=>t.hci)):n}function Bt(t){var i=this[`_${t}Time`]?"Time":this._discrete===t||this[`_${t}Sort`]?"Point":"Linear",e=this[`_${t}Domain`]?this[`_${t}Domain`].slice():u[t],s=this[`_${t}2Domain`]?this[`_${t}2Domain`].slice():u[t+"2"];return"Point"!=i&&(e&&void 0===e[0]&&(e[0]=u[t][0]),e&&void 0===e[1]&&(e[1]=u[t][1]),s&&void 0===s[0]&&(s[0]=u[t+"2"][0]),s)&&void 0===s[1]&&(s[1]=u[t+"2"][1]),[e,i,s,i]}$.includes("Line")&&(this._confidence&&$.push("Area"),this._lineMarkers)&&$.push("Circle"),this._previousShapes.filter(t=>!$.includes(t)).forEach(t=>{(new Wt[t]).config(T).data([]).render()}),this._previousShapes=$}return this}
|
|
3445
3445
|
/**
|
|
3446
3446
|
@memberof Plot
|
|
3447
3447
|
@desc Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
|
|
@@ -3704,7 +3704,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3704
3704
|
@memberof Plot
|
|
3705
3705
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
3706
3706
|
@private
|
|
3707
|
-
*/constructor(){super(),this._axisPersist=!1,this._annotations=[],this._backgroundConfig={duration:0,fill:"transparent"},this._barPadding=0,this._buffer=Pt.assign({},Xt,{Bar:!1,Line:!1}),this._confidenceConfig={fill:(t,i)=>"function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke,fillOpacity:Ht(.5)},this._discreteCutoff=100,this._groupPadding=5,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=Ht("auto"),this._lineMarkerConfig={fill:(t,i)=>A.colorAssign(this._id(t,i)),r:Ht(3)},this._lineMarkers=!1,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{Area:{label:(t,i)=>!!this._stacked&&this._drawLabel(t,i),labelBounds:(t,i,e)=>{let s=E.largestRect(e.points,{angle:Dt.range(-20,20,5)});if(!(s=!s||s.height<20||s.width<50?E.largestRect(e.points,{angle:Dt.range(-80,80,5)}):s))return null;let h=Dt.min(e.points,t=>t[0]);e=Dt.max(e.points.filter(t=>t[0]===h),t=>t[1]);return{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-h,y:s.cy-s.height/2-e}},labelConfig:{fontMin:6,fontResize:!0,padding:10}},ariaLabel:(t,i)=>{let e="";return t.nested?e=""+this._drawLabel(t.data,t.i):(e=""+this._drawLabel(t,i),void 0!==this._x(t,i)&&(e+=", x: "+this._x(t,i)),void 0!==this._y(t,i)&&(e+=", y: "+this._y(t,i)),void 0!==this._x2(t,i)&&(e+=", x2: "+this._x2(t,i)),void 0!==this._y2(t,i)&&(e+=", y2: "+this._y2(t,i))),e+"."},Bar:{labelBounds(t,i,e){var s="y"===this._discrete?"width":"height",h="y"===this._discrete?"height":"width",n="x"===this._discrete.charAt(0)?"y":"x",
|
|
3707
|
+
*/constructor(){super(),this._axisPersist=!1,this._annotations=[],this._backgroundConfig={duration:0,fill:"transparent"},this._barPadding=0,this._buffer=Pt.assign({},Xt,{Bar:!1,Line:!1}),this._confidenceConfig={fill:(t,i)=>"function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke,fillOpacity:Ht(.5)},this._discreteCutoff=100,this._groupPadding=5,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=Ht("auto"),this._lineMarkerConfig={fill:(t,i)=>A.colorAssign(this._id(t,i)),r:Ht(3)},this._lineMarkers=!1,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{Area:{label:(t,i)=>!!this._stacked&&this._drawLabel(t,i),labelBounds:(t,i,e)=>{let s=E.largestRect(e.points,{angle:Dt.range(-20,20,5)});if(!(s=!s||s.height<20||s.width<50?E.largestRect(e.points,{angle:Dt.range(-80,80,5)}):s))return null;let h=Dt.min(e.points,t=>t[0]);e=Dt.max(e.points.filter(t=>t[0]===h),t=>t[1]);return{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-h,y:s.cy-s.height/2-e}},labelConfig:{fontMin:6,fontResize:!0,padding:10}},ariaLabel:(t,i)=>{let e="";return t.nested?e=""+this._drawLabel(t.data,t.i):(e=""+this._drawLabel(t,i),void 0!==this._x(t,i)&&(e+=", x: "+this._x(t,i)),void 0!==this._y(t,i)&&(e+=", y: "+this._y(t,i)),void 0!==this._x2(t,i)&&(e+=", x2: "+this._x2(t,i)),void 0!==this._y2(t,i)&&(e+=", y2: "+this._y2(t,i))),e+"."},Bar:{labelBounds(t,i,e){var s="y"===this._discrete?"width":"height",h="y"===this._discrete?"height":"width",n="x"===this._discrete.charAt(0)?"y":"x",r="y"==n,n=this._discrete.replace(this._discrete.charAt(0),n),a=this[`_${n}Axis`]._d3Scale.range(),a=Math.abs(a[1]-a[0]),n=this["_"+n](t,i)<0;return ei.bind(this)(t,i)?{[s]:a-e[s],[h]:e[h],x:r?-e.width/2:n?-a:e.width+1,y:r?n?e.height+1:-a:-e.height/2+1}:{[s]:e[s],[h]:e[h],x:r?-e.width/2:n?(this._stacked,1-e.width):-1,y:r?n?(this._stacked,1):1-e.height:-e.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):A.colorContrast("function"==typeof this._shapeConfig.fill?this._shapeConfig.fill(t,i):this._shapeConfig.fill)},fontStroke(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):"transparent"},fontStrokeWidth(t,i){return ei.bind(this)(t,i)?.1:0},padding:3,textAnchor(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0,s=s?"middle":ei.bind(this)(t,i)?e?"end":"start":e?"start":"end";return Pt.rtl()?"start"==s?"end":"end"==s?"start":s:s},verticalAlign(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0;return s?ei.bind(this)(t,i)?e?"top":"bottom":e?"bottom":"top":"middle"}}},Circle:{r:Jt.bind(this)},Line:{curve:()=>this._discrete?"monotone"+this._discrete.charAt(0).toUpperCase():"linear",fill:Ht("none"),labelConfig:{fontColor:(t,i)=>{t="function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke;return A.colorLegible(t)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:Ht(2)},Rect:{height:t=>2*Jt.bind(this)(t),width:t=>2*Jt.bind(this)(t)}}),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this._shapeSort=(t,i)=>this._shapeOrder.indexOf(t)-this._shapeOrder.indexOf(i),this._sizeMax=20,this._sizeMin=5,this._sizeScale="sqrt",this._stackOffset=ii,this._stackOrder=Zt,this._timelineConfig=Pt.assign(this._timelineConfig,{brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=s("x"),this._xKey="x",this._xAxis=(new et).align("end"),this._xTest=(new et).align("end").gridSize(0),this._xConfig={gridConfig:{stroke:t=>this._discrete&&"x"===this._discrete.charAt(0)||this._xAxis.range()[0]===this._xAxis._getPosition.bind(this._xAxis)(t.id)?"transparent":Yt.colors.gray[200]}},this._xCutoff=150,this._x2=s("x2"),this._x2Key="x2",this._x2Axis=(new nt).align("start"),this._x2Test=(new nt).align("start").gridSize(0),this._x2Config={},this._y=s("y"),this._yKey="y",this._yAxis=(new st).align("start"),this._yKey="y",this._yTest=(new st).align("start").gridSize(0),this._yConfig={gridConfig:{stroke:t=>{var i;return this._discrete&&"y"===this._discrete.charAt(0)||(i=this._yAxis.range())[i.length-1]===this._yAxis._getPosition.bind(this._yAxis)(t.id)?"transparent":Yt.colors.gray[200]}}},this._yCutoff=150,this._y2=s("y2"),this._y2Key="y2",this._y2Axis=(new ht).align("end"),this._y2Test=(new st).align("end").gridSize(0),this._y2Config={}}}class hi extends si{
|
|
3708
3708
|
/**
|
|
3709
3709
|
@memberof AreaPlot
|
|
3710
3710
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|
|
@@ -3714,12 +3714,12 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3714
3714
|
@memberof BarChart
|
|
3715
3715
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|
|
3716
3716
|
@private
|
|
3717
|
-
*/constructor(){super(),this._baseline=0,this._discrete="x";let e=this._legend;this._legend=(t,i)=>i.map(this._groupBy[this._legendDepth].bind(this)).sort().join()!==this._filteredData.map(this._groupBy[this._legendDepth].bind(this)).sort().join()&&e.bind(this)(t,i),this._shape=Ht("Bar")}}class
|
|
3717
|
+
*/constructor(){super(),this._baseline=0,this._discrete="x";let e=this._legend;this._legend=(t,i)=>i.map(this._groupBy[this._legendDepth].bind(this)).sort().join()!==this._filteredData.map(this._groupBy[this._legendDepth].bind(this)).sort().join()&&e.bind(this)(t,i),this._shape=Ht("Bar")}}class ri extends si{
|
|
3718
3718
|
/**
|
|
3719
3719
|
@memberof BoxWhisker
|
|
3720
3720
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|
|
3721
3721
|
@private
|
|
3722
|
-
*/constructor(){super(),this._discrete="x",this._shape=Ht("Box"),this._tooltipConfig=Pt.assign(this._tooltipConfig,{title:(t,i)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)i=(t=t.data).i;var e;return this._label?this._label(t,i):(e=this._ids(t,i).slice(0,this._drawDepth))[e.length-1]}})}}class
|
|
3722
|
+
*/constructor(){super(),this._discrete="x",this._shape=Ht("Box"),this._tooltipConfig=Pt.assign(this._tooltipConfig,{title:(t,i)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)i=(t=t.data).i;var e;return this._label?this._label(t,i):(e=this._ids(t,i).slice(0,this._drawDepth))[e.length-1]}})}}class ai extends si{
|
|
3723
3723
|
/**
|
|
3724
3724
|
@memberof BumpChart
|
|
3725
3725
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|
|
@@ -3769,7 +3769,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3769
3769
|
@memberof Donut
|
|
3770
3770
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
3771
3771
|
@private
|
|
3772
|
-
*/constructor(){super(),this._innerRadius=()=>Dt.min([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom])/4,this._padPixel=2}}var _i=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}];let di=Object.assign({},C,w,
|
|
3772
|
+
*/constructor(){super(),this._innerRadius=()=>Dt.min([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom])/4,this._padPixel=2}}var _i=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}];let di=Object.assign({},C,w,S);
|
|
3773
3773
|
/**
|
|
3774
3774
|
* @name findAttribution
|
|
3775
3775
|
* @param {String} url
|
|
@@ -3789,7 +3789,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3789
3789
|
/**
|
|
3790
3790
|
Extends the draw behavior of the abstract Viz class.
|
|
3791
3791
|
@private
|
|
3792
|
-
*/_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,i=this._width-this._margin.left-this._margin.right,s=(this._container=this._select.selectAll("svg.d3plus-geomap").data([0]),this._container=this._container.enter().append("svg").attr("class","d3plus-geomap").attr("opacity",0).attr("width",i).attr("height",t).attr("x",this._margin.left).attr("y",this._margin.top).style("background-color",this._ocean||"transparent").merge(this._container),this._container.transition(this._transition).attr("opacity",1).attr("width",i).attr("height",t).attr("x",this._margin.left).attr("y",this._margin.top),this._container.selectAll("rect.d3plus-geomap-ocean").data([0]));s.enter().append("rect").attr("class","d3plus-geomap-ocean").merge(s).attr("width",i).attr("height",t).attr("fill",this._ocean||"transparent"),this._tileGroup=this._container.selectAll("g.d3plus-geomap-tileGroup").data([0]),this._tileGroup=this._tileGroup.enter().append("g").attr("class","d3plus-geomap-tileGroup").merge(this._tileGroup),this._zoomGroup=this._container.selectAll("g.d3plus-geomap-zoomGroup").data([0]),this._zoomGroup=this._zoomGroup.enter().append("g").attr("class","d3plus-geomap-zoomGroup").merge(this._zoomGroup);let e=this._zoomGroup.selectAll("g.d3plus-geomap-paths").data([0]);e=e.enter().append("g").attr("class","d3plus-geomap-paths").merge(e);s=this._coordData=this._topojson?ci(this._topojson,this._topojsonKey):{type:"FeatureCollection",features:[]};this._topojsonFilter&&(s.features=s.features.filter(this._topojsonFilter));let
|
|
3792
|
+
*/_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,i=this._width-this._margin.left-this._margin.right,s=(this._container=this._select.selectAll("svg.d3plus-geomap").data([0]),this._container=this._container.enter().append("svg").attr("class","d3plus-geomap").attr("opacity",0).attr("width",i).attr("height",t).attr("x",this._margin.left).attr("y",this._margin.top).style("background-color",this._ocean||"transparent").merge(this._container),this._container.transition(this._transition).attr("opacity",1).attr("width",i).attr("height",t).attr("x",this._margin.left).attr("y",this._margin.top),this._container.selectAll("rect.d3plus-geomap-ocean").data([0]));s.enter().append("rect").attr("class","d3plus-geomap-ocean").merge(s).attr("width",i).attr("height",t).attr("fill",this._ocean||"transparent"),this._tileGroup=this._container.selectAll("g.d3plus-geomap-tileGroup").data([0]),this._tileGroup=this._tileGroup.enter().append("g").attr("class","d3plus-geomap-tileGroup").merge(this._tileGroup),this._zoomGroup=this._container.selectAll("g.d3plus-geomap-zoomGroup").data([0]),this._zoomGroup=this._zoomGroup.enter().append("g").attr("class","d3plus-geomap-zoomGroup").merge(this._zoomGroup);let e=this._zoomGroup.selectAll("g.d3plus-geomap-paths").data([0]);e=e.enter().append("g").attr("class","d3plus-geomap-paths").merge(e);s=this._coordData=this._topojson?ci(this._topojson,this._topojsonKey):{type:"FeatureCollection",features:[]};this._topojsonFilter&&(s.features=s.features.filter(this._topojsonFilter));let a=this._path=di.geoPath().projection(this._projection);var h=this._filteredData.filter((t,i)=>this._point(t,i)instanceof Array);let n=this._filteredData.filter((t,i)=>!(this._point(t,i)instanceof Array)).reduce((t,i)=>(t[this._id(i)]=i,t),{});var r=s.features.reduce((t,i)=>{var e=this._topojsonId(i);return t.push({__d3plus__:!0,data:n[e],feature:i,id:e}),t},[]);let o=$t["scale"+this._pointSizeScale.charAt(0).toUpperCase()+this._pointSizeScale.slice(1)]().domain(Dt.extent(h,(t,i)=>this._pointSize(t,i))).range([this._pointSizeMin,this._pointSizeMax]);if(!this._zoomSet){s=this._fitObject?ci(this._fitObject,this._fitKey):s;if(this._extentBounds={type:"FeatureCollection",features:this._fitFilter?s.features.filter(this._fitFilter):s.features.slice()},this._extentBounds.features=this._extentBounds.features.reduce((t,r)=>{if(r.geometry){let e={type:r.type,id:r.id,geometry:{coordinates:r.geometry.coordinates,type:r.geometry.type}};if("MultiPolygon"===r.geometry.type&&1<r.geometry.coordinates.length){let s=[],h=[],i=(r.geometry.coordinates.forEach(t=>{e.geometry.coordinates=[t],s.push(a.area(e))}),e.geometry.coordinates=[r.geometry.coordinates[s.indexOf(Dt.max(s))]],a.centroid(e)),n=(r.geometry.coordinates.forEach(t=>{e.geometry.coordinates=[t],h.push(E.pointDistance(a.centroid(e),i))}),Dt.quantile(s.reduce((t,i,e)=>(i&&t.push(s[e]/i),t),[]),.9));e.geometry.coordinates=r.geometry.coordinates.filter((t,i)=>{var e=h[i];return 0===e||s[i]/e>=n})}t.push(e)}return t},[]),!this._extentBounds.features.length&&h.length){let e=[[void 0,void 0],[void 0,void 0]];h.forEach((t,i)=>{t=this._projection(this._point(t,i));(void 0===e[0][0]||t[0]<e[0][0])&&(e[0][0]=t[0]),(void 0===e[1][0]||t[0]>e[1][0])&&(e[1][0]=t[0]),(void 0===e[0][1]||t[1]<e[0][1])&&(e[0][1]=t[1]),(void 0===e[1][1]||t[1]>e[1][1])&&(e[1][1]=t[1])}),this._extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:e.map(t=>this._projection.invert(t))}}]};s=Dt.max(h,(t,i)=>o(this._pointSize(t,i)));this._projectionPadding.top+=s,this._projectionPadding.right+=s,this._projectionPadding.bottom+=s,this._projectionPadding.left+=s}this._zoomBehavior.extent([[0,0],[i,t]]).scaleExtent([1,this._zoomMax]).translateExtent([[0,0],[i,t]]),this._zoomSet=!0}this._projection=this._projection.fitExtent(this._extentBounds.features.length?[[this._projectionPadding.left,this._projectionPadding.top],[i-this._projectionPadding.right,t-this._projectionPadding.bottom]]:[[0,0],[i,t]],this._extentBounds.features.length?this._extentBounds:{type:"Sphere"}),this._shapes.push((new B).data(r).d(t=>a(t.feature)).select(e.node()).x(0).y(0).config(jt.bind(this)(this._shapeConfig,"shape","Path")).render());let l=this._zoomGroup.selectAll("g.d3plus-geomap-pins").data([0]);l=l.enter().append("g").attr("class","d3plus-geomap-pins").merge(l);var _=(new Rt).config(jt.bind(this)(this._shapeConfig,"shape","Circle")).data(h).r((t,i)=>o(this._pointSize(t,i))).select(l.node()).sort((t,i)=>this._pointSize(i)-this._pointSize(t)).x((t,i)=>this._projection(this._point(t,i))[0]).y((t,i)=>this._projection(this._point(t,i))[1]),s=Object.keys(this._on),d=s.filter(t=>t.includes(".Circle")),g=s.filter(t=>!t.includes(".")),c=s.filter(t=>t.includes(".shape"));for(let t=0;t<g.length;t++)_.on(g[t],this._on[g[t]]);for(let t=0;t<c.length;t++)_.on(c[t],this._on[c[t]]);for(let t=0;t<d.length;t++)_.on(d[t],this._on[d[t]]);return this._shapes.push(_.render()),this}
|
|
3793
3793
|
/**
|
|
3794
3794
|
@memberof Geomap
|
|
3795
3795
|
@desc Topojson files sometimes include small geographies that negatively impact how the library determines the default zoom level (for example, a small island or territory far off the coast that is barely visible to the eye). The fitFilter method can be used to remove specific geographies from the logic used to determine the zooming.
|
|
@@ -3928,7 +3928,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3928
3928
|
@memberof Matrix
|
|
3929
3929
|
@desc Extends the draw behavior of the abstract Viz class.
|
|
3930
3930
|
@private
|
|
3931
|
-
*/_draw(o){var{rowValues:l,columnValues:_,shapeData:d}=fi.bind(this)(this._filteredData);if(l.length&&_.length){let t=this._height-this._margin.top-this._margin.bottom,e=this._select,s=this._transition,i=this._width-this._margin.left-this._margin.right;var g={opacity:0},c={opacity:1},u=i/_.length<120,p=(t,i)=>Pt.elem("g.d3plus-Matrix-"+t,Object.assign({parent:e,transition:s},i)).node(),f=(this._rowAxis.select(p("row",{enter:g,update:g})).domain(l).height(t-this._margin.top-this._margin.bottom-this._padding.bottom-this._padding.top).maxSize(i/4).width(i).config(this._rowConfig).render(),this._rowAxis.outerBounds().width),m=(this._padding.left+=f,`translate(0, ${this._margin.top})`),g=Object.assign({transform:m},g),g=(this._columnAxis.select(p("column",{enter:g,update:g})).domain(_).range([this._margin.left+this._padding.left,i-this._margin.right+this._padding.right]).height(t).maxSize(t/4).width(i).labelRotation(u).config(this._columnConfig).render(),this._columnAxis.outerBounds().height),u=(this._padding.top+=g,super._draw(o),`translate(${this._margin.left}, ${this._margin.top})`),m=`translate(0, ${this._margin.top})`,o=Object.assign({transform:m},c);this._rowAxis.select(p("row",{update:Object.assign({transform:u},c)})).height(t-this._margin.top-this._margin.bottom-this._padding.bottom).maxSize(f).range([g+this._columnAxis.padding(),void 0]).render(),this._columnAxis.select(p("column",{update:o})).range([this._margin.left+this._padding.left+this._rowAxis.padding(),i-this._margin.right+this._padding.right]).maxSize(g).render();let h=this._rowAxis._getPosition.bind(this._rowAxis),n=this._columnAxis._getPosition.bind(this._columnAxis),
|
|
3931
|
+
*/_draw(o){var{rowValues:l,columnValues:_,shapeData:d}=fi.bind(this)(this._filteredData);if(l.length&&_.length){let t=this._height-this._margin.top-this._margin.bottom,e=this._select,s=this._transition,i=this._width-this._margin.left-this._margin.right;var g={opacity:0},c={opacity:1},u=i/_.length<120,p=(t,i)=>Pt.elem("g.d3plus-Matrix-"+t,Object.assign({parent:e,transition:s},i)).node(),f=(this._rowAxis.select(p("row",{enter:g,update:g})).domain(l).height(t-this._margin.top-this._margin.bottom-this._padding.bottom-this._padding.top).maxSize(i/4).width(i).config(this._rowConfig).render(),this._rowAxis.outerBounds().width),m=(this._padding.left+=f,`translate(0, ${this._margin.top})`),g=Object.assign({transform:m},g),g=(this._columnAxis.select(p("column",{enter:g,update:g})).domain(_).range([this._margin.left+this._padding.left,i-this._margin.right+this._padding.right]).height(t).maxSize(t/4).width(i).labelRotation(u).config(this._columnConfig).render(),this._columnAxis.outerBounds().height),u=(this._padding.top+=g,super._draw(o),`translate(${this._margin.left}, ${this._margin.top})`),m=`translate(0, ${this._margin.top})`,o=Object.assign({transform:m},c);this._rowAxis.select(p("row",{update:Object.assign({transform:u},c)})).height(t-this._margin.top-this._margin.bottom-this._padding.bottom).maxSize(f).range([g+this._columnAxis.padding(),void 0]).render(),this._columnAxis.select(p("column",{update:o})).range([this._margin.left+this._padding.left+this._rowAxis.padding(),i-this._margin.right+this._padding.right]).maxSize(g).render();let h=this._rowAxis._getPosition.bind(this._rowAxis),n=this._columnAxis._getPosition.bind(this._columnAxis),r=1<l.length?h(l[1])-h(l[0]):this._rowAxis.height(),a=1<_.length?n(_[1])-n(_[0]):this._columnAxis.width();m=`translate(0, ${this._margin.top})`,u=jt.bind(this)(this._shapeConfig,"shape","Rect");this._shapes.push((new Ft).data(d).select(Pt.elem("g.d3plus-Matrix-cells",{parent:this._select,enter:{transform:m},update:{transform:m}}).node()).config({height:r-this._cellPadding,width:a-this._cellPadding,x:t=>n(t.column)+a/2,y:t=>h(t.row)+r/2}).config(u).render())}return this}
|
|
3932
3932
|
/**
|
|
3933
3933
|
@memberof Matrix
|
|
3934
3934
|
@desc The pixel padding in between each cell.
|
|
@@ -3996,7 +3996,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3996
3996
|
@memberof Matrix
|
|
3997
3997
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
3998
3998
|
@private
|
|
3999
|
-
*/constructor(){super(),this._cellPadding=2,this._column=s("column"),this._columnAxis=new o,this._columnConfig=Pt.assign({orient:"top"},mi),this._columnSort=(t,i)=>(""+t).localeCompare(""+i),this._label=(t,i)=>
|
|
3999
|
+
*/constructor(){super(),this._cellPadding=2,this._column=s("column"),this._columnAxis=new o,this._columnConfig=Pt.assign({orient:"top"},mi),this._columnSort=(t,i)=>(""+t).localeCompare(""+i),this._label=(t,i)=>a.bind(this)("row",t,i)+" / "+a.bind(this)("column",t,i);let r=this._on["mousemove.shape"];this._on["mousemove.shape"]=(t,i,e,s)=>{r(t,i,e,s);let h=a.bind(this)("row",t,i),n=a.bind(this)("column",t,i);this.hover((t,i)=>a.bind(this)("row",t,i)===h||a.bind(this)("column",t,i)===n)},this._row=s("row"),this._rowAxis=new o,this._rowConfig=Pt.assign({orient:"left"},mi),this._rowSort=(t,i)=>(""+t).localeCompare(""+i)}}
|
|
4000
4000
|
/**
|
|
4001
4001
|
* Fetches the unique ID for a data point, whether it's defined by data or nodes.
|
|
4002
4002
|
* @private
|
|
@@ -4004,7 +4004,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4004
4004
|
/**
|
|
4005
4005
|
Extends the draw behavior of the abstract Viz class.
|
|
4006
4006
|
@private
|
|
4007
|
-
*/_draw(t){super._draw(t);var t=this._duration,i=this._height-this._margin.top-this._margin.bottom,e=`translate(${this._margin.left}, ${this._margin.top})`,s=this._width-this._margin.left-this._margin.right;let h=this._filteredData.reduce((t,i,e)=>(t[this._id(i,e)]=i,t),{}),n=this._nodes.reduce((t,i,e)=>(t[xi.bind(this)(i,e)]=i,t),{}),
|
|
4007
|
+
*/_draw(t){super._draw(t);var t=this._duration,i=this._height-this._margin.top-this._margin.bottom,e=`translate(${this._margin.left}, ${this._margin.top})`,s=this._width-this._margin.left-this._margin.right;let h=this._filteredData.reduce((t,i,e)=>(t[this._id(i,e)]=i,t),{}),n=this._nodes.reduce((t,i,e)=>(t[xi.bind(this)(i,e)]=i,t),{}),r=(n=Array.from(new Set(Object.keys(h).concat(Object.keys(n)))).map((t,i)=>{var e=h[t],s=n[t];return void 0!==s&&{__d3plus__:!0,data:e||s,i:i,id:t,fx:void 0===e||isNaN(this._x(e))?this._x(s):this._x(e),fy:void 0===e||isNaN(this._y(e))?this._y(s):this._y(e),node:s,r:this._size?void 0!==e&&void 0!==this._size(e)?this._size(e):this._size(s):this._sizeMin,shape:void 0!==e&&void 0!==this._shape(e)?this._shape(e):this._shape(s)}}).filter(t=>t),this._nodeLookup=n.reduce((t,i)=>(t[i.id]=i,t),{})),a=n.map(t=>t.node);var o=this._links.map(t=>{var i=typeof t.source;return{size:this._linkSize(t),source:"number"==i?n[a.indexOf(this._nodes[t.source])]:"string"==i?r[t.source]:r[t.source.id],target:"number"==i?n[a.indexOf(this._nodes[t.target])]:"string"==i?r[t.target]:r[t.target.id]}}),l=(this._linkLookup=o.reduce((t,i)=>(t[i.source.id]||(t[i.source.id]=[]),t[i.source.id].push(i.target),t[i.target.id]||(t[i.target.id]=[]),t[i.target.id].push(i.source),t),{}),n.some(t=>void 0===t.fx||void 0===t.fy));if(l){let i=$t.scaleLinear().domain(Dt.extent(o,t=>t.size)).range([.1,.5]);var l=D.forceSimulation().force("link",D.forceLink(o).id(t=>t.id).distance(1).strength(t=>i(t.size)).iterations(4)).force("charge",D.forceManyBody().strength(-1)).stop(),_=1-Math.pow(.001,.01),_=(l.velocityDecay(0),l.alphaMin(.001),l.alphaDecay(_),l.alphaDecay(0),l.nodes(n),l.tick(100).stop(),n.map(t=>[t.vx,t.vy]));let e=0,s=0,h=0;2===_.length?e=100:2<_.length&&(l=O.polygonHull(_),_=E.largestRect(l,{verbose:!0}),e=_.angle,s=_.cx,h=_.cy),n.forEach(t=>{var i=E.pointRotate([t.vx,t.vy],Math.PI/180*e*-1,[s,h]);t.fx=i[0],t.fy=i[1]})}l=Dt.extent(n.map(t=>t.fx)),_=Dt.extent(n.map(t=>t.fy));let d=$t.scaleLinear().domain(l).range([0,s]),g=$t.scaleLinear().domain(_).range([0,i]);var l=(l[1]-l[0])/(_[1]-_[0])||1,_=s/i,c=(_<l?(c=i*_/l,g.range([(i-c)/2,i-(i-c)/2])):(c=s*l/_,d.range([(s-c)/2,s-(s-c)/2])),n.forEach(t=>{t.x=d(t.fx),t.y=g(t.fy)}),Dt.extent(n.map(t=>t.r))),u=this._sizeMax||Dt.max([1,Dt.min(Dt.merge(n.map(i=>n.map(t=>i===t?null:E.pointDistance([i.x,i.y],[t.x,t.y])))))/2]);let p=$t["scale"+this._sizeScale.charAt(0).toUpperCase()+this._sizeScale.slice(1)]().domain(c).range([c[0]===c[1]?u:Dt.min([u/2,this._sizeMin]),u]),f=d.domain(),m=g.domain();var y=f[1]-f[0],x=m[1]-m[0],b=(n.forEach(t=>{var i=p(t.r);f[0]>d.invert(t.x-i)&&(f[0]=d.invert(t.x-i)),f[1]<d.invert(t.x+i)&&(f[1]=d.invert(t.x+i)),m[0]>g.invert(t.y-i)&&(m[0]=g.invert(t.y-i)),m[1]<g.invert(t.y+i)&&(m[1]=g.invert(t.y+i))}),f[1]-f[0]),v=m[1]-m[0];u*=Dt.min([y/b,x/v]),p.range([c[0]===c[1]?u:Dt.min([u/2,this._sizeMin]),u]),d.domain(f),g.domain(m);let C=(_<l?s:i)/2;n.forEach(t=>{t.x=d(t.fx),t.fx=t.x,t.y=g(t.fy),t.fy=t.y,t.r=p(t.r)||C,t.width=2*t.r,t.height=2*t.r}),this._container=this._select.selectAll("svg.d3plus-network").data([0]),this._container=this._container.enter().append("svg").attr("class","d3plus-network").attr("opacity",0).attr("width",s).attr("height",i).attr("x",this._margin.left).attr("y",this._margin.top).style("background-color","transparent").merge(this._container),this._container.transition().duration(t).attr("opacity",1).attr("width",s).attr("height",i).attr("x",this._margin.left).attr("y",this._margin.top);y=this._container.selectAll("rect.d3plus-network-hitArea").data([0]),y.enter().append("rect").attr("class","d3plus-network-hitArea").merge(y).attr("width",s).attr("height",i).attr("fill","transparent").on("click",()=>{this._focus&&(this.active(!1),this._focus=void 0,this._zoomToBounds(null))}),this._zoomGroup=this._container.selectAll("g.d3plus-network-zoomGroup").data([0]),b=this._zoomGroup=this._zoomGroup.enter().append("g").attr("class","d3plus-network-zoomGroup").merge(this._zoomGroup),x=Dt.extent(o,t=>t.size);if(x[0]!==x[1]){let i=$t["scale"+this._linkSizeScale.charAt(0).toUpperCase()+this._linkSizeScale.slice(1)]().domain(x).range([this._linkSizeMin,p.range()[0]]);o.forEach(t=>{t.size=i(t.size)})}v=jt.bind(this)(this._shapeConfig,"edge","Path");delete v.on,this._shapes.push((new B).config(v).strokeWidth(t=>t.size).activeStyle({"stroke-width":t=>t.size}).d(t=>`M${t.source.x},${t.source.y} ${t.target.x},`+t.target.y).data(o).select(Pt.elem("g.d3plus-network-links",{parent:b,duration:t,enter:{transform:e},update:{transform:e}}).node()).render());let w={label:t=>!!(n.length<=this._dataCutoff||this._hover&&this._hover(t)||this._active&&this._active(t))&&this._drawLabel(t.data||t.node,t.i),select:Pt.elem("g.d3plus-network-nodes",{parent:b,duration:t,enter:{transform:e},update:{transform:e}}).node()};return Ot.nest().key(t=>t.shape).entries(n).forEach(t=>{this._shapes.push((new Wt[t.key]).config(jt.bind(this)(this._shapeConfig,"shape",t.key)).config(w).config(w[t.key]||{}).data(t.values).render())}),this}
|
|
4008
4008
|
/**
|
|
4009
4009
|
@memberof Network
|
|
4010
4010
|
@desc If *value* is specified, sets the hover method to the specified function and returns the current class instance.
|
|
@@ -4096,7 +4096,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4096
4096
|
@memberof Network
|
|
4097
4097
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4098
4098
|
@private
|
|
4099
|
-
*/constructor(){super(),this._links=[],this._linkSize=Ht(1),this._linkSizeMin=1,this._linkSizeScale="sqrt",this._noDataMessage=!1,this._nodeGroupBy=[s("id")],this._nodes=[],this._on["click.shape"]=(t,
|
|
4099
|
+
*/constructor(){super(),this._links=[],this._linkSize=Ht(1),this._linkSizeMin=1,this._linkSizeScale="sqrt",this._noDataMessage=!1,this._nodeGroupBy=[s("id")],this._nodes=[],this._on["click.shape"]=(t,r,i,e)=>{if(this._tooltipClass.data([]).render(),this._hover&&this._drawDepth>=this._groupBy.length-1){let n=xi.bind(this)(t,r);if(this._focus&&this._focus===n)this.active(!1),this._on.mouseenter.bind(this)(t,r,i,e),this._focus=void 0,this._zoomToBounds(null);else{this.hover(!1);t=this._linkLookup[n],r=this._nodeLookup[n];let e=[n],i=[r.x-r.r,r.x+r.r],s=[r.y-r.r,r.y+r.r],h=(t.forEach(t=>{e.push(t.id),t.x-t.r<i[0]&&(i[0]=t.x-t.r),t.x+t.r>i[1]&&(i[1]=t.x+t.r),t.y-t.r<s[0]&&(s[0]=t.y-t.r),t.y+t.r>s[1]&&(s[1]=t.y+t.r)}),this.active((t,i)=>t.source&&t.target?t.source.id===n||t.target.id===n:e.includes(xi.bind(this)(t,i))),this._focus=n,d.zoomTransform(this._container.node()));i=i.map(t=>t*h.k+h.x),s=s.map(t=>t*h.k+h.y),this._zoomToBounds([[i[0],s[0]],[i[1],s[1]]])}}},this._on["click.legend"]=(t,i,e,s)=>{var n=this._id(t),r=(r=this._ids(t))[r.length-1];if(this._hover&&this._drawDepth>=this._groupBy.length-1){if(this._focus&&this._focus===n)this.active(!1),this._focus=void 0,this._zoomToBounds(null);else{this.hover(!1);var a=n.map(t=>this._nodeLookup[t]);let e=[""+r],i=[a[0].x-a[0].r,a[0].x+a[0].r],s=[a[0].y-a[0].r,a[0].y+a[0].r],h=(a.forEach(t=>{e.push(t.id),t.x-t.r<i[0]&&(i[0]=t.x-t.r),t.x+t.r>i[1]&&(i[1]=t.x+t.r),t.y-t.r<s[0]&&(s[0]=t.y-t.r),t.y+t.r>s[1]&&(s[1]=t.y+t.r)}),this.active((t,i)=>t.source&&t.target?e.includes(t.source.id)&&e.includes(t.target.id):(t=this._ids(t,i),e.includes(""+t[t.length-1]))),this._focus=n,d.zoomTransform(this._container.node()));i=i.map(t=>t*h.k+h.x),s=s.map(t=>t*h.k+h.y),this._zoomToBounds([[i[0],s[0]],[i[1],s[1]]])}this._on.mouseenter.bind(this)(t,i,e,s),this._on["mousemove.legend"].bind(this)(t,i,e,s)}},this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let _=this._on["mousemove.shape"];this._on["mousemove.shape"]=(t,i,e,s)=>{_(t,i,e,s);let h=xi.bind(this)(t,i),n=this._linkLookup[h]||[],r=this._nodeLookup[h],a=[h],o=[r.x-r.r,r.x+r.r],l=[r.y-r.r,r.y+r.r];n.forEach(t=>{a.push(t.id),t.x-t.r<o[0]&&(o[0]=t.x-t.r),t.x+t.r>o[1]&&(o[1]=t.x+t.r),t.y-t.r<l[0]&&(l[0]=t.y-t.r),t.y+t.r>l[1]&&(l[1]=t.y+t.r)}),this.hover((t,i)=>t.source&&t.target?t.source.id===h||t.target.id===h:a.includes(""+this._ids(t,i)[this._drawDepth]))},this._sizeMin=5,this._sizeScale="sqrt",this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{ariaLabel:(t,i)=>{var e=this._size?", "+this._size(t,i):"";return this._drawLabel(t,i)+e+"."},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee"}}),this._x=s("x"),this._y=s("y"),this._zoom=!0}}let vi=(t,i=[])=>(t.values?t.values.forEach(t=>{i.push(t),vi(t,i)}):i.push(t),i);class Ci extends _{
|
|
4100
4100
|
/**
|
|
4101
4101
|
Extends the draw behavior of the abstract Viz class.
|
|
4102
4102
|
@private
|
|
@@ -4139,12 +4139,12 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4139
4139
|
@memberof Pack
|
|
4140
4140
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4141
4141
|
@private
|
|
4142
|
-
*/constructor(){super(),this._layoutPadding=1;let e=this._legend,
|
|
4142
|
+
*/constructor(){super(),this._layoutPadding=1;let e=this._legend,r=(this._legend=(t,i)=>i.length!==this._filteredData.length&&e.bind(this)(t,i),this._on.mouseenter=()=>{},this._on["mousemove.legend"]),n=(this._on["mousemove.legend"]=(e,t,i,s)=>{r(e,t,i,s);let h=this._ids(e,t),n=vi(e);this.hover(i=>(Object.keys(i).filter(t=>"value"!==t).every(t=>e[t]&&e[t].includes(i[t]))?n.push(i):h.includes(i.key)&&n.push(...vi(i,[i])),n.includes(i)))},this._on["mousemove.shape"]);this._on["mousemove.shape"]=(t,i,e,s)=>{t.__d3plusTooltip__&&n(t,i,e,s);let h=vi(t,[t]);this.hover(t=>h.includes(t))},this._pack=f.pack(),this._packOpacity=Ht(.25),this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{Circle:{label:t=>!(!t.parent||t.children)&&t.id,labelConfig:{fontResize:!0},opacity:t=>t.__d3plusOpacity__}}),this._sort=(t,i)=>i.value-t.value,this._sum=s("value")}}class wi extends _{
|
|
4143
4143
|
/**
|
|
4144
4144
|
@memberof Priestley
|
|
4145
4145
|
@desc Extends the render behavior of the abstract Viz class.
|
|
4146
4146
|
@private
|
|
4147
|
-
*/_draw(n){if(super._draw(n),this._filteredData){n=this._filteredData.map((t,i)=>({__d3plus__:!0,data:t,end:"time"===this._axisConfig.scale?Pt.date(this._end(t,i)):this._end(t,i),i:i,id:this._id(t,i),start:"time"===this._axisConfig.scale?Pt.date(this._start(t,i)):this._start(t,i)})).filter(t=>0<t.end-t.start).sort((t,i)=>t.start-i.start);let t;if(1<this._groupBy.length&&0<this._drawDepth){var
|
|
4147
|
+
*/_draw(n){if(super._draw(n),this._filteredData){n=this._filteredData.map((t,i)=>({__d3plus__:!0,data:t,end:"time"===this._axisConfig.scale?Pt.date(this._end(t,i)):this._end(t,i),i:i,id:this._id(t,i),start:"time"===this._axisConfig.scale?Pt.date(this._start(t,i)):this._start(t,i)})).filter(t=>0<t.end-t.start).sort((t,i)=>t.start-i.start);let t;if(1<this._groupBy.length&&0<this._drawDepth){var r=Ot.nest();for(let i=0;i<this._drawDepth;i++)r.key(t=>this._groupBy[i](t.data,t.i));t=r.entries(n)}else t=[{values:n}];let s=0;t.forEach(t=>{let e=[];t.values.forEach(i=>{var t=(e=e.map(t=>!(t<=i.start)&&t)).indexOf(!1);t<0?(i.lane=s+e.length,e.push(i.end)):(e[t]=i.end,i.lane=s+t)}),s+=e.length});var a={domain:[Dt.min(n,t=>t.start)||0,Dt.max(n,t=>t.end)||0],height:this._height-this._margin.top-this._margin.bottom,width:this._width-this._margin.left-this._margin.right},o=`translate(${this._margin.left}, ${this._margin.top})`,a=(this._axisTest.config(a).config(this._axisConfig).select(Pt.elem("g.d3plus-priestley-axis-test",{parent:this._select,enter:{opacity:0}}).node()).render(),this._axis.config(a).config(this._axisConfig).select(Pt.elem("g.d3plus-priestley-axis",{parent:this._select,enter:{transform:o},update:{transform:o}}).node()).render(),this._axisTest._padding);let i=this._axis._d3Scale,e=k.scaleBand().domain(Dt.range(0,s,1)).paddingInner(this._paddingInner).paddingOuter(this._paddingOuter).rangeRound([this._height-this._margin.bottom-this._axisTest.outerBounds().height-a,this._margin.top+a]),h=e.bandwidth();this._shapes.push((new Ft).data(n).duration(this._duration).height(h).label((t,i)=>this._drawLabel(t.data,i)).select(Pt.elem("g.d3plus-priestley-shapes",{parent:this._select}).node()).width(t=>{t=Math.abs(i(t.end)-i(t.start));return 2<t?t-2:t}).x(t=>i(t.start)+(i(t.end)-i(t.start))/2).y(t=>e(t.lane)+h/2).config(jt.bind(this)(this._shapeConfig,"shape","Rect")).render())}return this}
|
|
4148
4148
|
/**
|
|
4149
4149
|
@memberof Priestley
|
|
4150
4150
|
@desc If *value* is specified, sets the config method for the axis and returns the current class instance. If *value* is not specified, returns the current axis configuration.
|
|
@@ -4179,11 +4179,11 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4179
4179
|
@memberof Priestley
|
|
4180
4180
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4181
4181
|
@private
|
|
4182
|
-
*/constructor(){super(),this._axis=(new o).align("end").orient("bottom"),this._axisConfig={scale:"time"},this._axisTest=(new o).align("end").gridSize(0).orient("bottom"),this.end("end"),this._paddingInner=.05,this._paddingOuter=.05,this._shapeConfig=Pt.assign({},this._shapeConfig,{ariaLabel:(t,i)=>`${this._drawLabel(t,i)}, ${this._start(t,i)} - ${this._end(t,i)}.`}),this.start("start")}}let
|
|
4182
|
+
*/constructor(){super(),this._axis=(new o).align("end").orient("bottom"),this._axisConfig={scale:"time"},this._axisTest=(new o).align("end").gridSize(0).orient("bottom"),this.end("end"),this._paddingInner=.05,this._paddingOuter=.05,this._shapeConfig=Pt.assign({},this._shapeConfig,{ariaLabel:(t,i)=>`${this._drawLabel(t,i)}, ${this._start(t,i)} - ${this._end(t,i)}.`}),this.start("start")}}let Si=2*Math.PI;class ki extends _{
|
|
4183
4183
|
/**
|
|
4184
4184
|
Extends the draw behavior of the abstract Viz class.
|
|
4185
4185
|
@private
|
|
4186
|
-
*/_draw(t){super._draw(t);let l=this._height-this._margin.top-this._margin.bottom,_=this._width-this._margin.left-this._margin.right,d=Dt.min([l,_])/2-this._outerPadding,i=`translate(${_/2}, ${l/2})`;var t=Ot.nest().key(this._metric).entries(this._filteredData),e=Ot.nest().key(this._id).key(this._metric).entries(this._filteredData);let s=Dt.max(e.map(t=>t.values.map(t=>Dt.sum(t.values,(t,i)=>this._value(t,i)))).flat());var h=Array.from(Array(this._levels).keys()).map(t=>({id:t,r:d*((t+1)/this._levels)})),n=jt.bind(this)(this._axisConfig.shapeConfig,"shape","Circle");delete n.label,(new Rt).data(h).select(Pt.elem("g.d3plus-Radar-radial-circles",{parent:this._select,enter:{transform:i},update:{transform:i}}).node()).config(n).render();let g=t.length;var h=t.map((t,i)=>{var e=this._outerPadding,s=2*(1.4*(this._shapeConfig.labelConfig.fontSize&&this._shapeConfig.labelConfig.fontSize(t,i)||11)),h=parseInt(360-360/g*i/90,10)%4+1,n=
|
|
4186
|
+
*/_draw(t){super._draw(t);let l=this._height-this._margin.top-this._margin.bottom,_=this._width-this._margin.left-this._margin.right,d=Dt.min([l,_])/2-this._outerPadding,i=`translate(${_/2}, ${l/2})`;var t=Ot.nest().key(this._metric).entries(this._filteredData),e=Ot.nest().key(this._id).key(this._metric).entries(this._filteredData);let s=Dt.max(e.map(t=>t.values.map(t=>Dt.sum(t.values,(t,i)=>this._value(t,i)))).flat());var h=Array.from(Array(this._levels).keys()).map(t=>({id:t,r:d*((t+1)/this._levels)})),n=jt.bind(this)(this._axisConfig.shapeConfig,"shape","Circle");delete n.label,(new Rt).data(h).select(Pt.elem("g.d3plus-Radar-radial-circles",{parent:this._select,enter:{transform:i},update:{transform:i}}).node()).config(n).render();let g=t.length;var h=t.map((t,i)=>{var e=this._outerPadding,s=2*(1.4*(this._shapeConfig.labelConfig.fontSize&&this._shapeConfig.labelConfig.fontSize(t,i)||11)),h=parseInt(360-360/g*i/90,10)%4+1,n=Si/g*i;let r=360/g*i,a="start",o=10;2!=h&&3!=h||(o=-e-10,a="end",r+=180);h={x:o,y:-s/2,width:e,height:s};return{__d3plus__:!0,data:Lt.merge(t.values,this._aggs),i:i,id:t.key,angle:r,textAnchor:a,labelBounds:h,rotateAnchor:[-o,s/2],x:d*Math.cos(n),y:d*Math.sin(n)}}).sort((t,i)=>t.key-i.key),n=((new Ft).data(h).rotate(t=>t.angle||0).width(0).height(0).x(t=>t.x).y(t=>t.y).label(t=>t.id).labelBounds(t=>t.labelBounds).labelConfig(this._axisConfig.shapeConfig.labelConfig).select(Pt.elem("g.d3plus-Radar-text",{parent:this._select,enter:{transform:i},update:{transform:i}}).node()).render(),(new B).data(h).d(t=>`M0,0 ${-t.x},`+-t.y).select(Pt.elem("g.d3plus-Radar-axis",{parent:this._select,enter:{transform:i},update:{transform:i}}).node()).config(jt.bind(this)(this._axisConfig.shapeConfig,"shape","Path")).render(),e.map(t=>{var i=t.values.map((t,i)=>{t=Dt.sum(t.values,(t,i)=>this._value(t,i))/s*d,i=Si/g*i;return{x:t*Math.cos(i),y:t*Math.sin(i)}}),e=`M ${i[0].x} ${i[0].y} ${i.map(t=>`L ${t.x} `+t.y).join(" ")} L ${i[0].x} `+i[0].y;return{arr:t.values.map(t=>Lt.merge(t.values,this._aggs)),id:t.key,points:i,d:e,__d3plus__:!0,data:Lt.merge(t.values.map(t=>Lt.merge(t.values,this._aggs)),this._aggs)}})),r=jt.bind(this)(this._shapeConfig,"shape","Path"),a=Object.keys(r.on);r.on={};for(let t=0;t<a.length;t++){let o=a[t];r.on[o]=(t,i,e,s)=>{var h=t.points.map(t=>t.x+_/2),n=t.points.map(t=>t.y+l/2);let r=j.pointer(s,this._select.node());h=h.map(t=>Math.abs(t-r[0]));let a=n.map(t=>Math.abs(t-r[1]));n=h.map((t,i)=>t+a[i]);this._on[o].bind(this)(t.arr[n.indexOf(Dt.min(n))],i,e,s)}}return this._shapes.push((new B).data(n).d(t=>t.d).select(Pt.elem("g.d3plus-Radar-items",{parent:this._select,enter:{transform:i},update:{transform:i}}).node()).config(r).render()),this}
|
|
4187
4187
|
/**
|
|
4188
4188
|
@memberof Radar
|
|
4189
4189
|
@desc Sets the config method used for the radial spokes, circles, and labels.
|
|
@@ -4220,11 +4220,11 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4220
4220
|
@memberof RadialMatrix
|
|
4221
4221
|
@desc Extends the draw behavior of the abstract Viz class.
|
|
4222
4222
|
@private
|
|
4223
|
-
*/_draw(o){let{rowValues:l,columnValues:_,shapeData:d}=fi.bind(this)(this._filteredData);if(l.length&&_.length){super._draw(o);var o=this._height-this._margin.top-this._margin.bottom,g=this._select,c=this._transition,u=this._width-this._margin.left-this._margin.right;let
|
|
4223
|
+
*/_draw(o){let{rowValues:l,columnValues:_,shapeData:d}=fi.bind(this)(this._filteredData);if(l.length&&_.length){super._draw(o);var o=this._height-this._margin.top-this._margin.bottom,g=this._select,c=this._transition,u=this._width-this._margin.left-this._margin.right;let r=Dt.min([o-100,u-200])/2,t=`translate(${u/2+this._margin.left}, ${o/2+this._margin.top})`;u=_.slice().reverse();u.unshift(u.pop());let a=u.length,i=u.map((t,i)=>{var i=i/a*zi,e=Math.round(180*i/Math.PI),s=Math.floor((e+90)/90%4+1),h=[0,180].includes(e)?-50:[2,3].includes(s)?-100:0,n=[90,270].includes(e)?-25:[2,1].includes(s)?-50:0;return{key:t,angle:e,quadrant:s,radians:i,x:r*Math.sin(i+Math.PI)+h,y:r*Math.cos(i+Math.PI)+n}});
|
|
4224
4224
|
/**
|
|
4225
4225
|
* Extracts the axis config "labels" Array, if it exists, it filters
|
|
4226
4226
|
* the column labels by the values included in the Array.
|
|
4227
|
-
*/o=this._columnConfig.labels instanceof Array?i.filter(t=>this._columnConfig.labels.includes(t.key)):i;this._columnLabels.data(o).x(t=>t.x).y(t=>t.y).text(t=>t.key).width(100).height(50).config(this._columnConfig.shapeConfig.labelConfig).select(Pt.elem("g.d3plus-RadialMatrix-columns",{parent:g,transition:c,enter:{transform:t},update:{transform:t}}).node()).render();let e=this._innerRadius(
|
|
4227
|
+
*/o=this._columnConfig.labels instanceof Array?i.filter(t=>this._columnConfig.labels.includes(t.key)):i;this._columnLabels.data(o).x(t=>t.x).y(t=>t.y).text(t=>t.key).width(100).height(50).config(this._columnConfig.shapeConfig.labelConfig).select(Pt.elem("g.d3plus-RadialMatrix-columns",{parent:g,transition:c,enter:{transform:t},update:{transform:t}}).node()).render();let e=this._innerRadius(r),s=(r-e)/l.length,h=1<i.length?i[1].radians-i[0].radians:zi,n=l.slice().reverse();u=m.arc().padAngle(this._cellPadding/r).innerRadius(t=>e+n.indexOf(t.row)*s+this._cellPadding/2).outerRadius(t=>e+(n.indexOf(t.row)+1)*s-this._cellPadding/2).startAngle(t=>i[_.indexOf(t.column)].radians-h/2).endAngle(t=>i[_.indexOf(t.column)].radians+h/2);this._shapes.push((new B).data(d).d(u).select(Pt.elem("g.d3plus-RadialMatrix-arcs",{parent:g,transition:c,enter:{transform:t},update:{transform:t}}).node()).config({id:t=>this._ids(t).join("-"),x:0,y:0}).config(jt.bind(this)(this._shapeConfig,"shape","Path")).render())}return this}
|
|
4228
4228
|
/**
|
|
4229
4229
|
@memberof RadialMatrix
|
|
4230
4230
|
@desc The pixel padding in between each cell.
|
|
@@ -4295,11 +4295,11 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4295
4295
|
@memberof RadialMatrix
|
|
4296
4296
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4297
4297
|
@private
|
|
4298
|
-
*/constructor(){super(),this._cellPadding=2,this._column=s("column"),this._columnConfig={shapeConfig:{labelConfig:{fontColor:"#000",padding:5,textAnchor:t=>[0,180].includes(t.angle)?"middle":[2,3].includes(t.quadrant)?"end":"start",verticalAlign:t=>[90,270].includes(t.angle)?"middle":[2,1].includes(t.quadrant)?"bottom":"top"}}},this._columnSort=(t,i)=>(""+t).localeCompare(""+i),this._innerRadius=t=>t/5,this._label=(t,i)=>
|
|
4298
|
+
*/constructor(){super(),this._cellPadding=2,this._column=s("column"),this._columnConfig={shapeConfig:{labelConfig:{fontColor:"#000",padding:5,textAnchor:t=>[0,180].includes(t.angle)?"middle":[2,3].includes(t.quadrant)?"end":"start",verticalAlign:t=>[90,270].includes(t.angle)?"middle":[2,1].includes(t.quadrant)?"bottom":"top"}}},this._columnSort=(t,i)=>(""+t).localeCompare(""+i),this._innerRadius=t=>t/5,this._label=(t,i)=>a.bind(this)("row",t,i)+" / "+a.bind(this)("column",t,i);let r=this._on["mousemove.shape"];this._on["mousemove.shape"]=(t,i,e,s)=>{r(t,i,e,s);let h=a.bind(this)("row",t,i),n=a.bind(this)("column",t,i);this.hover((t,i)=>a.bind(this)("row",t,i)===h||a.bind(this)("column",t,i)===n)},this._row=s("row"),this._rowSort=(t,i)=>(""+t).localeCompare(""+i),this._columnLabels=new l}}class Ai extends _{
|
|
4299
4299
|
/**
|
|
4300
4300
|
Extends the draw behavior of the abstract Viz class.
|
|
4301
4301
|
@private
|
|
4302
|
-
*/_draw(e){super._draw(e);let h=this._filteredData.reduce((t,i,e)=>(t[this._id(i,e)]=i,t),{}),o=this._nodes;!this._nodes.length&&this._links.length&&(e=Array.from(new Set(this._links.reduce((t,i)=>t.concat([i.source,i.target]),[]))),o=e.map(t=>"object"==typeof t?t:{id:t})),o=o.reduce((t,i,e)=>(t[this._nodeGroupBy?this._nodeGroupBy[this._drawDepth](i,e):this._id(i,e)]=i,t),{}),o=Array.from(new Set(Object.keys(h).concat(Object.keys(o)))).map((t,i)=>{var e=h[t],s=o[t];return void 0!==s&&{__d3plus__:!0,data:e||s,i:i,id:t,node:s,shape:void 0!==e&&void 0!==this._shape(e)?this._shape(e):this._shape(s)}}).filter(t=>t);let s=this._nodeLookup=o.reduce((t,i)=>(t[i.id]=i,t),{});e=this._links.map(e=>{var t=["source","target"].reduce((t,i)=>(t[i]="number"==typeof e[i]?o[e[i]]:s[e[i].id||e[i]],t),{});return t.size=this._linkSize(e),t});let n=e.reduce((t,i)=>(t[i.source.id]||(t[i.source.id]=[]),t[i.source.id].push(i),t[i.target.id]||(t[i.target.id]=[]),t[i.target.id].push(i),t),{}),t=this._duration,l=this._height-this._margin.top-this._margin.bottom,i=`translate(${this._margin.left}, ${this._margin.top})`,_=this._width-this._margin.left-this._margin.right,d=[],
|
|
4302
|
+
*/_draw(e){super._draw(e);let h=this._filteredData.reduce((t,i,e)=>(t[this._id(i,e)]=i,t),{}),o=this._nodes;!this._nodes.length&&this._links.length&&(e=Array.from(new Set(this._links.reduce((t,i)=>t.concat([i.source,i.target]),[]))),o=e.map(t=>"object"==typeof t?t:{id:t})),o=o.reduce((t,i,e)=>(t[this._nodeGroupBy?this._nodeGroupBy[this._drawDepth](i,e):this._id(i,e)]=i,t),{}),o=Array.from(new Set(Object.keys(h).concat(Object.keys(o)))).map((t,i)=>{var e=h[t],s=o[t];return void 0!==s&&{__d3plus__:!0,data:e||s,i:i,id:t,node:s,shape:void 0!==e&&void 0!==this._shape(e)?this._shape(e):this._shape(s)}}).filter(t=>t);let s=this._nodeLookup=o.reduce((t,i)=>(t[i.id]=i,t),{});e=this._links.map(e=>{var t=["source","target"].reduce((t,i)=>(t[i]="number"==typeof e[i]?o[e[i]]:s[e[i].id||e[i]],t),{});return t.size=this._linkSize(e),t});let n=e.reduce((t,i)=>(t[i.source.id]||(t[i.source.id]=[]),t[i.source.id].push(i),t[i.target.id]||(t[i.target.id]=[]),t[i.target.id].push(i),t),{}),t=this._duration,l=this._height-this._margin.top-this._margin.bottom,i=`translate(${this._margin.left}, ${this._margin.top})`,_=this._width-this._margin.left-this._margin.right,d=[],r=Dt.min([l,_])/2,g=r/3,c=g,u=2*g,p=s[this._center],a=(p.x=_/2,p.y=l/2,p.r=this._sizeMin?Dt.max([this._sizeMin,.65*c]):this._sizeMax?Dt.min([this._sizeMax,.65*c]):.65*c,[p]),f=[],m=(n[this._center].forEach(t=>{var i=t.source.id===this._center?t.target:t.source;i.edges=n[i.id].filter(t=>t.source.id!==this._center||t.target.id!==this._center),i.edge=t,a.push(i),f.push(i)}),f.sort((t,i)=>t.edges.length-i.edges.length),[]),y=0,x=(f.forEach(t=>{let e=t.id;t.edges=t.edges.filter(t=>!a.includes(t.source)&&t.target.id===e||!a.includes(t.target)&&t.source.id===e),y+=t.edges.length||1,t.edges.forEach(t=>{var{source:t,target:i}=t,t=i.id===e?t:i;a.push(t)})}),2*Math.PI),b=0;f.forEach((s,t)=>{let h=s.edges.length||1;var i=x/y*h;0===t&&(b-=i/2);let n=b+i/2-x/4;s.radians=n,s.x=_/2+c*Math.cos(n),s.y=l/2+c*Math.sin(n),b+=i,s.edges.forEach((t,i)=>{var t=t.source.id===s.id?t.target:t.source,e=x/y,e=n-e*h/2+e/2+e*i;t.radians=e,t.x=_/2+u*Math.cos(e),t.y=l/2+u*Math.sin(e),m.push(t)})});var v=g/2,C=g/4;let w=v/2-4,S=(v/2-4<8&&(w=Dt.min([v/2,8])),C/2-4);(S=(S=C/2-4<4?Dt.min([C/2,4]):S)>g/10?g/10:S)>w&&10<S&&(S=.75*w),w>1.5*S&&(w=1.5*S),w=Math.floor(w),S=Math.floor(S);let k;this._size?((v=Dt.extent(h,t=>t.size))[0]===v[1]&&(v[0]=0),k=$t.scaleLinear().domain(v).rangeRound([3,Dt.min([w,S])]),C=p.size,p.r=k(C)):k=$t.scaleLinear().domain([1,2]).rangeRound([w,S]),m.forEach(t=>{t.ring=2;var i=this._size?t.size:2;t.r=this._sizeMin?Dt.max([this._sizeMin,k(i)]):this._sizeMax?Dt.min([this._sizeMax,k(i)]):k(i)}),f.forEach(t=>{t.ring=1;var i=this._size?t.size:1;t.r=this._sizeMin?Dt.max([this._sizeMin,k(i)]):this._sizeMax?Dt.min([this._sizeMax,k(i)]):k(i)}),o=[p].concat(f).concat(m),f.forEach(a=>{let e=a.edge;["source","target"].forEach(i=>{e[i]=o.find(t=>t.id===e[i].id)}),d.push(e),n[a.id].forEach(r=>{let i=r.source.id===a.id?r.target:r.source;if(i.id!==p.id){let n=m.find(t=>t.id===i.id);if(n=n||f.find(t=>t.id===i.id)){r.spline=!0;let e=_/2,s=l/2,h=c+.5*(u-c);["source","target"].forEach((i,t)=>{r[i+"X"]=r[i].x+Math.cos(2===r[i].ring?r[i].radians+Math.PI:r[i].radians)*r[i].r,r[i+"Y"]=r[i].y+Math.sin(2===r[i].ring?r[i].radians+Math.PI:r[i].radians)*r[i].r,r[i+"BisectX"]=e+h*Math.cos(r[i].radians),r[i+"BisectY"]=s+h*Math.sin(r[i].radians),r[i]=o.find(t=>t.id===r[i].id),void 0===r[i].edges&&(r[i].edges={});t=(0===t?r.target:r.source).id;r[i].id===a.id?r[i].edges[t]={angle:a.radians+Math.PI,radius:g/2}:r[i].edges[t]={angle:n.radians,radius:g/2}}),d.push(r)}}})}),o.forEach(s=>{if(s.id!==this._center){var h=1.4*(this._shapeConfig.labelConfig.fontSize&&this._shapeConfig.labelConfig.fontSize(s)||11),n=2*h,r=g-s.r;let t=s.radians*(180/Math.PI),i=s.r+5,e="start";(t<-90||90<t)&&(i=-s.r-r-5,e="end",t+=180),s.labelBounds={x:i,y:-h/2,width:r,height:n},s.rotate=t,s.textAnchor=e}else s.labelBounds={x:-c/2,y:-c/2,width:c,height:c}}),this._linkLookup=e.reduce((t,i)=>(t[i.source.id]||(t[i.source.id]=[]),t[i.source.id].push(i.target),t[i.target.id]||(t[i.target.id]=[]),t[i.target.id].push(i.source),t),{});v=Dt.extent(e,t=>t.size);if(v[0]!==v[1]){let t=Dt.min(o,t=>t.r),i=$t["scale"+this._linkSizeScale.charAt(0).toUpperCase()+this._linkSizeScale.slice(1)]().domain(v).range([this._linkSizeMin,t]);e.forEach(t=>{t.size=i(t.size)})}C=jt.bind(this)(this._shapeConfig,"edge","Path");delete C.on,this._shapes.push((new B).config(C).strokeWidth(t=>t.size).id(t=>t.source.id+"_"+t.target.id).d(t=>t.spline?`M${t.sourceX},${t.sourceY}C${t.sourceBisectX},${t.sourceBisectY} ${t.targetBisectX},${t.targetBisectY} ${t.targetX},`+t.targetY:`M${t.source.x},${t.source.y} ${t.target.x},`+t.target.y).data(d).select(Pt.elem("g.d3plus-rings-links",{parent:this._select,duration:t,enter:{transform:i},update:{transform:i}}).node()).render());let z=this,M={label:t=>!!(o.length<=this._dataCutoff||this._hover&&this._hover(t)||this._active&&this._active(t))&&this._drawLabel(t.data||t.node,t.i),labelBounds:t=>t.labelBounds,labelConfig:{fontColor:t=>t.id===this._center?jt.bind(z)(z._shapeConfig,"shape",t.key).labelConfig.fontColor(t):A.colorLegible(jt.bind(z)(z._shapeConfig,"shape",t.key).fill(t)),fontResize:t=>t.id===this._center,padding:0,textAnchor:t=>s[t.id].textAnchor||jt.bind(z)(z._shapeConfig,"shape",t.key).labelConfig.textAnchor,verticalAlign:t=>t.id===this._center?"middle":"top"},rotate:t=>s[t.id].rotate||0,select:Pt.elem("g.d3plus-rings-nodes",{parent:this._select,duration:t,enter:{transform:i},update:{transform:i}}).node()};return Ot.nest().key(t=>t.shape).entries(o).forEach(t=>{this._shapes.push((new Wt[t.key]).config(jt.bind(this)(this._shapeConfig,"shape",t.key)).config(M).data(t.values).render())}),this}
|
|
4303
4303
|
/**
|
|
4304
4304
|
@memberof Rings
|
|
4305
4305
|
@desc Sets the center node to be the node with the given id.
|
|
@@ -4385,7 +4385,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
4385
4385
|
@memberof Rings
|
|
4386
4386
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4387
4387
|
@private
|
|
4388
|
-
*/constructor(){super(),this._links=[],this._linkSize=Ht(1),this._linkSizeMin=1,this._linkSizeScale="sqrt",this._noDataMessage=!1,this._nodes=[],this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let e=this._on["mousemove.shape"];this._on["mousemove.shape"]=(a,
|
|
4388
|
+
*/constructor(){super(),this._links=[],this._linkSize=Ht(1),this._linkSizeMin=1,this._linkSizeScale="sqrt",this._noDataMessage=!1,this._nodes=[],this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let e=this._on["mousemove.shape"];this._on["mousemove.shape"]=(r,a,t,i)=>{if(e(r,a,t,i),this._focus&&this._focus===r.id)this.hover(!1),this._on.mouseenter.bind(this)(r,a,t,i),this._focus=void 0;else{let t=this._nodeGroupBy&&this._nodeGroupBy[this._drawDepth](r,a)?this._nodeGroupBy[this._drawDepth](r,a):this._id(r,a),i=this._linkLookup[t],e=this._nodeLookup[t],s=[e.id],h=[e.x-e.r,e.x+e.r],n=[e.y-e.r,e.y+e.r];i.forEach(t=>{s.push(t.id),t.x-t.r<h[0]&&(h[0]=t.x-t.r),t.x+t.r>h[1]&&(h[1]=t.x+t.r),t.y-t.r<n[0]&&(n[0]=t.y-t.r),t.y+t.r>n[1]&&(n[1]=t.y+t.r)}),this.hover((t,i)=>t.source&&t.target?t.source.id===e.id||t.target.id===e.id:s.includes(this._ids(t,i)[this._drawDepth]))}},this._on["click.shape"]=t=>{this._center=t.id,
|
|
4389
4389
|
// Need to resets margins and padding because we are
|
|
4390
4390
|
// skipping over the default render method and using
|
|
4391
4391
|
// _draw directly.
|
|
@@ -4393,13 +4393,19 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4393
4393
|
/**
|
|
4394
4394
|
Extends the draw behavior of the abstract Viz class.
|
|
4395
4395
|
@private
|
|
4396
|
-
*/_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,i=this._width-this._margin.left-this._margin.right,e=(Array.isArray(this._nodes)?this._nodes:this._links.reduce((t,i)=>(t.includes(i[this._linksSource])||t.push(i[this._linksSource]),t.includes(i[this._linksTarget])||t.push(i[this._linksTarget]),t),[]).map(t=>({id:t}))).map((t,i)=>({__d3plus__:!0,data:t,i:i,id:this._nodeId(t,i),node:t,shape:"Rect"}));let s=this._nodeLookup=e.reduce((t,i,e)=>(t[i.id]=e,t),{});var h=this._links.map((e,t)=>{var i=[this._linksSource,this._linksTarget].reduce((t,i)=>(t[i]=s[e[i]],t),{});return{source:i[this._linksSource],target:i[this._linksTarget],value:this._value(e,t)}});this._linkLookup=h.reduce((t,i)=>(t[i.source]||(t[i.source]=[]),t[i.source].push(i.target),t[i.target]||(t[i.target]=[]),t[i.target].push(i.source),t),{});let n=`translate(${this._margin.left}, ${this._margin.top})`;return this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(e).links(h).size([i,t])(),this._shapes.push((new B).config(this._shapeConfig.Path).data(h).d(this._path).select(Pt.elem("g.d3plus-Links",{parent:this._select,enter:{transform:n},update:{transform:n}}).node()).render()),Ot.nest().key(t=>t.shape).entries(e).forEach(t=>{this._shapes.push((new Wt[t.key]).data(t.values).height(t=>t.y1-t.y0).width(t=>t.x1-t.x0).x(t=>(t.x1+t.x0)/2).y(t=>(t.y1+t.y0)/2).select(Pt.elem("g.d3plus-sankey-nodes",{parent:this._select,enter:{transform:n},update:{transform:n}}).node()).config(jt.bind(this)(this._shapeConfig,"shape",t.key)).render())}),this}
|
|
4396
|
+
*/_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,i=this._width-this._margin.left-this._margin.right,e=(Array.isArray(this._nodes)?this._nodes:this._links.reduce((t,i)=>(t.includes(i[this._linksSource])||t.push(i[this._linksSource]),t.includes(i[this._linksTarget])||t.push(i[this._linksTarget]),t),[]).map(t=>({id:t}))).map((t,i)=>({__d3plus__:!0,data:t,i:i,id:this._nodeId(t,i),node:t,shape:"Rect"}));let s=this._nodeLookup=e.reduce((t,i,e)=>(t[i.id]=e,t),{});var h=this._links.map((e,t)=>{var i=[this._linksSource,this._linksTarget].reduce((t,i)=>(t[i]=s[e[i]],t),{});return{source:i[this._linksSource],target:i[this._linksTarget],value:this._value(e,t)}});this._linkLookup=h.reduce((t,i)=>(t[i.source]||(t[i.source]=[]),t[i.source].push(i.target),t[i.target]||(t[i.target]=[]),t[i.target].push(i.source),t),{});let n=`translate(${this._margin.left}, ${this._margin.top})`;return this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(e).nodeSort(this._nodeSort).links(h).linkSort(this._linkSort).iterations(this._iterations).size([i,t])(),this._shapes.push((new B).config(this._shapeConfig.Path).data(h).d(this._path).select(Pt.elem("g.d3plus-Links",{parent:this._select,enter:{transform:n},update:{transform:n}}).node()).render()),Ot.nest().key(t=>t.shape).entries(e).forEach(t=>{this._shapes.push((new Wt[t.key]).data(t.values).height(t=>t.y1-t.y0).width(t=>t.x1-t.x0).x(t=>(t.x1+t.x0)/2).y(t=>(t.y1+t.y0)/2).select(Pt.elem("g.d3plus-sankey-nodes",{parent:this._select,enter:{transform:n},update:{transform:n}}).node()).config(jt.bind(this)(this._shapeConfig,"shape",t.key)).render())}),this}
|
|
4397
4397
|
/**
|
|
4398
4398
|
@memberof Sankey
|
|
4399
4399
|
@desc If *value* is specified, sets the hover method to the specified function and returns the current class instance.
|
|
4400
4400
|
@param {Function} [*value*]
|
|
4401
4401
|
@chainable
|
|
4402
4402
|
*/hover(i){return this._hover=i,this._shapes.forEach(t=>t.hover(i)),this._legend&&this._legendClass.hover(i),this}
|
|
4403
|
+
/**
|
|
4404
|
+
@memberof Sankey
|
|
4405
|
+
@desc A pass-through for the d3-sankey [iterations](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_iterations) function.
|
|
4406
|
+
@param {Number} [*value* = 6]
|
|
4407
|
+
@chainable
|
|
4408
|
+
*/iterations(t){return arguments.length?(this._iterations=t,this):this._iterations}
|
|
4403
4409
|
/**
|
|
4404
4410
|
@memberof Sankey
|
|
4405
4411
|
@desc A predefined *Array* of edges that connect each object passed to the [node](#Sankey.node) method. The `source` and `target` keys in each link need to map to the nodes in one of one way:
|
|
@@ -4409,6 +4415,12 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4409
4415
|
@param {Array} *links* = []
|
|
4410
4416
|
@chainable
|
|
4411
4417
|
*/links(t,i){return arguments.length?(Lt.addToQueue.bind(this)(t,i,"links"),this):this._links}
|
|
4418
|
+
/**
|
|
4419
|
+
@memberof Sankey
|
|
4420
|
+
@desc A pass-through for the d3-sankey [linkSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_linkSort) function.
|
|
4421
|
+
@param {Function|undefined} [*value* = undefined]
|
|
4422
|
+
@chainable
|
|
4423
|
+
*/linkSort(t){return arguments.length?(this._linkSort=t,this):this._linkSort}
|
|
4412
4424
|
/**
|
|
4413
4425
|
@memberof Sankey
|
|
4414
4426
|
@desc The key inside of each link Object that references the source node.
|
|
@@ -4447,6 +4459,12 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4447
4459
|
@param {Number} [*value* = 8]
|
|
4448
4460
|
@chainable
|
|
4449
4461
|
*/nodePadding(t){return arguments.length?(this._nodePadding=t,this):this._nodePadding}
|
|
4462
|
+
/**
|
|
4463
|
+
@memberof Sankey
|
|
4464
|
+
@desc A pass-through for the d3-sankey [nodeSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_nodeSort) function.
|
|
4465
|
+
@param {Function|undefined} [*value* = undefined]
|
|
4466
|
+
@chainable
|
|
4467
|
+
*/nodeSort(t){return arguments.length?(this._nodeSort=t,this):this._nodeSort}
|
|
4450
4468
|
/**
|
|
4451
4469
|
@memberof Sankey
|
|
4452
4470
|
@desc If *value* is specified, sets the width of the node and returns the current class instance. If *value* is not specified, returns the current nodeWidth. By default, the nodeWidth size is 30.
|
|
@@ -4466,7 +4484,7 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4466
4484
|
@memberof Sankey
|
|
4467
4485
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4468
4486
|
@private
|
|
4469
|
-
*/constructor(){super(),this._nodeId=s("id"),this._links=s("links"),this._linksSource="source",this._linksTarget="target",this._noDataMessage=!1,this._nodes=s("nodes"),this._nodeAlign=Bi.justify,this._nodePadding=8,this._nodeWidth=30,this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let i=this._on["mousemove.shape"];this._on["mousemove.shape"]=(h,n,
|
|
4487
|
+
*/constructor(){super(),this._iterations=6,this._nodeId=s("id"),this._nodeSort=void 0,this._links=s("links"),this._linkSort=void 0,this._linksSource="source",this._linksTarget="target",this._noDataMessage=!1,this._nodes=s("nodes"),this._nodeAlign=Bi.justify,this._nodePadding=8,this._nodeWidth=30,this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let i=this._on["mousemove.shape"];this._on["mousemove.shape"]=(h,n,r,t)=>{if(i(h,n,r,t),this._focus&&this._focus===h.id)this.hover(!1),this._on.mouseenter.bind(this)(h,n,r,t),this._focus=void 0;else{let e=this._nodeId(h,n),t=this._nodeLookup[e],i=Object.keys(this._nodeLookup).reduce((t,i)=>(t[this._nodeLookup[i]]=isNaN(i)?i:parseInt(i,10),t),{});r=this._linkLookup[t];let s=[e];r.forEach(t=>{s.push(i[t])}),this.hover((t,i)=>t.source&&t.target?t.source.id===e||t.target.id===e:s.includes(this._nodeId(t,i)))}},this._path=e.sankeyLinkHorizontal(),this._sankey=e.sankey(),this._shape=Ht("Rect"),this._shapeConfig=Pt.assign(this._shapeConfig,{Path:{fill:"none",hoverStyle:{"stroke-width":t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},Rect:{}}),this._value=Ht(1)}}class Di extends hi{
|
|
4470
4488
|
/**
|
|
4471
4489
|
@memberof StackedArea
|
|
4472
4490
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|
|
@@ -4475,11 +4493,11 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4475
4493
|
/**
|
|
4476
4494
|
Extends the draw behavior of the abstract Viz class.
|
|
4477
4495
|
@private
|
|
4478
|
-
*/_draw(t){super._draw(t);let
|
|
4496
|
+
*/_draw(t){super._draw(t);let r="vertical"===this._orient,n="horizontal"===this._orient,i=r?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right,a=r?"left":"top",e=this,s=`translate(${this._margin.left}, ${this._margin.top})`,o=n?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right;t=this._treeData=this._tree.separation(this._separation).size([o,i])(f.hierarchy({key:"root",values:Lt.nest(this._filteredData,this._groupBy.slice(0,this._drawDepth+1))},t=>t.key&&t.values?t.values:null).sort(this._sort)).descendants().filter(t=>t.depth<=this._groupBy.length&&t.parent);
|
|
4479
4497
|
/**
|
|
4480
4498
|
Merges the values of a given nest branch.
|
|
4481
4499
|
@private
|
|
4482
|
-
*/t.forEach((t,i)=>{t.data.key&&t.data.values&&(t.data=function i(t){return Lt.merge(t.values.map(t=>t.key&&t.values?i(t):t),e._aggs)}(t.data)),t.__d3plus__=!0,t.i=i});let h=this._shapeConfig.r;"function"!=typeof h&&(h=Ht(h));var l=Dt.max(t,t=>1===t.depth?h(t.data,t.i):0),_=Dt.max(t,t=>t.children?0:h(t.data,t.i)),d=Dt.extent(t,t=>t.y);this._labelHeight=Dt.min([
|
|
4500
|
+
*/t.forEach((t,i)=>{t.data.key&&t.data.values&&(t.data=function i(t){return Lt.merge(t.values.map(t=>t.key&&t.values?i(t):t),e._aggs)}(t.data)),t.__d3plus__=!0,t.i=i});let h=this._shapeConfig.r;"function"!=typeof h&&(h=Ht(h));var l=Dt.max(t,t=>1===t.depth?h(t.data,t.i):0),_=Dt.max(t,t=>t.children?0:h(t.data,t.i)),d=Dt.extent(t,t=>t.y);this._labelHeight=Dt.min([r?50:100,(d[1]-l-_)/(this._groupBy.length+1)]),this._labelWidths=Lt.nest(t,t=>t.depth).map(h=>h.values.reduce((t,i,e)=>{var s=e<h.values.length-1?h.values[e+1].x:o+this._margin[a],e=e?h.values[e-1].x:this._margin[a];return Dt.min([t,s-i.x,i.x-e])},o));let g=k.scaleLinear().domain(d).range([l+this._labelHeight,i-_-this._labelHeight]),c=(t.forEach(t=>{var i=g(t.y);n?(t.y=t.x,t.x=i):t.y=i}),{parent:this._select,enter:{transform:s},update:{transform:s}}),u=(this._shapes.push((new B).data(t.filter(t=>1<t.depth).map(t=>Pt.assign({},t))).select(Pt.elem("g.d3plus-Tree-Links",c).node()).config(jt.bind(this)(this._shapeConfig,"shape","Path")).config({d:t=>{let i=this._shapeConfig.r;"function"==typeof i&&(i=i(t.data,t.i));var e=t.parent.x-t.x+(r?0:i),t=t.parent.y-t.y+(r?i:0),s=r?0:-i,h=r?-i:0;return r?`M${s},${h}C${s},${(h+t)/2} ${e},${(h+t)/2} ${e},`+t:`M${s},${h}C${(s+e)/2},${h} ${(s+e)/2},${t} ${e},`+t},id:(t,i)=>this._ids(t,i)[t.depth-1]}).render()),{id:(t,i)=>this._ids(t,i)[t.depth-1],label:(t,i)=>this._label?this._label(t.data,i):(i=this._ids(t,i).slice(0,t.depth))[i.length-1],labelConfig:{textAnchor:(t,i,e)=>r?"middle":e.children&&e.depth!==this._drawDepth+1?"end":"start",verticalAlign:(t,i,e)=>r?1===e.depth?"bottom":"top":"middle"},hitArea:(t,i,e)=>{var s=this._labelHeight,e=e.r||(r?e.height/2:e.width/2),h=this._labelWidths[t.depth-1];return{width:r?h:2*e+h,height:n?s:2*e+s,x:r?-h/2:t.children&&t.depth!==this._groupBy.length?-(e+h):-e,y:n?-s/2:t.children&&t.depth!==this._groupBy.length?-(e+this._labelHeight):-e}},labelBounds:(t,i,e)=>{var s=this._labelHeight,h=r?"height":"width",e=e.r||(r?e.height/2:e.width/2),n=this._labelWidths[t.depth-1];return{[r?"width":"height"]:n,[h]:s,[r?"x":"y"]:-n/2,[r?"y":"x"]:t.children&&t.depth!==this._groupBy.length?-(e+s):e}}});d=Lt.nest(t,t=>this._shape(t.data));let p=d.map(t=>t.key);l=this._previousShapes.filter(t=>!p.includes(t));return d.concat(l.map(t=>({key:t,values:[]}))).forEach(({key:t,values:i})=>{this._shapes.push((new Wt[t]).data(i).select(Pt.elem("g.d3plus-Tree-"+t,c).node()).config(jt.bind(this)(this._shapeConfig,"shape",t)).config(u).render())}),this._previousShapes=p,this}
|
|
4483
4501
|
/**
|
|
4484
4502
|
@memberof Tree
|
|
4485
4503
|
@desc Changes the orientation of the entire Tree, either "vertical" (top to bottom) or "horizontal" (left to right).
|
|
@@ -4506,24 +4524,24 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4506
4524
|
@memberof Treemap
|
|
4507
4525
|
@desc Extends the draw behavior of the abstract Viz class.
|
|
4508
4526
|
@private
|
|
4509
|
-
*/_draw(t){super._draw(t);let i=Ot.nest();for(let t=0;t<=this._drawDepth;t++)i.key(this._groupBy[t]);i=i.entries(this._filteredData);t=this._treemap.padding(this._layoutPadding).size([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom]).tile(this._tile)(f.hierarchy({values:i},t=>t.values).sum(this._sum).sort(this._sort));let n=[],
|
|
4527
|
+
*/_draw(t){super._draw(t);let i=Ot.nest();for(let t=0;t<=this._drawDepth;t++)i.key(this._groupBy[t]);i=i.entries(this._filteredData);t=this._treemap.padding(this._layoutPadding).size([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom]).tile(this._tile)(f.hierarchy({values:i},t=>t.values).sum(this._sum).sort(this._sort));let n=[],r=this;
|
|
4510
4528
|
/**
|
|
4511
4529
|
@memberof Treemap
|
|
4512
4530
|
@desc Flattens and merges treemap data.
|
|
4513
4531
|
@private
|
|
4514
|
-
*/t.children&&!function i(e){for(let t=0;t<e.length;t++){var s,h=e[t];h.depth<=
|
|
4532
|
+
*/t.children&&!function i(e){for(let t=0;t<e.length;t++){var s,h=e[t];h.depth<=r._drawDepth?i(h.children):(s=1===h.data.values.length?r._filteredData.indexOf(h.data.values[0]):void 0,h.__d3plus__=!0,h.id=h.data.key,h.i=-1<s?s:void 0,h.data=Lt.merge(h.data.values,r._aggs),h.x=h.x0+(h.x1-h.x0)/2,h.y=h.y0+(h.y1-h.y0)/2,n.push(h))}}(t.children),this._rankData=n.sort(this._sort).map(t=>t.data);let e=t.value;n.forEach(t=>{t.share=this._sum(t.data,t.i)/e});var t=`translate(${this._margin.left}, ${this._margin.top})`,s=jt.bind(this)(this._shapeConfig,"shape","Rect");let a=s.labelConfig.fontMax,o=s.labelConfig.fontMin,l=s.labelConfig.padding;return this._shapes.push((new Ft).data(n).label(t=>[this._drawLabel(t.data,t.i),Tt.formatAbbreviate(100*t.share,this._locale)+"%"]).select(Pt.elem("g.d3plus-Treemap",{parent:this._select,enter:{transform:t},update:{transform:t}}).node()).config({height:t=>t.y1-t.y0,labelBounds:(t,i,e)=>{var s=e.height;let h=Math.min(a,.5*(s-2*l));return h<o&&(h=0),[{width:e.width,height:s-h,x:-e.width/2,y:-s/2},{width:e.width,height:h+2*l,x:-e.width/2,y:s/2-h-2*l}]},labelConfig:{textAnchor:(t,i,e)=>{let s,h=e;for(;void 0===s&&h;)void 0!==h.l&&(s=h.l),h=h.__d3plusParent__;return s?"middle":"start"},verticalAlign:(t,i,e)=>{let s,h=e;for(;void 0===s&&h;)void 0!==h.l&&(s=h.l),h=h.__d3plusParent__;return s?"bottom":"top"}},width:t=>t.x1-t.x0}).config(s).render()),this}
|
|
4515
4533
|
/**
|
|
4516
4534
|
* Applies the threshold algorithm for Treemaps.
|
|
4517
4535
|
* @param {Array} data The data to process.
|
|
4518
4536
|
* @private
|
|
4519
|
-
*/_thresholdFunction(t){let
|
|
4537
|
+
*/_thresholdFunction(t){let r=this._aggs,i=this._drawDepth,e=this._groupBy,a=this._threshold,o=this._thresholdKey,l=Dt.sum(t,o);return a&&o?
|
|
4520
4538
|
/**
|
|
4521
4539
|
* @memberof Treemap
|
|
4522
4540
|
* @desc Explores the data tree recursively and merges elements under the indicated threshold.
|
|
4523
4541
|
* @param {object[]} branchData The current subset of the dataset to work on.
|
|
4524
4542
|
* @param {number} depth The depth of the current branch.
|
|
4525
4543
|
* @private
|
|
4526
|
-
*/function s(n,h){if(h<i)return Ot.nest().key(e[h]).entries(n).reduce((t,i)=>{let e=s(i.values,h+1);return t.concat(e)},[]);if(h===i){let i=Math.min(1,Math.max(0,
|
|
4544
|
+
*/function s(n,h){if(h<i)return Ot.nest().key(e[h]).entries(n).reduce((t,i)=>{let e=s(i.values,h+1);return t.concat(e)},[]);if(h===i){let i=Math.min(1,Math.max(0,a(n)));if(!isFinite(i)||isNaN(i))return null;let e=[],s=n.slice(),t=i*l,h=s.length;for(;h--;){let i=s[h];if(o(i)<t){let t=s.indexOf(i);s.splice(t,1),e.push(i)}}if(0<e.length){let t=Lt.merge(e,r);t._isAggregation=!0,t._threshold=i,s.push(t)}return s}throw new Error("Depth is higher than the amount of grouping levels.")}(t,0):t}
|
|
4527
4545
|
/**
|
|
4528
4546
|
@memberof Treemap
|
|
4529
4547
|
@desc If *value* is specified, sets the inner and outer padding accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current padding accessor.
|
|
@@ -4558,5 +4576,5 @@ this._margin={bottom:0,left:0,right:0,top:0},this._padding={bottom:0,left:0,righ
|
|
|
4558
4576
|
@memberof Treemap
|
|
4559
4577
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
4560
4578
|
@private
|
|
4561
|
-
*/constructor(){super(),this._layoutPadding=1;let e=this._legend,h=(this._legend=(t,i)=>i.length!==this._filteredData.length&&e.bind(this)(t,i),this._legendSort=(t,i)=>this._sum(i)-this._sum(t),this._legendTooltip=Pt.assign({},this._legendTooltip,{tbody:[]}),this._shapeConfig=Pt.assign({},this._shapeConfig,{ariaLabel:(t,i)=>(this._rankData?this._rankData.indexOf(t)+1+". ":"")+this._drawLabel(t,i)+`, ${this._sum(t,i)}.`,labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}}),this._sort=(t,i)=>{var e=h(t),s=h(i);return e&&!s?1:!e&&s?-1:i.value-t.value},this._sum=s("value"),this._thresholdKey=this._sum,this._tile=f.treemapSquarify,this._tooltipConfig=Pt.assign({},this._tooltipConfig,{tbody:[[()=>this._translate("Share"),(t,i,e)=>Tt.formatAbbreviate(100*e.share,this._locale)+"%"]]}),this._treemap=f.treemap().round(!0),t=>t.children&&1===t.children.length&&t.children[0].data._isAggregation)}}t.Area=Nt,t.AreaPlot=hi,t.Axis=o,t.AxisBottom=et,t.AxisLeft=st,t.AxisRight=ht,t.AxisTop=nt,t.Bar=K,t.BarChart=ni,t.BaseClass=h,t.Box=Q,t.BoxWhisker=
|
|
4579
|
+
*/constructor(){super(),this._layoutPadding=1;let e=this._legend,h=(this._legend=(t,i)=>i.length!==this._filteredData.length&&e.bind(this)(t,i),this._legendSort=(t,i)=>this._sum(i)-this._sum(t),this._legendTooltip=Pt.assign({},this._legendTooltip,{tbody:[]}),this._shapeConfig=Pt.assign({},this._shapeConfig,{ariaLabel:(t,i)=>(this._rankData?this._rankData.indexOf(t)+1+". ":"")+this._drawLabel(t,i)+`, ${this._sum(t,i)}.`,labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}}),this._sort=(t,i)=>{var e=h(t),s=h(i);return e&&!s?1:!e&&s?-1:i.value-t.value},this._sum=s("value"),this._thresholdKey=this._sum,this._tile=f.treemapSquarify,this._tooltipConfig=Pt.assign({},this._tooltipConfig,{tbody:[[()=>this._translate("Share"),(t,i,e)=>Tt.formatAbbreviate(100*e.share,this._locale)+"%"]]}),this._treemap=f.treemap().round(!0),t=>t.children&&1===t.children.length&&t.children[0].data._isAggregation)}}t.Area=Nt,t.AreaPlot=hi,t.Axis=o,t.AxisBottom=et,t.AxisLeft=st,t.AxisRight=ht,t.AxisTop=nt,t.Bar=K,t.BarChart=ni,t.BaseClass=h,t.Box=Q,t.BoxWhisker=ri,t.BumpChart=ai,t.Circle=Rt,t.ColorScale=at,t.Donut=li,t.Geomap=ui,t.Image=V,t.Legend=rt,t.Line=It,t.LinePlot=pi,t.Matrix=yi,t.Message=ot,t.Network=bi,t.Pack=Ci,t.Path=B,t.Pie=oi,t.Plot=si,t.Priestley=wi,t.RESET=T,t.Radar=ki,t.RadialMatrix=Mi,t.Rect=Ft,t.Rings=Ai,t.Sankey=Pi,t.Shape=r,t.StackedArea=Di,t.TextBox=l,t.Timeline=dt,t.Tooltip=ct,t.Tree=Oi,t.Treemap=Ti,t.Viz=_,t.Whisker=X,t.accessor=s,t.configPrep=jt,t.constant=Ht,t.uuid=q});
|
|
4562
4580
|
//# sourceMappingURL=d3plus-core.js.map
|