d3plus-legend
Advanced tools
Comparing version 0.8.28 to 0.8.29
/* | ||
d3plus-legend v0.8.28 | ||
d3plus-legend v0.8.29 | ||
An easy to use javascript chart legend. | ||
Copyright (c) 2019 D3plus - https://d3plus.org | ||
Copyright (c) 2020 D3plus - https://d3plus.org | ||
@license MIT | ||
*/ | ||
(function(t){typeof define==="function"&&define.amd?define(t):t()})(function(){"use strict";var t=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}var i="object";var n=function(t){return t&&t.Math==Math&&t};var c=n(typeof globalThis==i&&globalThis)||n(typeof window==i&&window)||n(typeof self==i&&self)||n(typeof t==i&&t)||Function("return this")();var r=function(t){try{return!!t()}catch(t){return true}};var d=!r(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7});var a={}.propertyIsEnumerable;var o=Object.getOwnPropertyDescriptor;var s=o&&!a.call({1:2},1);var h=s?function t(e){var i=o(this,e);return!!i&&i.enumerable}:a;var g={f:h};var u=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}};var l={}.toString;var f=function(t){return l.call(t).slice(8,-1)};var v="".split;var w=r(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return f(t)=="String"?v.call(t,""):Object(t)}:Object;var _=function(t){if(t==undefined)throw TypeError("Can't call method on "+t);return t};var p=function(t){return w(_(t))};var y=function(t){return typeof t==="object"?t!==null:typeof t==="function"};var m=function(t,e){if(!y(t))return t;var i,n;if(e&&typeof(i=t.toString)=="function"&&!y(n=i.call(t)))return n;if(typeof(i=t.valueOf)=="function"&&!y(n=i.call(t)))return n;if(!e&&typeof(i=t.toString)=="function"&&!y(n=i.call(t)))return n;throw TypeError("Can't convert object to primitive value")};var b={}.hasOwnProperty;var x=function(t,e){return b.call(t,e)};var C=c.document;var k=y(C)&&y(C.createElement);var S=function(t){return k?C.createElement(t):{}};var M=!d&&!r(function(){return Object.defineProperty(S("div"),"a",{get:function(){return 7}}).a!=7});var O=Object.getOwnPropertyDescriptor;var j=d?O:function t(e,i){e=p(e);i=m(i,true);if(M)try{return O(e,i)}catch(t){}if(x(e,i))return u(!g.f.call(e,i),e[i])};var A={f:j};var T=function(t){if(!y(t)){throw TypeError(String(t)+" is not an object")}return t};var E=Object.defineProperty;var B=d?E:function t(e,i,n){T(e);i=m(i,true);T(n);if(M)try{return E(e,i,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");if("value"in n)e[i]=n.value;return e};var W={f:B};var H=d?function(t,e,i){return W.f(t,e,u(1,i))}:function(t,e,i){t[e]=i;return t};var P=function(e,i){try{H(c,e,i)}catch(t){c[e]=i}return i};var D=e(function(t){var e="__core-js_shared__";var i=c[e]||P(e,{});(t.exports=function(t,e){return i[t]||(i[t]=e!==undefined?e:{})})("versions",[]).push({version:"3.2.1",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})});var z=D("native-function-to-string",Function.toString);var L=c.WeakMap;var F=typeof L==="function"&&/native code/.test(z.call(L));var R=0;var q=Math.random();var N=function(t){return"Symbol("+String(t===undefined?"":t)+")_"+(++R+q).toString(36)};var G=D("keys");var I=function(t){return G[t]||(G[t]=N(t))};var V={};var K=c.WeakMap;var Y,J,Q;var U=function(t){return Q(t)?J(t):Y(t,{})};var X=function(i){return function(t){var e;if(!y(t)||(e=J(t)).type!==i){throw TypeError("Incompatible receiver, "+i+" required")}return e}};if(F){var Z=new K;var $=Z.get;var tt=Z.has;var et=Z.set;Y=function(t,e){et.call(Z,t,e);return e};J=function(t){return $.call(Z,t)||{}};Q=function(t){return tt.call(Z,t)}}else{var it=I("state");V[it]=true;Y=function(t,e){H(t,it,e);return e};J=function(t){return x(t,it)?t[it]:{}};Q=function(t){return x(t,it)}}var nt={set:Y,get:J,has:Q,enforce:U,getterFor:X};var rt=e(function(t){var e=nt.get;var s=nt.enforce;var h=String(z).split("toString");D("inspectSource",function(t){return z.call(t)});(t.exports=function(t,e,i,n){var r=n?!!n.unsafe:false;var a=n?!!n.enumerable:false;var o=n?!!n.noTargetGet:false;if(typeof i=="function"){if(typeof e=="string"&&!x(i,"name"))H(i,"name",e);s(i).source=h.join(typeof e=="string"?e:"")}if(t===c){if(a)t[e]=i;else P(e,i);return}else if(!r){delete t[e]}else if(!o&&t[e]){a=true}if(a)t[e]=i;else H(t,e,i)})(Function.prototype,"toString",function t(){return typeof this=="function"&&e(this).source||z.call(this)})});var at=c;var ot=function(t){return typeof t=="function"?t:undefined};var st=function(t,e){return arguments.length<2?ot(at[t])||ot(c[t]):at[t]&&at[t][e]||c[t]&&c[t][e]};var ht=Math.ceil;var ut=Math.floor;var lt=function(t){return isNaN(t=+t)?0:(t>0?ut:ht)(t)};var ct=Math.min;var ft=function(t){return t>0?ct(lt(t),9007199254740991):0};var dt=Math.max;var gt=Math.min;var vt=function(t,e){var i=lt(t);return i<0?dt(i+e,0):gt(i,e)};var _t=function(s){return function(t,e,i){var n=p(t);var r=ft(n.length);var a=vt(i,r);var o;if(s&&e!=e)while(r>a){o=n[a++];if(o!=o)return true}else for(;r>a;a++){if((s||a in n)&&n[a]===e)return s||a||0}return!s&&-1}};var pt={includes:_t(true),indexOf:_t(false)};var yt=pt.indexOf;var mt=function(t,e){var i=p(t);var n=0;var r=[];var a;for(a in i)!x(V,a)&&x(i,a)&&r.push(a);while(e.length>n)if(x(i,a=e[n++])){~yt(r,a)||r.push(a)}return r};var wt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"];var bt=wt.concat("length","prototype");var xt=Object.getOwnPropertyNames||function t(e){return mt(e,bt)};var Ct={f:xt};var kt=Object.getOwnPropertySymbols;var St={f:kt};var Mt=st("Reflect","ownKeys")||function t(e){var i=Ct.f(T(e));var n=St.f;return n?i.concat(n(e)):i};var Ot=function(t,e){var i=Mt(e);var n=W.f;var r=A.f;for(var a=0;a<i.length;a++){var o=i[a];if(!x(t,o))n(t,o,r(e,o))}};var jt=/#|\.prototype\./;var At=function(t,e){var i=Et[Tt(t)];return i==Wt?true:i==Bt?false:typeof e=="function"?r(e):!!e};var Tt=At.normalize=function(t){return String(t).replace(jt,".").toLowerCase()};var Et=At.data={};var Bt=At.NATIVE="N";var Wt=At.POLYFILL="P";var Ht=At;var Pt=A.f;var Dt=function(t,e){var i=t.target;var n=t.global;var r=t.stat;var a,o,s,h,u,l;if(n){o=c}else if(r){o=c[i]||P(i,{})}else{o=(c[i]||{}).prototype}if(o)for(s in e){u=e[s];if(t.noTargetGet){l=Pt(o,s);h=l&&l.value}else h=o[s];a=Ht(n?s:i+(r?".":"#")+s,t.forced);if(!a&&h!==undefined){if(typeof u===typeof h)continue;Ot(u,h)}if(t.sham||h&&h.sham){H(u,"sham",true)}rt(o,s,u,t)}};var zt=function(t){if(typeof t!="function"){throw TypeError(String(t)+" is not a function")}return t};var Lt=function(n,r,t){zt(n);if(r===undefined)return n;switch(t){case 0:return function(){return n.call(r)};case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,i){return n.call(r,t,e,i)}}return function(){return n.apply(r,arguments)}};var Ft=function(t){return Object(_(t))};var Rt=Array.isArray||function t(e){return f(e)=="Array"};var qt=!!Object.getOwnPropertySymbols&&!r(function(){return!String(Symbol())});var Nt=c.Symbol;var Gt=D("wks");var It=function(t){return Gt[t]||(Gt[t]=qt&&Nt[t]||(qt?Nt:N)("Symbol."+t))};var Vt=It("species");var Kt=function(t,e){var i;if(Rt(t)){i=t.constructor;if(typeof i=="function"&&(i===Array||Rt(i.prototype)))i=undefined;else if(y(i)){i=i[Vt];if(i===null)i=undefined}}return new(i===undefined?Array:i)(e===0?0:e)};var Yt=[].push;var Jt=function(d){var g=d==1;var v=d==2;var _=d==3;var p=d==4;var y=d==6;var m=d==5||y;return function(t,e,i,n){var r=Ft(t);var a=w(r);var o=Lt(e,i,3);var s=ft(a.length);var h=0;var u=n||Kt;var l=g?u(t,s):v?u(t,0):undefined;var c,f;for(;s>h;h++)if(m||h in a){c=a[h];f=o(c,h,r);if(d){if(g)l[h]=f;else if(f)switch(d){case 3:return true;case 5:return c;case 6:return h;case 2:Yt.call(l,c)}else if(p)return false}}return y?-1:_||p?p:l}};var Qt={forEach:Jt(0),map:Jt(1),filter:Jt(2),some:Jt(3),every:Jt(4),find:Jt(5),findIndex:Jt(6)};var Ut=Object.keys||function t(e){return mt(e,wt)};var Xt=d?Object.defineProperties:function t(e,i){T(e);var n=Ut(i);var r=n.length;var a=0;var o;while(r>a)W.f(e,o=n[a++],i[o]);return e};var Zt=st("document","documentElement");var $t=I("IE_PROTO");var te="prototype";var ee=function(){};var ie=function(){var t=S("iframe");var e=wt.length;var i="<";var n="script";var r=">";var a="java"+n+":";var o;t.style.display="none";Zt.appendChild(t);t.src=String(a);o=t.contentWindow.document;o.open();o.write(i+n+r+"document.F=Object"+i+"/"+n+r);o.close();ie=o.F;while(e--)delete ie[te][wt[e]];return ie()};var ne=Object.create||function t(e,i){var n;if(e!==null){ee[te]=T(e);n=new ee;ee[te]=null;n[$t]=e}else n=ie();return i===undefined?n:Xt(n,i)};V[$t]=true;var re=It("unscopables");var ae=Array.prototype;if(ae[re]==undefined){H(ae,re,ne(null))}var oe=function(t){ae[re][t]=true};var se=Qt.find;var he="find";var ue=true;if(he in[])Array(1)[he](function(){ue=false});Dt({target:"Array",proto:true,forced:ue},{find:function t(e){return se(this,e,arguments.length>1?arguments[1]:undefined)}});oe(he);var le=pt.includes;Dt({target:"Array",proto:true},{includes:function t(e){return le(this,e,arguments.length>1?arguments[1]:undefined)}});oe("includes");var ce=Object.assign;var fe=!ce||r(function(){var t={};var e={};var i=Symbol();var n="abcdefghijklmnopqrst";t[i]=7;n.split("").forEach(function(t){e[t]=t});return ce({},t)[i]!=7||Ut(ce({},e)).join("")!=n})?function t(e,i){var n=Ft(e);var r=arguments.length;var a=1;var o=St.f;var s=g.f;while(r>a){var h=w(arguments[a++]);var u=o?Ut(h).concat(o(h)):Ut(h);var l=u.length;var c=0;var f;while(l>c){f=u[c++];if(!d||s.call(h,f))n[f]=h[f]}}return n}:ce;Dt({target:"Object",stat:true,forced:Object.assign!==fe},{assign:fe});var de=It("match");var ge=function(t){var e;return y(t)&&((e=t[de])!==undefined?!!e:f(t)=="RegExp")};var ve=function(t){if(ge(t)){throw TypeError("The method doesn't accept regular expressions")}return t};var _e=It("match");var pe=function(e){var i=/./;try{"/./"[e](i)}catch(t){try{i[_e]=false;return"/./"[e](i)}catch(t){}}return false};Dt({target:"String",proto:true,forced:!pe("includes")},{includes:function t(e){return!!~String(_(this)).indexOf(ve(e),arguments.length>1?arguments[1]:undefined)}});var ye="".startsWith;var me=Math.min;Dt({target:"String",proto:true,forced:!pe("startsWith")},{startsWith:function t(e){var i=String(_(this));ve(e);var n=ft(me(arguments.length>1?arguments[1]:undefined,i.length));var r=String(e);return ye?ye.call(i,r,n):i.slice(n,n+r.length)===r}});if(typeof window!=="undefined"){(function(){var n=function(t,e){var i=t.nodeType;if(i===3){e.push(t.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(i===1){e.push("<",t.tagName);if(t.hasAttributes()){[].forEach.call(t.attributes,function(t){e.push(" ",t.item.name,"='",t.item.value,"'")})}if(t.hasChildNodes()){e.push(">");[].forEach.call(t.childNodes,function(t){n(t,e)});e.push("</",t.tagName,">")}else{e.push("/>")}}else if(i==8){e.push("\x3c!--",t.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var t=[];var e=this.firstChild;while(e){n(e,t);e=e.nextSibling}return t.join("")},set:function(t){while(this.firstChild){this.removeChild(this.firstChild)}try{var e=new DOMParser;e.async=false;var i="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>";var n=e.parseFromString(i,"text/xml").documentElement;var r=n.firstChild;while(r){this.appendChild(this.ownerDocument.importNode(r,true));r=r.nextSibling}}catch(t){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})})()}});(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-selection"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-text"),require("d3-scale"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-format")):typeof define==="function"&&define.amd?define("d3plus-legend",["exports","d3-array","d3-selection","d3plus-common","d3plus-shape","d3plus-text","d3-scale","d3plus-axis","d3plus-color","d3plus-format"],e):(t=t||self,e(t.d3plus={},t.d3Array,t.d3Selection,t.d3plusCommon,t.shapes,t.d3plusText,t.d3Scale,t.d3plusAxis,t.d3plusColor,t.d3plusFormat))})(this,function(t,$,tt,et,b,x,it,i,nt,rt){"use strict";function l(t){return t.slice().sort(function(t,e){return t-e})}function c(t){var e,i=0;for(var n=0;n<t.length;n++){if(n===0||t[n]!==e){e=t[n];i++}}return i}function f(t,e){var i=[];for(var n=0;n<t;n++){var r=[];for(var a=0;a<e;a++){r.push(0)}i.push(r)}return i}function v(t,e,i,n){var r;if(t>0){var a=(i[e]-i[t-1])/(e-t+1);r=n[e]-n[t-1]-(e-t+1)*a*a}else r=n[e]-i[e]*i[e]/(e+1);if(r<0)return 0;return r}function _(t,e,i,n,r,a,o){if(t>e)return;var s=Math.floor((t+e)/2);n[i][s]=n[i-1][s-1];r[i][s]=s;var h=i;if(t>i)h=Math.max(h,r[i][t-1]||0);h=Math.max(h,r[i-1][s]||0);var u=s-1;if(e<n.length-1)u=Math.min(u,r[i][e+1]||0);for(var l=u;l>=h;--l){var c=v(l,s,a,o);if(c+n[i-1][h-1]>=n[i][s])break;var f=v(h,s,a,o);var d=f+n[i-1][h-1];if(d<n[i][s]){n[i][s]=d;r[i][s]=h}h++;var g=c+n[i-1][l-1];if(g<n[i][s]){n[i][s]=g;r[i][s]=l}}_(t,s-1,i,n,r,a,o);_(s+1,e,i,n,r,a,o)}function d(t,e,i){var n=e[0]?e[0].length:0;var r=t[Math.floor(n/2)];var a=[];var o=[];for(var s=0,h=void 0;s<n;++s){h=t[s]-r;if(s===0){a.push(h);o.push(h*h)}else{a.push(a[s-1]+h);o.push(o[s-1]+h*h)}e[0][s]=v(0,s,a,o);i[0][s]=0}for(var u=1;u<e.length;++u){var l=n-1;if(u<e.length-1)l=u;_(l,n-1,u,e,i,a,o)}}function at(t,e){if(e>t.length){throw new Error("Cannot generate more classes than there are data values")}var i=l(t);var n=c(i);if(n===1){return[i]}var r=f(e,i.length),a=f(e,i.length);d(i,a,r);var o=r[0]?r[0].length-1:0;var s=[];for(var h=r.length-1;h>=0;h--){var u=r[h][o];s[h]=i.slice(u,o+1);if(h>0)o=u-1}return s}function n(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}function a(t,e,i){if(e)r(t.prototype,e);if(i)r(t,i);return t}function ot(t,e,i){if(e in t){Object.defineProperty(t,e,{value:i,enumerable:true,configurable:true,writable:true})}else{t[e]=i}return t}function o(t,e){if(typeof e!=="function"&&e!==null){throw new TypeError("Super expression must either be null or a function")}t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}});if(e)s(t,e)}function h(t){h=Object.setPrototypeOf?Object.getPrototypeOf:function t(e){return e.__proto__||Object.getPrototypeOf(e)};return h(t)}function s(t,e){s=Object.setPrototypeOf||function t(e,i){e.__proto__=i;return e};return s(t,e)}function u(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function g(t,e){if(e&&(typeof e==="object"||typeof e==="function")){return e}return u(t)}var p=function(t){o(e,t);function e(){var s;n(this,e);s=g(this,h(e).call(this));s._align="center";s._data=[];s._direction="row";s._duration=600;s._height=200;s._id=et.accessor("id");s._label=et.accessor("id");s._lineData=[];s._outerBounds={width:0,height:0,x:0,y:0};s._padding=5;s._shape=et.constant("Rect");s._shapes=[];s._shapeConfig={duration:s._duration,fill:et.accessor("color"),height:et.constant(10),hitArea:function t(e,i){var n=s._lineData[i],r=$.max([n.height,n.shapeHeight]);return{width:n.width+n.shapeWidth,height:r,x:-n.shapeWidth/2,y:-r/2}},labelBounds:function t(e,i){var n=s._lineData[i];var r=n.shapeWidth;if(n.shape==="Circle")r-=n.shapeR;var a=$.max([n.shapeHeight,n.height]);return{width:n.width,height:a,x:r,y:-a/2}},labelConfig:{fontColor:et.constant("#444"),fontFamily:(new x.TextBox).fontFamily(),fontResize:false,fontSize:et.constant(10),verticalAlign:"middle"},opacity:1,r:et.constant(5),width:et.constant(10),x:function t(e,i){var n=s._lineData[i];var r=n.y;var a=s._align==="left"||s._align==="right"&&s._direction==="column"?0:s._align==="center"?(s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return r===t.y})))/2:s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return r===t.y}));var o=s._lineData.slice(0,i).filter(function(t){return r===t.y});return s._rowWidth(o)+s._padding*(o.length?n.sentence?2:1:0)+s._outerBounds.x+n.shapeWidth/2+a},y:function t(e,i){var n=s._lineData[i];return n.y+s._titleHeight+s._outerBounds.y+$.max(s._lineData.filter(function(t){return n.y===t.y}).map(function(t){return t.height}).concat(s._data.map(function(t,e){return s._fetchConfig("height",t,e)})))/2}};s._titleClass=new x.TextBox;s._titleConfig={};s._verticalAlign="middle";s._width=400;return s}a(e,[{key:"_fetchConfig",value:function t(e,i,n){var r=this._shapeConfig[e]||this._shapeConfig.labelConfig[e];if(!r&&e==="lineHeight")return this._fetchConfig("fontSize",i,n)*1.4;return typeof r==="function"?r(i,n):r}},{key:"_rowHeight",value:function t(e){return $.max(e.map(function(t){return t.height}).concat(e.map(function(t){return t.shapeHeight})))+this._padding}},{key:"_rowWidth",value:function t(n){var r=this;return $.sum(n.map(function(t,e){var i=r._padding*(e===n.length-1?0:t.width?2:1);return t.shapeWidth+t.width+i}))}},{key:"render",value:function t(e){var c=this;if(this._select===void 0)this.select(tt.select("body").append("svg").attr("width","".concat(this._width,"px")).attr("height","".concat(this._height,"px")).node());this._group=et.elem("g.d3plus-Legend",{parent:this._select});var f=this._height;this._titleHeight=0;this._titleWidth=0;if(this._title){var i=this._titleConfig.fontFamily||this._titleClass.fontFamily()(),n=this._titleConfig.fontSize||this._titleClass.fontSize()();var r=r=this._titleConfig.lineHeight||this._titleClass.lineHeight();r=r?r():n*1.4;var a=x.textWrap().fontFamily(i).fontSize(n).lineHeight(r).width(this._width).height(this._height)(this._title);this._titleHeight=r+a.lines.length+this._padding;this._titleWidth=$.max(a.widths);f-=this._titleHeight}this._lineData=this._data.map(function(t,e){var i=c._label(t,e);var n=c._shape(t,e);var r=c._fetchConfig("r",t,e);var a={data:t,i:e,id:c._id(t,e),shape:n,shapeR:r,shapeWidth:n==="Circle"?r*2:c._fetchConfig("width",t,e),shapeHeight:n==="Circle"?r*2:c._fetchConfig("height",t,e),y:0};if(!i){a.sentence=false;a.words=[];a.height=0;a.width=0;return a}var o=c._fetchConfig("fontFamily",t,e),s=c._fetchConfig("lineHeight",t,e),h=c._fetchConfig("fontSize",t,e);var u=f-(c._data.length+1)*c._padding,l=c._width;a=Object.assign(a,x.textWrap().fontFamily(o).fontSize(h).lineHeight(s).width(l).height(u)(i));a.width=Math.ceil($.max(a.lines.map(function(t){return x.textWidth(t,{"font-family":o,"font-size":h})})))+h*.75;a.height=Math.ceil(a.lines.length*(s+1));a.og={height:a.height,width:a.width};a.f=o;a.s=h;a.lh=s;return a});var o;var h=this._width-this._padding*2;o=this._rowWidth(this._lineData);if(this._direction==="column"||o>h){var u=1,l=[];var d=$.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var e=this;u++;if(u>d)return;var o=u===1?this._lineData.slice():this._lineData.filter(function(t){return t.width+t.shapeWidth+e._padding*(t.width?2:1)>h&&t.words.length>=u}).sort(function(t,e){return e.sentence.length-t.sentence.length});if(o.length&&f>o[0].height*u){var s=false;var t=function t(e){var i=o[e];var n=i.og.height*u,r=i.og.width*(1.5*(1/u));var a=x.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(r).height(n)(i.sentence);if(!a.truncated){i.width=Math.ceil($.max(a.lines.map(function(t){return x.textWidth(t,{"font-family":i.f,"font-size":i.s})})))+i.s;i.height=a.lines.length*(i.lh+1)}else{s=true;return"break"}};for(var i=0;i<o.length;i++){var n=t(i);if(n==="break")break}if(!s)this._wrapRows()}else{l=[];return}};this._wrapRows=function(){l=[];var t=1,e=0;for(var i=0;i<this._lineData.length;i++){var n=this._lineData[i],r=n.width+this._padding*(n.width?2:1)+n.shapeWidth;if($.sum(l.map(function(t){return $.max(t,function(t){return $.max([t.height,t.shapeHeight])})}))>f){l=[];break}if(r>h){l=[];this._wrapLines();break}else if(e+r<h){e+=r}else if(this._direction!=="column"){e=r;t++}if(!l[t-1])l[t-1]=[];l[t-1].push(n);if(this._direction==="column"){e=0;t++}}};this._wrapRows();if(!l.length||$.sum(l,this._rowHeight.bind(this))+this._padding>f){o=$.sum(this._lineData.map(function(t){return t.shapeWidth+c._padding}))-this._padding;for(var s=0;s<this._lineData.length;s++){this._lineData[s].width=0;this._lineData[s].height=0}this._wrapRows()}if(l.length&&$.sum(l,this._rowHeight.bind(this))+this._padding<f){l.forEach(function(t,e){t.forEach(function(t){if(e){t.y=$.sum(l.slice(0,e),c._rowHeight.bind(c))}})});o=$.max(l,this._rowWidth.bind(this))}}var g=$.max(this._lineData,function(t,e){return $.max([t.height,c._fetchConfig("height",t.data,e)])+t.y})+this._titleHeight,v=$.max([o,this._titleWidth]);this._outerBounds.width=v;this._outerBounds.height=g;var _=this._padding,p=this._padding;if(this._align==="center")_=(this._width-v)/2;else if(this._align==="right")_=this._width-this._padding-v;if(this._verticalAlign==="middle")p=(this._height-g)/2;else if(this._verticalAlign==="bottom")p=this._height-this._padding-g;this._outerBounds.x=_;this._outerBounds.y=p;this._titleClass.data(this._title?[{text:this._title}]:[]).duration(this._duration).select(this._group.node()).textAnchor({left:"start",center:"middle",right:"end"}[this._align]).width(this._width-this._padding*2).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render();this._shapes=[];var y=et.configPrep.bind(this)(this._shapeConfig,"legend"),m={id:function t(e){return e.id},label:function t(e){return e.label},lineHeight:function t(e){return e.lH}};var w=this._data.map(function(t,e){var i={__d3plus__:true,data:t,i:e,id:c._id(t,e),label:c._lineData[e].width?c._label(t,e):false,lH:c._fetchConfig("lineHeight",t,e),shape:c._shape(t,e)};return i});this._shapes=[];["Circle","Rect"].forEach(function(e){c._shapes.push((new b[e]).data(w.filter(function(t){return t.shape===e})).duration(c._duration).labelConfig({padding:0}).select(c._group.node()).verticalAlign("top").config(et.assign({},y,m)).render())});if(e)setTimeout(e,this._duration+100);return this}},{key:"active",value:function t(e){this._shapes.forEach(function(t){return t.active(e)});return this}},{key:"align",value:function t(e){return arguments.length?(this._align=e,this):this._align}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"direction",value:function t(e){return arguments.length?(this._direction=e,this):this._direction}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"height",value:function t(e){return arguments.length?(this._height=e,this):this._height}},{key:"hover",value:function t(e){this._shapes.forEach(function(t){return t.hover(e)});return this}},{key:"id",value:function t(e){return arguments.length?(this._id=e,this):this._id}},{key:"label",value:function t(e){return arguments.length?(this._label=typeof e==="function"?e:et.constant(e),this):this._label}},{key:"outerBounds",value:function t(){return this._outerBounds}},{key:"padding",value:function t(e){return arguments.length?(this._padding=e,this):this._padding}},{key:"select",value:function t(e){return arguments.length?(this._select=tt.select(e),this):this._select}},{key:"shape",value:function t(e){return arguments.length?(this._shape=typeof e==="function"?e:et.constant(e),this):this._shape}},{key:"shapeConfig",value:function t(e){return arguments.length?(this._shapeConfig=et.assign(this._shapeConfig,e),this):this._shapeConfig}},{key:"title",value:function t(e){return arguments.length?(this._title=e,this):this._title}},{key:"titleConfig",value:function t(e){return arguments.length?(this._titleConfig=et.assign(this._titleConfig,e),this):this._titleConfig}},{key:"verticalAlign",value:function t(e){return arguments.length?(this._verticalAlign=e,this):this._verticalAlign}},{key:"width",value:function t(e){return arguments.length?(this._width=e,this):this._width}}]);return e}(et.BaseClass);var e=function(t){o(e,t);function e(){var t;n(this,e);t=g(this,h(e).call(this));t._axisClass=new i.Axis;t._axisConfig={gridSize:0,shapeConfig:{labelConfig:{fontColor:"#222"}},titleConfig:{fontSize:12}};t._axisTest=new i.Axis;t._align="middle";t._buckets=5;t._bucketAxis=false;t._colorMax="#0C8040";t._colorMid="#f7f7f7";t._colorMin="#b22200";t._data=[];t._duration=600;t._height=200;t._legendClass=new p;t._legendConfig={shapeConfig:{labelConfig:{fontColor:"#222"},stroke:"#444",strokeWidth:1}};t._midpoint=0;t._orient="bottom";t._outerBounds={width:0,height:0,x:0,y:0};t._padding=5;t._rectClass=new b.Rect;t._rectConfig={stroke:"#444",strokeWidth:1};t._scale="linear";t._size=10;t._value=et.accessor("value");t._width=400;return t}a(e,[{key:"render",value:function t(e){var i=this;if(this._select===void 0)this.select(tt.select("body").append("svg").attr("width","".concat(this._width,"px")).attr("height","".concat(this._height,"px")).node());var n=["bottom","top"].includes(this._orient);var r=n?"height":"width",a=n?"width":"height",o=n?"x":"y",s=n?"y":"x";this._group=et.elem("g.d3plus-ColorScale",{parent:this._select});var h=$.extent(this._data,this._value);var u=h[0]<this._midpoint;var l=h[1]>this._midpoint;var c=u&&l;var f=this._color,d,g;if(f&&!(f instanceof Array)){f=$.range(0,this._buckets,1).map(function(t){return nt.colorLighter(f,(t+1)/i._buckets)}).reverse()}if(this._scale==="jenks"){var v=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});var _=$.min([f?f.length:this._buckets,v.length]);var p=at(v,_);g=$.merge(p.map(function(t,e){return e===p.length-1?[t[0],t[t.length-1]]:[t[0]]}));var y=new Set(g);if(g.length!==y.size){d=Array.from(y)}if(!f){if(c){f=[this._colorMin,this._colorMid,this._colorMax];var m=g.slice(0,_).filter(function(t,e){return t<i._midpoint&&g[e+1]<=i._midpoint});var w=g.slice(0,_).filter(function(t,e){return t<=i._midpoint&&g[e+1]>i._midpoint});var b=g.slice(0,_).filter(function(t,e){return t>i._midpoint&&g[e+1]>i._midpoint});var x=m.map(function(t,e){return!e?f[0]:nt.colorLighter(f[0],e/m.length)});var C=w.map(function(){return f[1]});var k=b.map(function(t,e){return e===b.length-1?f[2]:nt.colorLighter(f[2],1-(e+1)/b.length)});f=x.concat(C).concat(k)}else{f=$.range(0,this._buckets,1).map(function(t){return nt.colorLighter(i._colorMax,t/i._buckets)}).reverse()}}if(v.length<=_){f=f.slice(_-v.length)}this._colorScale=it.scaleThreshold().domain(g).range(["black"].concat(f).concat(f[f.length-1]))}else{var S;if(c&&!f){var M=Math.floor(this._buckets/2);var O=$.range(0,M,1).map(function(t){return!t?i._colorMin:nt.colorLighter(i._colorMin,t/M)});var j=(this._buckets%2?[0]:[]).map(function(){return i._colorMid});var A=$.range(0,M,1).map(function(t){return!t?i._colorMax:nt.colorLighter(i._colorMax,t/M)}).reverse();f=O.concat(j).concat(A);var T=(f.length-1)/2;S=[h[0],this._midpoint,h[1]];S=$.range(h[0],this._midpoint,-(h[0]-this._midpoint)/T).concat($.range(this._midpoint,h[1],(h[1]-this._midpoint)/T)).concat([h[1]])}else{if(!f){if(this._scale==="buckets"){f=$.range(0,this._buckets,1).map(function(t){return nt.colorLighter(u?i._colorMin:i._colorMax,t/i._buckets)});if(l)f=f.reverse()}else{f=u?[this._colorMin,nt.colorLighter(this._colorMin,.8)]:[nt.colorLighter(this._colorMax,.8),this._colorMax]}}var E=(h[1]-h[0])/(f.length-1);S=$.range(h[0],h[1]+E/2,E)}if(this._scale==="buckets"){g=S.concat([S[S.length-1]])}if(this._scale==="log"){var B=S.filter(function(t){return t<0});if(B.length){var W=B[0];var H=B.map(function(t){return-Math.pow(Math.abs(W),t/W)});B.forEach(function(t,e){S[S.indexOf(t)]=H[e]})}var P=S.filter(function(t){return t>0});if(P.length){var D=P[P.length-1];var z=P.map(function(t){return Math.pow(D,t/D)});P.forEach(function(t,e){S[S.indexOf(t)]=z[e]})}if(S.includes(0))S[S.indexOf(0)]=1}this._colorScale=it.scaleLinear().domain(S).range(f)}if(this._bucketAxis||!["buckets","jenks"].includes(this._scale)){var L;var F=et.assign({domain:n?h:h.reverse(),duration:this._duration,height:this._height,labels:d||g,orient:this._orient,padding:this._padding,scale:this._scale==="log"?"log":"linear",ticks:g,width:this._width},this._axisConfig);this._axisTest.select(et.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(F).duration(0).render();var R=this._axisTest.outerBounds();this._outerBounds[a]=this["_".concat(a)]-this._padding*2;this._outerBounds[r]=R[r]+this._size;this._outerBounds[o]=this._padding;this._outerBounds[s]=this._padding;if(this._align==="middle")this._outerBounds[s]=(this["_".concat(r)]-this._outerBounds[r])/2;else if(this._align==="end")this._outerBounds[s]=this["_".concat(r)]-this._padding-this._outerBounds[r];var q=this._outerBounds[s]+(["bottom","right"].includes(this._orient)?this._size:0)-(F.padding||this._axisClass.padding());this._axisClass.select(et.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate(".concat(n?0:q,", ").concat(n?q:0,")")}}).node()).config(F).align("start").render();var N=this._axisTest._getPosition.bind(this._axisTest);var G=this._axisTest._getRange();var I=this._group.selectAll("defs").data([0]);var V=I.enter().append("defs");V.append("linearGradient").attr("id","gradient-".concat(this._uuid));I=V.merge(I);I.select("linearGradient").attr("".concat(o,"1"),n?"0%":"100%").attr("".concat(o,"2"),n?"100%":"0%").attr("".concat(s,"1"),"0%").attr("".concat(s,"2"),"0%");var K=I.select("linearGradient").selectAll("stop").data(f);var Y=this._colorScale.domain();var J=it.scaleLinear().domain(G).range([0,100]);K.enter().append("stop").merge(K).attr("offset",function(t,e){return"".concat(J(N(Y[e])),"%")}).attr("stop-color",String);var Q=function t(e,i){var n=Math.abs(N(g[i+1])-N(e));return n||2};this._rectClass.data(g?g.slice(0,g.length-1):[0]).id(function(t,e){return e}).select(et.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config((L={duration:this._duration,fill:g?function(t){return i._colorScale(t)}:"url(#gradient-".concat(this._uuid,")")},ot(L,o,g?function(t,e){return N(t)+Q(t,e)/2-(["left","right"].includes(i._orient)?Q(t,e):0)}:G[0]+(G[1]-G[0])/2),ot(L,s,this._outerBounds[s]+(["top","left"].includes(this._orient)?R[r]:0)+this._size/2),ot(L,a,g?Q:G[1]-G[0]),ot(L,r,this._size),L)).config(this._rectConfig).render()}else{var U=this._axisConfig.tickFormat?this._axisConfig.tickFormat:rt.formatAbbreviate;var X=g.reduce(function(t,e,i){if(i!==g.length-1){var n=g[i+1];t.push({color:f[i],id:e===n?"".concat(U(e),"+"):"".concat(U(e)," - ").concat(U(n))})}return t},[]);var Z=et.assign({align:n?"center":{start:"left",middle:"center",end:"right"}[this._align],direction:n?"row":"column",duration:this._duration,height:this._height,padding:this._padding,shapeConfig:et.assign({duration:this._duration},this._axisConfig.shapeConfig||{}),title:this._axisConfig.title,titleConfig:this._axisConfig.titleConfig||{},width:this._width,verticalAlign:n?{start:"top",middle:"middle",end:"bottom"}[this._align]:"middle"},this._legendConfig);this._legendClass.data(X).select(et.elem("g.d3plus-ColorScale-legend",{parent:this._group}).node()).config(Z).render();this._outerBounds=this._legendClass.outerBounds()}if(e)setTimeout(e,this._duration+100);return this}},{key:"axisConfig",value:function t(e){return arguments.length?(this._axisConfig=et.assign(this._axisConfig,e),this):this._axisConfig}},{key:"align",value:function t(e){return arguments.length?(this._align=e,this):this._align}},{key:"buckets",value:function t(e){return arguments.length?(this._buckets=e,this):this._buckets}},{key:"bucketAxis",value:function t(e){return arguments.length?(this._bucketAxis=e,this):this._bucketAxis}},{key:"color",value:function t(e){return arguments.length?(this._color=e,this):this._color}},{key:"colorMax",value:function t(e){return arguments.length?(this._colorMax=e,this):this._colorMax}},{key:"colorMid",value:function t(e){return arguments.length?(this._colorMid=e,this):this._colorMid}},{key:"colorMin",value:function t(e){return arguments.length?(this._colorMin=e,this):this._colorMin}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"height",value:function t(e){return arguments.length?(this._height=e,this):this._height}},{key:"legendConfig",value:function t(e){return arguments.length?(this._legendConfig=et.assign(this._legendConfig,e),this):this._legendConfig}},{key:"midpoint",value:function t(e){return arguments.length?(this._midpoint=e,this):this._midpoint}},{key:"orient",value:function t(e){return arguments.length?(this._orient=e,this):this._orient}},{key:"outerBounds",value:function t(){return this._outerBounds}},{key:"padding",value:function t(e){return arguments.length?(this._padding=e,this):this._padding}},{key:"rectConfig",value:function t(e){return arguments.length?(this._rectConfig=et.assign(this._rectConfig,e),this):this._rectConfig}},{key:"scale",value:function t(e){return arguments.length?(this._scale=e,this):this._scale}},{key:"select",value:function t(e){return arguments.length?(this._select=tt.select(e),this):this._select}},{key:"size",value:function t(e){return arguments.length?(this._size=e,this):this._size}},{key:"value",value:function t(e){return arguments.length?(this._value=typeof e==="function"?e:et.constant(e),this):this._value}},{key:"width",value:function t(e){return arguments.length?(this._width=e,this):this._width}}]);return e}(et.BaseClass);t.ColorScale=e;t.Legend=p;t.ckmeans=at;Object.defineProperty(t,"__esModule",{value:true})}); | ||
(function(t){typeof define==="function"&&define.amd?define(t):t()})(function(){"use strict";var t=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}var i="object";var n=function(t){return t&&t.Math==Math&&t};var c=n(typeof globalThis==i&&globalThis)||n(typeof window==i&&window)||n(typeof self==i&&self)||n(typeof t==i&&t)||Function("return this")();var r=function(t){try{return!!t()}catch(t){return true}};var d=!r(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7});var a={}.propertyIsEnumerable;var o=Object.getOwnPropertyDescriptor;var s=o&&!a.call({1:2},1);var h=s?function t(e){var i=o(this,e);return!!i&&i.enumerable}:a;var g={f:h};var l=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}};var u={}.toString;var f=function(t){return u.call(t).slice(8,-1)};var _="".split;var b=r(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return f(t)=="String"?_.call(t,""):Object(t)}:Object;var v=function(t){if(t==undefined)throw TypeError("Can't call method on "+t);return t};var p=function(t){return b(v(t))};var y=function(t){return typeof t==="object"?t!==null:typeof t==="function"};var m=function(t,e){if(!y(t))return t;var i,n;if(e&&typeof(i=t.toString)=="function"&&!y(n=i.call(t)))return n;if(typeof(i=t.valueOf)=="function"&&!y(n=i.call(t)))return n;if(!e&&typeof(i=t.toString)=="function"&&!y(n=i.call(t)))return n;throw TypeError("Can't convert object to primitive value")};var w={}.hasOwnProperty;var x=function(t,e){return w.call(t,e)};var C=c.document;var k=y(C)&&y(C.createElement);var M=function(t){return k?C.createElement(t):{}};var S=!d&&!r(function(){return Object.defineProperty(M("div"),"a",{get:function(){return 7}}).a!=7});var O=Object.getOwnPropertyDescriptor;var j=d?O:function t(e,i){e=p(e);i=m(i,true);if(S)try{return O(e,i)}catch(t){}if(x(e,i))return l(!g.f.call(e,i),e[i])};var A={f:j};var B=function(t){if(!y(t)){throw TypeError(String(t)+" is not an object")}return t};var T=Object.defineProperty;var W=d?T:function t(e,i,n){B(e);i=m(i,true);B(n);if(S)try{return T(e,i,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");if("value"in n)e[i]=n.value;return e};var E={f:W};var z=d?function(t,e,i){return E.f(t,e,l(1,i))}:function(t,e,i){t[e]=i;return t};var H=function(e,i){try{z(c,e,i)}catch(t){c[e]=i}return i};var P=e(function(t){var e="__core-js_shared__";var i=c[e]||H(e,{});(t.exports=function(t,e){return i[t]||(i[t]=e!==undefined?e:{})})("versions",[]).push({version:"3.2.1",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})});var D=P("native-function-to-string",Function.toString);var L=c.WeakMap;var F=typeof L==="function"&&/native code/.test(D.call(L));var R=0;var q=Math.random();var N=function(t){return"Symbol("+String(t===undefined?"":t)+")_"+(++R+q).toString(36)};var G=P("keys");var I=function(t){return G[t]||(G[t]=N(t))};var V={};var K=c.WeakMap;var Y,J,Q;var U=function(t){return Q(t)?J(t):Y(t,{})};var X=function(i){return function(t){var e;if(!y(t)||(e=J(t)).type!==i){throw TypeError("Incompatible receiver, "+i+" required")}return e}};if(F){var Z=new K;var $=Z.get;var tt=Z.has;var et=Z.set;Y=function(t,e){et.call(Z,t,e);return e};J=function(t){return $.call(Z,t)||{}};Q=function(t){return tt.call(Z,t)}}else{var it=I("state");V[it]=true;Y=function(t,e){z(t,it,e);return e};J=function(t){return x(t,it)?t[it]:{}};Q=function(t){return x(t,it)}}var nt={set:Y,get:J,has:Q,enforce:U,getterFor:X};var rt=e(function(t){var e=nt.get;var s=nt.enforce;var h=String(D).split("toString");P("inspectSource",function(t){return D.call(t)});(t.exports=function(t,e,i,n){var r=n?!!n.unsafe:false;var a=n?!!n.enumerable:false;var o=n?!!n.noTargetGet:false;if(typeof i=="function"){if(typeof e=="string"&&!x(i,"name"))z(i,"name",e);s(i).source=h.join(typeof e=="string"?e:"")}if(t===c){if(a)t[e]=i;else H(e,i);return}else if(!r){delete t[e]}else if(!o&&t[e]){a=true}if(a)t[e]=i;else z(t,e,i)})(Function.prototype,"toString",function t(){return typeof this=="function"&&e(this).source||D.call(this)})});var at=c;var ot=function(t){return typeof t=="function"?t:undefined};var st=function(t,e){return arguments.length<2?ot(at[t])||ot(c[t]):at[t]&&at[t][e]||c[t]&&c[t][e]};var ht=Math.ceil;var lt=Math.floor;var ut=function(t){return isNaN(t=+t)?0:(t>0?lt:ht)(t)};var ct=Math.min;var ft=function(t){return t>0?ct(ut(t),9007199254740991):0};var dt=Math.max;var gt=Math.min;var _t=function(t,e){var i=ut(t);return i<0?dt(i+e,0):gt(i,e)};var vt=function(s){return function(t,e,i){var n=p(t);var r=ft(n.length);var a=_t(i,r);var o;if(s&&e!=e)while(r>a){o=n[a++];if(o!=o)return true}else for(;r>a;a++){if((s||a in n)&&n[a]===e)return s||a||0}return!s&&-1}};var pt={includes:vt(true),indexOf:vt(false)};var yt=pt.indexOf;var mt=function(t,e){var i=p(t);var n=0;var r=[];var a;for(a in i)!x(V,a)&&x(i,a)&&r.push(a);while(e.length>n)if(x(i,a=e[n++])){~yt(r,a)||r.push(a)}return r};var bt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"];var wt=bt.concat("length","prototype");var xt=Object.getOwnPropertyNames||function t(e){return mt(e,wt)};var Ct={f:xt};var kt=Object.getOwnPropertySymbols;var Mt={f:kt};var St=st("Reflect","ownKeys")||function t(e){var i=Ct.f(B(e));var n=Mt.f;return n?i.concat(n(e)):i};var Ot=function(t,e){var i=St(e);var n=E.f;var r=A.f;for(var a=0;a<i.length;a++){var o=i[a];if(!x(t,o))n(t,o,r(e,o))}};var jt=/#|\.prototype\./;var At=function(t,e){var i=Tt[Bt(t)];return i==Et?true:i==Wt?false:typeof e=="function"?r(e):!!e};var Bt=At.normalize=function(t){return String(t).replace(jt,".").toLowerCase()};var Tt=At.data={};var Wt=At.NATIVE="N";var Et=At.POLYFILL="P";var zt=At;var Ht=A.f;var Pt=function(t,e){var i=t.target;var n=t.global;var r=t.stat;var a,o,s,h,l,u;if(n){o=c}else if(r){o=c[i]||H(i,{})}else{o=(c[i]||{}).prototype}if(o)for(s in e){l=e[s];if(t.noTargetGet){u=Ht(o,s);h=u&&u.value}else h=o[s];a=zt(n?s:i+(r?".":"#")+s,t.forced);if(!a&&h!==undefined){if(typeof l===typeof h)continue;Ot(l,h)}if(t.sham||h&&h.sham){z(l,"sham",true)}rt(o,s,l,t)}};var Dt=function(t){if(typeof t!="function"){throw TypeError(String(t)+" is not a function")}return t};var Lt=function(n,r,t){Dt(n);if(r===undefined)return n;switch(t){case 0:return function(){return n.call(r)};case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,i){return n.call(r,t,e,i)}}return function(){return n.apply(r,arguments)}};var Ft=function(t){return Object(v(t))};var Rt=Array.isArray||function t(e){return f(e)=="Array"};var qt=!!Object.getOwnPropertySymbols&&!r(function(){return!String(Symbol())});var Nt=c.Symbol;var Gt=P("wks");var It=function(t){return Gt[t]||(Gt[t]=qt&&Nt[t]||(qt?Nt:N)("Symbol."+t))};var Vt=It("species");var Kt=function(t,e){var i;if(Rt(t)){i=t.constructor;if(typeof i=="function"&&(i===Array||Rt(i.prototype)))i=undefined;else if(y(i)){i=i[Vt];if(i===null)i=undefined}}return new(i===undefined?Array:i)(e===0?0:e)};var Yt=[].push;var Jt=function(d){var g=d==1;var _=d==2;var v=d==3;var p=d==4;var y=d==6;var m=d==5||y;return function(t,e,i,n){var r=Ft(t);var a=b(r);var o=Lt(e,i,3);var s=ft(a.length);var h=0;var l=n||Kt;var u=g?l(t,s):_?l(t,0):undefined;var c,f;for(;s>h;h++)if(m||h in a){c=a[h];f=o(c,h,r);if(d){if(g)u[h]=f;else if(f)switch(d){case 3:return true;case 5:return c;case 6:return h;case 2:Yt.call(u,c)}else if(p)return false}}return y?-1:v||p?p:u}};var Qt={forEach:Jt(0),map:Jt(1),filter:Jt(2),some:Jt(3),every:Jt(4),find:Jt(5),findIndex:Jt(6)};var Ut=Object.keys||function t(e){return mt(e,bt)};var Xt=d?Object.defineProperties:function t(e,i){B(e);var n=Ut(i);var r=n.length;var a=0;var o;while(r>a)E.f(e,o=n[a++],i[o]);return e};var Zt=st("document","documentElement");var $t=I("IE_PROTO");var te="prototype";var ee=function(){};var ie=function(){var t=M("iframe");var e=bt.length;var i="<";var n="script";var r=">";var a="java"+n+":";var o;t.style.display="none";Zt.appendChild(t);t.src=String(a);o=t.contentWindow.document;o.open();o.write(i+n+r+"document.F=Object"+i+"/"+n+r);o.close();ie=o.F;while(e--)delete ie[te][bt[e]];return ie()};var ne=Object.create||function t(e,i){var n;if(e!==null){ee[te]=B(e);n=new ee;ee[te]=null;n[$t]=e}else n=ie();return i===undefined?n:Xt(n,i)};V[$t]=true;var re=It("unscopables");var ae=Array.prototype;if(ae[re]==undefined){z(ae,re,ne(null))}var oe=function(t){ae[re][t]=true};var se=Qt.find;var he="find";var le=true;if(he in[])Array(1)[he](function(){le=false});Pt({target:"Array",proto:true,forced:le},{find:function t(e){return se(this,e,arguments.length>1?arguments[1]:undefined)}});oe(he);var ue=pt.includes;Pt({target:"Array",proto:true},{includes:function t(e){return ue(this,e,arguments.length>1?arguments[1]:undefined)}});oe("includes");var ce=Object.assign;var fe=!ce||r(function(){var t={};var e={};var i=Symbol();var n="abcdefghijklmnopqrst";t[i]=7;n.split("").forEach(function(t){e[t]=t});return ce({},t)[i]!=7||Ut(ce({},e)).join("")!=n})?function t(e,i){var n=Ft(e);var r=arguments.length;var a=1;var o=Mt.f;var s=g.f;while(r>a){var h=b(arguments[a++]);var l=o?Ut(h).concat(o(h)):Ut(h);var u=l.length;var c=0;var f;while(u>c){f=l[c++];if(!d||s.call(h,f))n[f]=h[f]}}return n}:ce;Pt({target:"Object",stat:true,forced:Object.assign!==fe},{assign:fe});var de=It("match");var ge=function(t){var e;return y(t)&&((e=t[de])!==undefined?!!e:f(t)=="RegExp")};var _e=function(t){if(ge(t)){throw TypeError("The method doesn't accept regular expressions")}return t};var ve=It("match");var pe=function(e){var i=/./;try{"/./"[e](i)}catch(t){try{i[ve]=false;return"/./"[e](i)}catch(t){}}return false};Pt({target:"String",proto:true,forced:!pe("includes")},{includes:function t(e){return!!~String(v(this)).indexOf(_e(e),arguments.length>1?arguments[1]:undefined)}});var ye="".startsWith;var me=Math.min;Pt({target:"String",proto:true,forced:!pe("startsWith")},{startsWith:function t(e){var i=String(v(this));_e(e);var n=ft(me(arguments.length>1?arguments[1]:undefined,i.length));var r=String(e);return ye?ye.call(i,r,n):i.slice(n,n+r.length)===r}});if(typeof window!=="undefined"){(function(){var n=function(t,e){var i=t.nodeType;if(i===3){e.push(t.textContent.replace(/&/,"&").replace(/</,"<").replace(">",">"))}else if(i===1){e.push("<",t.tagName);if(t.hasAttributes()){[].forEach.call(t.attributes,function(t){e.push(" ",t.item.name,"='",t.item.value,"'")})}if(t.hasChildNodes()){e.push(">");[].forEach.call(t.childNodes,function(t){n(t,e)});e.push("</",t.tagName,">")}else{e.push("/>")}}else if(i==8){e.push("\x3c!--",t.nodeValue,"--\x3e")}};Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var t=[];var e=this.firstChild;while(e){n(e,t);e=e.nextSibling}return t.join("")},set:function(t){while(this.firstChild){this.removeChild(this.firstChild)}try{var e=new DOMParser;e.async=false;var i="<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>";var n=e.parseFromString(i,"text/xml").documentElement;var r=n.firstChild;while(r){this.appendChild(this.ownerDocument.importNode(r,true));r=r.nextSibling}}catch(t){}}});Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})})()}});(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-selection"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-text"),require("d3-scale"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-format")):typeof define==="function"&&define.amd?define("d3plus-legend",["exports","d3-array","d3-selection","d3plus-common","d3plus-shape","d3plus-text","d3-scale","d3plus-axis","d3plus-color","d3plus-format"],e):(t=t||self,e(t.d3plus={},t.d3Array,t.d3Selection,t.d3plusCommon,t.shapes,t.d3plusText,t.d3Scale,t.d3plusAxis,t.d3plusColor,t.d3plusFormat))})(this,function(t,st,ht,lt,w,ut,ct,i,ft,dt){"use strict";function u(t){return t.slice().sort(function(t,e){return t-e})}function c(t){var e,i=0;for(var n=0;n<t.length;n++){if(n===0||t[n]!==e){e=t[n];i++}}return i}function f(t,e){var i=[];for(var n=0;n<t;n++){var r=[];for(var a=0;a<e;a++){r.push(0)}i.push(r)}return i}function _(t,e,i,n){var r;if(t>0){var a=(i[e]-i[t-1])/(e-t+1);r=n[e]-n[t-1]-(e-t+1)*a*a}else r=n[e]-i[e]*i[e]/(e+1);if(r<0)return 0;return r}function v(t,e,i,n,r,a,o){if(t>e)return;var s=Math.floor((t+e)/2);n[i][s]=n[i-1][s-1];r[i][s]=s;var h=i;if(t>i)h=Math.max(h,r[i][t-1]||0);h=Math.max(h,r[i-1][s]||0);var l=s-1;if(e<n.length-1)l=Math.min(l,r[i][e+1]||0);for(var u=l;u>=h;--u){var c=_(u,s,a,o);if(c+n[i-1][h-1]>=n[i][s])break;var f=_(h,s,a,o);var d=f+n[i-1][h-1];if(d<n[i][s]){n[i][s]=d;r[i][s]=h}h++;var g=c+n[i-1][u-1];if(g<n[i][s]){n[i][s]=g;r[i][s]=u}}v(t,s-1,i,n,r,a,o);v(s+1,e,i,n,r,a,o)}function d(t,e,i){var n=e[0]?e[0].length:0;var r=t[Math.floor(n/2)];var a=[];var o=[];for(var s=0,h=void 0;s<n;++s){h=t[s]-r;if(s===0){a.push(h);o.push(h*h)}else{a.push(a[s-1]+h);o.push(o[s-1]+h*h)}e[0][s]=_(0,s,a,o);i[0][s]=0}for(var l=1;l<e.length;++l){var u=n-1;if(l<e.length-1)u=l;v(u,n-1,l,e,i,a,o)}}function gt(t,e){if(e>t.length){throw new Error("Cannot generate more classes than there are data values")}var i=u(t);var n=c(i);if(n===1){return[i]}var r=f(e,i.length),a=f(e,i.length);d(i,a,r);var o=r[0]?r[0].length-1:0;var s=[];for(var h=r.length-1;h>=0;h--){var l=r[h][o];s[h]=i.slice(l,o+1);if(h>0)o=l-1}return s}function n(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}}function r(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}function a(t,e,i){if(e)r(t.prototype,e);if(i)r(t,i);return t}function _t(t,e,i){if(e in t){Object.defineProperty(t,e,{value:i,enumerable:true,configurable:true,writable:true})}else{t[e]=i}return t}function o(t,e){if(typeof e!=="function"&&e!==null){throw new TypeError("Super expression must either be null or a function")}t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}});if(e)s(t,e)}function h(t){h=Object.setPrototypeOf?Object.getPrototypeOf:function t(e){return e.__proto__||Object.getPrototypeOf(e)};return h(t)}function s(t,e){s=Object.setPrototypeOf||function t(e,i){e.__proto__=i;return e};return s(t,e)}function l(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function g(t,e){if(e&&(typeof e==="object"||typeof e==="function")){return e}return l(t)}var p=function(t){o(e,t);function e(){var s;n(this,e);s=g(this,h(e).call(this));s._align="center";s._data=[];s._direction="row";s._duration=600;s._height=200;s._id=lt.accessor("id");s._label=lt.accessor("id");s._lineData=[];s._outerBounds={width:0,height:0,x:0,y:0};s._padding=5;s._shape=lt.constant("Rect");s._shapes=[];s._shapeConfig={duration:s._duration,fill:lt.accessor("color"),height:lt.constant(10),hitArea:function t(e,i){var n=s._lineData[i],r=st.max([n.height,n.shapeHeight]);return{width:n.width+n.shapeWidth,height:r,x:-n.shapeWidth/2,y:-r/2}},labelBounds:function t(e,i){var n=s._lineData[i];var r=n.shapeWidth;if(n.shape==="Circle")r-=n.shapeR;var a=st.max([n.shapeHeight,n.height]);return{width:n.width,height:a,x:r,y:-a/2}},labelConfig:{fontColor:lt.constant("#444"),fontFamily:(new ut.TextBox).fontFamily(),fontResize:false,fontSize:lt.constant(10),verticalAlign:"middle"},opacity:1,r:lt.constant(5),width:lt.constant(10),x:function t(e,i){var n=s._lineData[i];var r=n.y;var a=s._align==="left"||s._align==="right"&&s._direction==="column"?0:s._align==="center"?(s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return r===t.y})))/2:s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return r===t.y}));var o=s._lineData.slice(0,i).filter(function(t){return r===t.y});return s._rowWidth(o)+s._padding*(o.length?n.sentence?2:1:0)+s._outerBounds.x+n.shapeWidth/2+a},y:function t(e,i){var n=s._lineData[i];return n.y+s._titleHeight+s._outerBounds.y+st.max(s._lineData.filter(function(t){return n.y===t.y}).map(function(t){return t.height}).concat(s._data.map(function(t,e){return s._fetchConfig("height",t,e)})))/2}};s._titleClass=new ut.TextBox;s._titleConfig={};s._verticalAlign="middle";s._width=400;return s}a(e,[{key:"_fetchConfig",value:function t(e,i,n){var r=this._shapeConfig[e]||this._shapeConfig.labelConfig[e];if(!r&&e==="lineHeight")return this._fetchConfig("fontSize",i,n)*1.4;return typeof r==="function"?r(i,n):r}},{key:"_rowHeight",value:function t(e){return st.max(e.map(function(t){return t.height}).concat(e.map(function(t){return t.shapeHeight})))+this._padding}},{key:"_rowWidth",value:function t(n){var r=this;return st.sum(n.map(function(t,e){var i=r._padding*(e===n.length-1?0:t.width?2:1);return t.shapeWidth+t.width+i}))}},{key:"render",value:function t(e){var c=this;if(this._select===void 0)this.select(ht.select("body").append("svg").attr("width","".concat(this._width,"px")).attr("height","".concat(this._height,"px")).node());this._group=lt.elem("g.d3plus-Legend",{parent:this._select});var f=this._height;this._titleHeight=0;this._titleWidth=0;if(this._title){var i=this._titleConfig.fontFamily||this._titleClass.fontFamily()(),n=this._titleConfig.fontSize||this._titleClass.fontSize()();var r=r=this._titleConfig.lineHeight||this._titleClass.lineHeight();r=r?r():n*1.4;var a=ut.textWrap().fontFamily(i).fontSize(n).lineHeight(r).width(this._width).height(this._height)(this._title);this._titleHeight=r+a.lines.length+this._padding;this._titleWidth=st.max(a.widths);f-=this._titleHeight}this._lineData=this._data.map(function(t,e){var i=c._label(t,e);var n=c._shape(t,e);var r=c._fetchConfig("r",t,e);var a={data:t,i:e,id:c._id(t,e),shape:n,shapeR:r,shapeWidth:n==="Circle"?r*2:c._fetchConfig("width",t,e),shapeHeight:n==="Circle"?r*2:c._fetchConfig("height",t,e),y:0};if(!i){a.sentence=false;a.words=[];a.height=0;a.width=0;return a}var o=c._fetchConfig("fontFamily",t,e),s=c._fetchConfig("lineHeight",t,e),h=c._fetchConfig("fontSize",t,e);var l=f-(c._data.length+1)*c._padding,u=c._width;a=Object.assign(a,ut.textWrap().fontFamily(o).fontSize(h).lineHeight(s).width(u).height(l)(i));a.width=Math.ceil(st.max(a.lines.map(function(t){return ut.textWidth(t,{"font-family":o,"font-size":h})})))+h*.75;a.height=Math.ceil(a.lines.length*(s+1));a.og={height:a.height,width:a.width};a.f=o;a.s=h;a.lh=s;return a});var o;var h=this._width-this._padding*2;o=this._rowWidth(this._lineData);if(this._direction==="column"||o>h){var l=1,u=[];var d=st.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var e=this;l++;if(l>d)return;var o=l===1?this._lineData.slice():this._lineData.filter(function(t){return t.width+t.shapeWidth+e._padding*(t.width?2:1)>h&&t.words.length>=l}).sort(function(t,e){return e.sentence.length-t.sentence.length});if(o.length&&f>o[0].height*l){var s=false;var t=function t(e){var i=o[e];var n=i.og.height*l,r=i.og.width*(1.5*(1/l));var a=ut.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(r).height(n)(i.sentence);if(!a.truncated){i.width=Math.ceil(st.max(a.lines.map(function(t){return ut.textWidth(t,{"font-family":i.f,"font-size":i.s})})))+i.s;i.height=a.lines.length*(i.lh+1)}else{s=true;return"break"}};for(var i=0;i<o.length;i++){var n=t(i);if(n==="break")break}if(!s)this._wrapRows()}else{u=[];return}};this._wrapRows=function(){u=[];var t=1,e=0;for(var i=0;i<this._lineData.length;i++){var n=this._lineData[i],r=n.width+this._padding*(n.width?2:1)+n.shapeWidth;if(st.sum(u.map(function(t){return st.max(t,function(t){return st.max([t.height,t.shapeHeight])})}))>f){u=[];break}if(r>h){u=[];this._wrapLines();break}else if(e+r<h){e+=r}else if(this._direction!=="column"){e=r;t++}if(!u[t-1])u[t-1]=[];u[t-1].push(n);if(this._direction==="column"){e=0;t++}}};this._wrapRows();if(!u.length||st.sum(u,this._rowHeight.bind(this))+this._padding>f){o=st.sum(this._lineData.map(function(t){return t.shapeWidth+c._padding}))-this._padding;for(var s=0;s<this._lineData.length;s++){this._lineData[s].width=0;this._lineData[s].height=0}this._wrapRows()}if(u.length&&st.sum(u,this._rowHeight.bind(this))+this._padding<f){u.forEach(function(t,e){t.forEach(function(t){if(e){t.y=st.sum(u.slice(0,e),c._rowHeight.bind(c))}})});o=st.max(u,this._rowWidth.bind(this))}}var g=st.max(this._lineData,function(t,e){return st.max([t.height,c._fetchConfig("height",t.data,e)])+t.y})+this._titleHeight,_=st.max([o,this._titleWidth]);this._outerBounds.width=_;this._outerBounds.height=g;var v=this._padding,p=this._padding;if(this._align==="center")v=(this._width-_)/2;else if(this._align==="right")v=this._width-this._padding-_;if(this._verticalAlign==="middle")p=(this._height-g)/2;else if(this._verticalAlign==="bottom")p=this._height-this._padding-g;this._outerBounds.x=v;this._outerBounds.y=p;this._titleClass.data(this._title?[{text:this._title}]:[]).duration(this._duration).select(this._group.node()).textAnchor({left:"start",center:"middle",right:"end"}[this._align]).width(this._width-this._padding*2).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render();this._shapes=[];var y=lt.configPrep.bind(this)(this._shapeConfig,"legend"),m={id:function t(e){return e.id},label:function t(e){return e.label},lineHeight:function t(e){return e.lH}};var b=this._data.map(function(t,e){var i={__d3plus__:true,data:t,i:e,id:c._id(t,e),label:c._lineData[e].width?c._label(t,e):false,lH:c._fetchConfig("lineHeight",t,e),shape:c._shape(t,e)};return i});this._shapes=[];["Circle","Rect"].forEach(function(e){c._shapes.push((new w[e]).data(b.filter(function(t){return t.shape===e})).duration(c._duration).labelConfig({padding:0}).select(c._group.node()).verticalAlign("top").config(lt.assign({},y,m)).render())});if(e)setTimeout(e,this._duration+100);return this}},{key:"active",value:function t(e){this._shapes.forEach(function(t){return t.active(e)});return this}},{key:"align",value:function t(e){return arguments.length?(this._align=e,this):this._align}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"direction",value:function t(e){return arguments.length?(this._direction=e,this):this._direction}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"height",value:function t(e){return arguments.length?(this._height=e,this):this._height}},{key:"hover",value:function t(e){this._shapes.forEach(function(t){return t.hover(e)});return this}},{key:"id",value:function t(e){return arguments.length?(this._id=e,this):this._id}},{key:"label",value:function t(e){return arguments.length?(this._label=typeof e==="function"?e:lt.constant(e),this):this._label}},{key:"outerBounds",value:function t(){return this._outerBounds}},{key:"padding",value:function t(e){return arguments.length?(this._padding=e,this):this._padding}},{key:"select",value:function t(e){return arguments.length?(this._select=ht.select(e),this):this._select}},{key:"shape",value:function t(e){return arguments.length?(this._shape=typeof e==="function"?e:lt.constant(e),this):this._shape}},{key:"shapeConfig",value:function t(e){return arguments.length?(this._shapeConfig=lt.assign(this._shapeConfig,e),this):this._shapeConfig}},{key:"title",value:function t(e){return arguments.length?(this._title=e,this):this._title}},{key:"titleConfig",value:function t(e){return arguments.length?(this._titleConfig=lt.assign(this._titleConfig,e),this):this._titleConfig}},{key:"verticalAlign",value:function t(e){return arguments.length?(this._verticalAlign=e,this):this._verticalAlign}},{key:"width",value:function t(e){return arguments.length?(this._width=e,this):this._width}}]);return e}(lt.BaseClass);var e=function(t){o(e,t);function e(){var t;n(this,e);t=g(this,h(e).call(this));t._axisClass=new i.Axis;t._axisConfig={gridSize:0,shapeConfig:{labelConfig:{fontColor:"#222"}},titleConfig:{fontSize:12}};t._axisTest=new i.Axis;t._align="middle";t._buckets=5;t._bucketAxis=false;t._colorMax="#0C8040";t._colorMid="#f7f7f7";t._colorMin="#b22200";t._data=[];t._duration=600;t._height=200;t._labelClass=new ut.TextBox;t._legendClass=new p;t._legendConfig={shapeConfig:{labelConfig:{fontColor:"#222"},stroke:"#444",strokeWidth:1}};t._midpoint=0;t._orient="bottom";t._outerBounds={width:0,height:0,x:0,y:0};t._padding=5;t._rectClass=new w.Rect;t._rectConfig={stroke:"#444",strokeWidth:1};t._scale="linear";t._size=10;t._value=lt.accessor("value");t._width=400;return t}a(e,[{key:"render",value:function t(e){var i=this;if(this._select===void 0)this.select(ht.select("body").append("svg").attr("width","".concat(this._width,"px")).attr("height","".concat(this._height,"px")).node());var n=["bottom","top"].includes(this._orient);var r=n?"height":"width",a=n?"width":"height",o=n?"x":"y",s=n?"y":"x";this._group=lt.elem("g.d3plus-ColorScale",{parent:this._select});var h=st.extent(this._data,this._value);var l=h[0]<this._midpoint;var u=h[1]>this._midpoint;var c=l&&u;var f=this._color,d,g;if(f&&!(f instanceof Array)){f=st.range(0,this._buckets,1).map(function(t){return ft.colorLighter(f,(t+1)/i._buckets)}).reverse()}if(this._scale==="jenks"){var _=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});var v=st.min([f?f.length:this._buckets,_.length]);var p=gt(_,v);g=st.merge(p.map(function(t,e){return e===p.length-1?[t[0],t[t.length-1]]:[t[0]]}));var y=new Set(g);if(g.length!==y.size){d=Array.from(y)}if(!f){if(c){f=[this._colorMin,this._colorMid,this._colorMax];var m=g.slice(0,v).filter(function(t,e){return t<i._midpoint&&g[e+1]<=i._midpoint});var b=g.slice(0,v).filter(function(t,e){return t<=i._midpoint&&g[e+1]>i._midpoint});var w=g.slice(0,v).filter(function(t,e){return t>i._midpoint&&g[e+1]>i._midpoint});var x=m.map(function(t,e){return!e?f[0]:ft.colorLighter(f[0],e/m.length)});var C=b.map(function(){return f[1]});var k=w.map(function(t,e){return e===w.length-1?f[2]:ft.colorLighter(f[2],1-(e+1)/w.length)});f=x.concat(C).concat(k)}else{f=st.range(0,this._buckets,1).map(function(t){return ft.colorLighter(i._colorMax,t/i._buckets)}).reverse()}}if(_.length<=v){f=f.slice(v-_.length)}this._colorScale=ct.scaleThreshold().domain(g).range(["black"].concat(f).concat(f[f.length-1]))}else{var M;if(c&&!f){var S=Math.floor(this._buckets/2);var O=st.range(0,S,1).map(function(t){return!t?i._colorMin:ft.colorLighter(i._colorMin,t/S)});var j=(this._buckets%2?[0]:[]).map(function(){return i._colorMid});var A=st.range(0,S,1).map(function(t){return!t?i._colorMax:ft.colorLighter(i._colorMax,t/S)}).reverse();f=O.concat(j).concat(A);var B=(f.length-1)/2;M=[h[0],this._midpoint,h[1]];M=st.range(h[0],this._midpoint,-(h[0]-this._midpoint)/B).concat(st.range(this._midpoint,h[1],(h[1]-this._midpoint)/B)).concat([h[1]])}else{if(!f){if(this._scale==="buckets"){f=st.range(0,this._buckets,1).map(function(t){return ft.colorLighter(l?i._colorMin:i._colorMax,t/i._buckets)});if(u)f=f.reverse()}else{f=l?[this._colorMin,ft.colorLighter(this._colorMin,.8)]:[ft.colorLighter(this._colorMax,.8),this._colorMax]}}var T=(h[1]-h[0])/(f.length-1);M=st.range(h[0],h[1]+T/2,T)}if(this._scale==="buckets"){g=M.concat([M[M.length-1]])}if(this._scale==="log"){var W=M.filter(function(t){return t<0});if(W.length){var E=W[0];var z=W.map(function(t){return-Math.pow(Math.abs(E),t/E)});W.forEach(function(t,e){M[M.indexOf(t)]=z[e]})}var H=M.filter(function(t){return t>0});if(H.length){var P=H[H.length-1];var D=H.map(function(t){return Math.pow(P,t/P)});H.forEach(function(t,e){M[M.indexOf(t)]=D[e]})}if(M.includes(0))M[M.indexOf(0)]=1}this._colorScale=ct.scaleLinear().domain(M).range(f)}if(this._bucketAxis||!["buckets","jenks"].includes(this._scale)){var L;var F={x:0,y:0};var R=lt.assign({domain:n?h:h.reverse(),duration:this._duration,height:this._height,labels:d||g,orient:this._orient,padding:this._padding,scale:this._scale==="log"?"log":"linear",ticks:g,width:this._width},this._axisConfig);var q=lt.assign({height:this["_".concat(r)]/2,width:this["_".concat(a)]/2},this._labelConfig||this._axisConfig.titleConfig);this._labelClass.config(q);var N=[];if(n&&this._labelMin){var G={"font-family":this._labelClass.fontFamily()(this._labelMin),"font-size":this._labelClass.fontSize()(this._labelMin),"font-weight":this._labelClass.fontWeight()(this._labelMin)};if(G["font-family"]instanceof Array)G["font-family"]=G["font-family"][0];var I=ut.textWidth(this._labelMin,G);if(I&&I<this["_".concat(a)]/2){N.push(this._labelMin);I+=this._padding;if(n)F.x+=I;R[a]-=I}}if(n&&this._labelMax){var V={"font-family":this._labelClass.fontFamily()(this._labelMax),"font-size":this._labelClass.fontSize()(this._labelMax),"font-weight":this._labelClass.fontWeight()(this._labelMax)};if(V["font-family"]instanceof Array)V["font-family"]=V["font-family"][0];var K=ut.textWidth(this._labelMax,V);if(K&&K<this["_".concat(a)]/2){N.push(this._labelMax);K+=this._padding;if(!n)F.y+=K;R[a]-=K}}this._axisTest.select(lt.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(R).duration(0).render();var Y=this._axisTest.outerBounds();this._outerBounds[a]=this["_".concat(a)]-this._padding*2;this._outerBounds[r]=Y[r]+this._size;this._outerBounds[o]=this._padding;this._outerBounds[s]=this._padding;if(this._align==="middle")this._outerBounds[s]=(this["_".concat(r)]-this._outerBounds[r])/2;else if(this._align==="end")this._outerBounds[s]=this["_".concat(r)]-this._padding-this._outerBounds[r];var J=this._outerBounds[s]+(["bottom","right"].includes(this._orient)?this._size:0)-(R.padding||this._axisClass.padding());this._axisClass.select(lt.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate(".concat(F.x+(n?0:J),", ").concat(F.y+(n?J:0),")")}}).node()).config(R).align("start").render();var Q=this._axisTest._getPosition.bind(this._axisTest);var U=this._axisTest._getRange();var X=this._group.selectAll("defs").data([0]);var Z=X.enter().append("defs");Z.append("linearGradient").attr("id","gradient-".concat(this._uuid));X=Z.merge(X);X.select("linearGradient").attr("".concat(o,"1"),n?"0%":"100%").attr("".concat(o,"2"),n?"100%":"0%").attr("".concat(s,"1"),"0%").attr("".concat(s,"2"),"0%");var $=X.select("linearGradient").selectAll("stop").data(n?f:f);var tt=this._colorScale.domain();var et=ct.scaleLinear().domain(U).range(n?[0,100]:[100,0]);$.enter().append("stop").merge($).attr("offset",function(t,e){return"".concat(et(Q(tt[e])),"%")}).attr("stop-color",String);var it=function t(e,i){var n=Math.abs(Q(g[i+1])-Q(e));return n||2};var nt=lt.assign((L={duration:this._duration,fill:g?function(t){return i._colorScale(t)}:"url(#gradient-".concat(this._uuid,")")},_t(L,o,g?function(t,e){return Q(t)+it(t,e)/2-(["left","right"].includes(i._orient)?it(t,e):0)}:U[0]+(U[1]-U[0])/2+F[o]),_t(L,s,this._outerBounds[s]+(["top","left"].includes(this._orient)?Y[r]:0)+this._size/2+F[s]),_t(L,a,g?it:U[1]-U[0]),_t(L,r,this._size),L),this._rectConfig);this._rectClass.data(g?g.slice(0,g.length-1):[0]).id(function(t,e){return e}).select(lt.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config(nt).render();q.height=this._outerBounds[r];q.width=this._outerBounds[a];this._labelClass.config(q).data(N).select(lt.elem("g.d3plus-ColorScale-labels",{parent:this._group}).node()).x(function(t){return t===i._labelMax?nt.x+nt.width/2+i._padding:i._outerBounds.x}).y(function(t){return nt.y-i._labelClass.fontSize()(t)/2}).text(function(t){return t}).rotate(n?0:this._orient==="right"?90:-90).render()}else{var rt=this._axisConfig.tickFormat?this._axisConfig.tickFormat:dt.formatAbbreviate;var at=g.reduce(function(t,e,i){if(i!==g.length-1){var n=g[i+1];t.push({color:f[i],id:e===n?"".concat(rt(e),"+"):"".concat(rt(e)," - ").concat(rt(n))})}return t},[]);var ot=lt.assign({align:n?"center":{start:"left",middle:"center",end:"right"}[this._align],direction:n?"row":"column",duration:this._duration,height:this._height,padding:this._padding,shapeConfig:lt.assign({duration:this._duration},this._axisConfig.shapeConfig||{}),title:this._axisConfig.title,titleConfig:this._axisConfig.titleConfig||{},width:this._width,verticalAlign:n?{start:"top",middle:"middle",end:"bottom"}[this._align]:"middle"},this._legendConfig);this._legendClass.data(at).select(lt.elem("g.d3plus-ColorScale-legend",{parent:this._group}).node()).config(ot).render();this._outerBounds=this._legendClass.outerBounds()}if(e)setTimeout(e,this._duration+100);return this}},{key:"axisConfig",value:function t(e){return arguments.length?(this._axisConfig=lt.assign(this._axisConfig,e),this):this._axisConfig}},{key:"align",value:function t(e){return arguments.length?(this._align=e,this):this._align}},{key:"buckets",value:function t(e){return arguments.length?(this._buckets=e,this):this._buckets}},{key:"bucketAxis",value:function t(e){return arguments.length?(this._bucketAxis=e,this):this._bucketAxis}},{key:"color",value:function t(e){return arguments.length?(this._color=e,this):this._color}},{key:"colorMax",value:function t(e){return arguments.length?(this._colorMax=e,this):this._colorMax}},{key:"colorMid",value:function t(e){return arguments.length?(this._colorMid=e,this):this._colorMid}},{key:"colorMin",value:function t(e){return arguments.length?(this._colorMin=e,this):this._colorMin}},{key:"data",value:function t(e){return arguments.length?(this._data=e,this):this._data}},{key:"duration",value:function t(e){return arguments.length?(this._duration=e,this):this._duration}},{key:"height",value:function t(e){return arguments.length?(this._height=e,this):this._height}},{key:"labelConfig",value:function t(e){return arguments.length?(this._labelConfig=e,this):this._labelConfig}},{key:"labelMin",value:function t(e){return arguments.length?(this._labelMin=e,this):this._labelMin}},{key:"labelMax",value:function t(e){return arguments.length?(this._labelMax=e,this):this._labelMax}},{key:"legendConfig",value:function t(e){return arguments.length?(this._legendConfig=lt.assign(this._legendConfig,e),this):this._legendConfig}},{key:"midpoint",value:function t(e){return arguments.length?(this._midpoint=e,this):this._midpoint}},{key:"orient",value:function t(e){return arguments.length?(this._orient=e,this):this._orient}},{key:"outerBounds",value:function t(){return this._outerBounds}},{key:"padding",value:function t(e){return arguments.length?(this._padding=e,this):this._padding}},{key:"rectConfig",value:function t(e){return arguments.length?(this._rectConfig=lt.assign(this._rectConfig,e),this):this._rectConfig}},{key:"scale",value:function t(e){return arguments.length?(this._scale=e,this):this._scale}},{key:"select",value:function t(e){return arguments.length?(this._select=ht.select(e),this):this._select}},{key:"size",value:function t(e){return arguments.length?(this._size=e,this):this._size}},{key:"value",value:function t(e){return arguments.length?(this._value=typeof e==="function"?e:lt.constant(e),this):this._value}},{key:"width",value:function t(e){return arguments.length?(this._width=e,this):this._width}}]);return e}(lt.BaseClass);t.ColorScale=e;t.Legend=p;t.ckmeans=gt;Object.defineProperty(t,"__esModule",{value:true})}); |
@@ -35,2 +35,3 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
import { Rect } from "d3plus-shape"; | ||
import { TextBox, textWidth } from "d3plus-text"; | ||
/** | ||
@@ -80,2 +81,3 @@ @class ColorScale | ||
_this._height = 200; | ||
_this._labelClass = new TextBox(); | ||
_this._legendClass = new Legend(); | ||
@@ -277,4 +279,8 @@ _this._legendConfig = { | ||
if (this._bucketAxis || !["buckets", "jenks"].includes(this._scale)) { | ||
var _this$_rectClass$data; | ||
var _assign; | ||
var offsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
var axisConfig = assign({ | ||
@@ -291,3 +297,45 @@ domain: horizontal ? domain : domain.reverse(), | ||
}, this._axisConfig); | ||
var labelConfig = assign({ | ||
height: this["_".concat(height)] / 2, | ||
width: this["_".concat(width)] / 2 | ||
}, this._labelConfig || this._axisConfig.titleConfig); | ||
this._labelClass.config(labelConfig); | ||
var labelData = []; | ||
if (horizontal && this._labelMin) { | ||
var labelCSS = { | ||
"font-family": this._labelClass.fontFamily()(this._labelMin), | ||
"font-size": this._labelClass.fontSize()(this._labelMin), | ||
"font-weight": this._labelClass.fontWeight()(this._labelMin) | ||
}; | ||
if (labelCSS["font-family"] instanceof Array) labelCSS["font-family"] = labelCSS["font-family"][0]; | ||
var labelMinWidth = textWidth(this._labelMin, labelCSS); | ||
if (labelMinWidth && labelMinWidth < this["_".concat(width)] / 2) { | ||
labelData.push(this._labelMin); | ||
labelMinWidth += this._padding; | ||
if (horizontal) offsets.x += labelMinWidth; | ||
axisConfig[width] -= labelMinWidth; | ||
} | ||
} | ||
if (horizontal && this._labelMax) { | ||
var _labelCSS = { | ||
"font-family": this._labelClass.fontFamily()(this._labelMax), | ||
"font-size": this._labelClass.fontSize()(this._labelMax), | ||
"font-weight": this._labelClass.fontWeight()(this._labelMax) | ||
}; | ||
if (_labelCSS["font-family"] instanceof Array) _labelCSS["font-family"] = _labelCSS["font-family"][0]; | ||
var labelMaxWidth = textWidth(this._labelMax, _labelCSS); | ||
if (labelMaxWidth && labelMaxWidth < this["_".concat(width)] / 2) { | ||
labelData.push(this._labelMax); | ||
labelMaxWidth += this._padding; | ||
if (!horizontal) offsets.y += labelMaxWidth; | ||
axisConfig[width] -= labelMaxWidth; | ||
} | ||
} | ||
this._axisTest.select(elem("g.d3plus-ColorScale-axisTest", { | ||
@@ -308,3 +356,3 @@ enter: { | ||
var groupOffset = this._outerBounds[y] + (["bottom", "right"].includes(this._orient) ? this._size : 0) - (axisConfig.padding || this._axisClass.padding()); | ||
var axisGroupOffset = this._outerBounds[y] + (["bottom", "right"].includes(this._orient) ? this._size : 0) - (axisConfig.padding || this._axisClass.padding()); | ||
@@ -314,3 +362,3 @@ this._axisClass.select(elem("g.d3plus-ColorScale-axis", { | ||
update: { | ||
transform: "translate(".concat(horizontal ? 0 : groupOffset, ", ").concat(horizontal ? groupOffset : 0, ")") | ||
transform: "translate(".concat(offsets.x + (horizontal ? 0 : axisGroupOffset), ", ").concat(offsets.y + (horizontal ? axisGroupOffset : 0), ")") | ||
} | ||
@@ -329,7 +377,7 @@ }).node()).config(axisConfig).align("start").render(); | ||
defs.select("linearGradient").attr("".concat(x, "1"), horizontal ? "0%" : "100%").attr("".concat(x, "2"), horizontal ? "100%" : "0%").attr("".concat(y, "1"), "0%").attr("".concat(y, "2"), "0%"); | ||
var stops = defs.select("linearGradient").selectAll("stop").data(colors); | ||
var stops = defs.select("linearGradient").selectAll("stop").data(horizontal ? colors : colors); | ||
var scaleDomain = this._colorScale.domain(); | ||
var offsetScale = scaleLinear().domain(scaleRange).range([0, 100]); | ||
var offsetScale = scaleLinear().domain(scaleRange).range(horizontal ? [0, 100] : [100, 0]); | ||
stops.enter().append("stop").merge(stops).attr("offset", function (d, i) { | ||
@@ -345,7 +393,3 @@ return "".concat(offsetScale(axisScale(scaleDomain[i])), "%"); | ||
this._rectClass.data(ticks ? ticks.slice(0, ticks.length - 1) : [0]).id(function (d, i) { | ||
return i; | ||
}).select(elem("g.d3plus-ColorScale-Rect", { | ||
parent: this._group | ||
}).node()).config((_this$_rectClass$data = { | ||
var rectConfig = assign((_assign = { | ||
duration: this._duration, | ||
@@ -355,5 +399,24 @@ fill: ticks ? function (d) { | ||
} : "url(#gradient-".concat(this._uuid, ")") | ||
}, _defineProperty(_this$_rectClass$data, x, ticks ? function (d, i) { | ||
}, _defineProperty(_assign, x, ticks ? function (d, i) { | ||
return axisScale(d) + bucketWidth(d, i) / 2 - (["left", "right"].includes(_this2._orient) ? bucketWidth(d, i) : 0); | ||
} : scaleRange[0] + (scaleRange[1] - scaleRange[0]) / 2), _defineProperty(_this$_rectClass$data, y, this._outerBounds[y] + (["top", "left"].includes(this._orient) ? axisBounds[height] : 0) + this._size / 2), _defineProperty(_this$_rectClass$data, width, ticks ? bucketWidth : scaleRange[1] - scaleRange[0]), _defineProperty(_this$_rectClass$data, height, this._size), _this$_rectClass$data)).config(this._rectConfig).render(); | ||
} : scaleRange[0] + (scaleRange[1] - scaleRange[0]) / 2 + offsets[x]), _defineProperty(_assign, y, this._outerBounds[y] + (["top", "left"].includes(this._orient) ? axisBounds[height] : 0) + this._size / 2 + offsets[y]), _defineProperty(_assign, width, ticks ? bucketWidth : scaleRange[1] - scaleRange[0]), _defineProperty(_assign, height, this._size), _assign), this._rectConfig); | ||
this._rectClass.data(ticks ? ticks.slice(0, ticks.length - 1) : [0]).id(function (d, i) { | ||
return i; | ||
}).select(elem("g.d3plus-ColorScale-Rect", { | ||
parent: this._group | ||
}).node()).config(rectConfig).render(); | ||
labelConfig.height = this._outerBounds[height]; | ||
labelConfig.width = this._outerBounds[width]; | ||
this._labelClass.config(labelConfig).data(labelData).select(elem("g.d3plus-ColorScale-labels", { | ||
parent: this._group | ||
}).node()).x(function (d) { | ||
return d === _this2._labelMax ? rectConfig.x + rectConfig.width / 2 + _this2._padding : _this2._outerBounds.x; | ||
}).y(function (d) { | ||
return rectConfig.y - _this2._labelClass.fontSize()(d) / 2; | ||
}).text(function (d) { | ||
return d; | ||
}).rotate(horizontal ? 0 : this._orient === "right" ? 90 : -90).render(); | ||
} else { | ||
@@ -541,2 +604,38 @@ var format = this._axisConfig.tickFormat ? this._axisConfig.tickFormat : formatAbbreviate; | ||
@memberof ColorScale | ||
@desc A pass-through for the [TextBox](http://d3plus.org/docs/#TextBox) class used to style the labelMin and labelMax text. | ||
@param {Object} [*value*] | ||
@chainable | ||
*/ | ||
}, { | ||
key: "labelConfig", | ||
value: function labelConfig(_) { | ||
return arguments.length ? (this._labelConfig = _, this) : this._labelConfig; | ||
} | ||
/** | ||
@memberof ColorScale | ||
@desc Defines a text label to be displayed off of the end of the minimum point in the scale (currently only available in horizontal orientation). | ||
@param {String} [*value*] | ||
@chainable | ||
*/ | ||
}, { | ||
key: "labelMin", | ||
value: function labelMin(_) { | ||
return arguments.length ? (this._labelMin = _, this) : this._labelMin; | ||
} | ||
/** | ||
@memberof ColorScale | ||
@desc Defines a text label to be displayed off of the end of the maximum point in the scale (currently only available in horizontal orientation). | ||
@param {String} [*value*] | ||
@chainable | ||
*/ | ||
}, { | ||
key: "labelMax", | ||
value: function labelMax(_) { | ||
return arguments.length ? (this._labelMax = _, this) : this._labelMax; | ||
} | ||
/** | ||
@memberof ColorScale | ||
@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/). | ||
@@ -543,0 +642,0 @@ @param {Object} [*value*] |
{ | ||
"name": "d3plus-legend", | ||
"version": "0.8.28", | ||
"version": "0.8.29", | ||
"description": "An easy to use javascript chart legend.", | ||
@@ -29,5 +29,5 @@ "main": "build/d3plus-legend.js", | ||
"d3-selection": "^1.3.0", | ||
"d3plus-axis": "^0.4.17", | ||
"d3plus-axis": "^0.4.18", | ||
"d3plus-color": "^0.6.7", | ||
"d3plus-common": "^0.6.57", | ||
"d3plus-common": "^0.6.60", | ||
"d3plus-shape": "^0.16.13", | ||
@@ -34,0 +34,0 @@ "d3plus-text": "^0.9.50" |
@@ -17,6 +17,6 @@ # d3plus-legend | ||
* [Images in Legends](http://d3plus.org/examples/d3plus-legend/legend-image/) | ||
* [Removing Legend Labels](http://d3plus.org/examples/d3plus-legend/legend-remove-label/) | ||
* [Changing Style of a Color Scale](http://d3plus.org/examples/d3plus-legend/colorScale-dark/) | ||
* [Creating a Color Scale](http://d3plus.org/examples/d3plus-legend/colorScale/) | ||
* [Removing Legend Labels](http://d3plus.org/examples/d3plus-legend/legend-remove-label/) | ||
* [Images in Legends](http://d3plus.org/examples/d3plus-legend/legend-image/) | ||
@@ -32,3 +32,3 @@ ## API Reference | ||
<a name="ColorScale"></a> | ||
#### **ColorScale** [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L19) | ||
#### **ColorScale** [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L20) | ||
@@ -53,2 +53,5 @@ | ||
* [.height([*value*])](#ColorScale.height) ↩︎ | ||
* [.labelConfig([*value*])](#ColorScale.labelConfig) ↩︎ | ||
* [.labelMin([*value*])](#ColorScale.labelMin) ↩︎ | ||
* [.labelMax([*value*])](#ColorScale.labelMax) ↩︎ | ||
* [.legendConfig([*value*])](#ColorScale.legendConfig) ↩︎ | ||
@@ -75,3 +78,3 @@ * [.midpoint([*value*])](#ColorScale.midpoint) ↩︎ | ||
<a name="ColorScale.render" href="#ColorScale.render">#</a> ColorScale.**render**([*callback*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L89) | ||
<a name="ColorScale.render" href="#ColorScale.render">#</a> ColorScale.**render**([*callback*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L91) | ||
@@ -84,3 +87,3 @@ Renders the current ColorScale to the page. If a *callback* is specified, it will be called once the ColorScale is done drawing. | ||
<a name="ColorScale.axisConfig" href="#ColorScale.axisConfig">#</a> ColorScale.**axisConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L368) | ||
<a name="ColorScale.axisConfig" href="#ColorScale.axisConfig">#</a> ColorScale.**axisConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L436) | ||
@@ -93,3 +96,3 @@ 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/). | ||
<a name="ColorScale.align" href="#ColorScale.align">#</a> ColorScale.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L378) | ||
<a name="ColorScale.align" href="#ColorScale.align">#</a> ColorScale.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L446) | ||
@@ -102,3 +105,3 @@ If *value* is specified, sets the horizontal alignment to the specified value and returns the current class instance. If *value* is not specified, returns the current horizontal alignment. | ||
<a name="ColorScale.buckets" href="#ColorScale.buckets">#</a> ColorScale.**buckets**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L388) | ||
<a name="ColorScale.buckets" href="#ColorScale.buckets">#</a> ColorScale.**buckets**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L456) | ||
@@ -111,3 +114,3 @@ The number of discrete buckets to create in a bucketed color scale. Will be overridden by any custom Array of colors passed to the `color` method. | ||
<a name="ColorScale.bucketAxis" href="#ColorScale.bucketAxis">#</a> ColorScale.**bucketAxis**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L398) | ||
<a name="ColorScale.bucketAxis" href="#ColorScale.bucketAxis">#</a> ColorScale.**bucketAxis**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L466) | ||
@@ -120,3 +123,3 @@ Determines whether or not to use an Axis to display bucket scales (both "buckets" and "jenks"). When set to `false`, bucketed scales will use the `Legend` class to display squares for each range of data. When set to `true`, bucketed scales will be displayed on an `Axis`, similar to "linear" scales. | ||
<a name="ColorScale.color" href="#ColorScale.color">#</a> ColorScale.**color**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L408) | ||
<a name="ColorScale.color" href="#ColorScale.color">#</a> ColorScale.**color**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L476) | ||
@@ -129,3 +132,3 @@ Overrides the default internal logic of `colorMin`, `colorMid`, and `colorMax` to only use just this specified color. If a single color is given as a String, then the scale is interpolated by lightening that color. Otherwise, the function expects an Array of color values to be used in order for the scale. | ||
<a name="ColorScale.colorMax" href="#ColorScale.colorMax">#</a> ColorScale.**colorMax**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L418) | ||
<a name="ColorScale.colorMax" href="#ColorScale.colorMax">#</a> ColorScale.**colorMax**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L486) | ||
@@ -138,3 +141,3 @@ Defines the color to be used for numbers greater than the value of the `midpoint` on the scale (defaults to `0`). Colors in between this value and the value of `colorMid` will be interpolated, unless a custom Array of colors has been specified using the `color` method. | ||
<a name="ColorScale.colorMid" href="#ColorScale.colorMid">#</a> ColorScale.**colorMid**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L428) | ||
<a name="ColorScale.colorMid" href="#ColorScale.colorMid">#</a> ColorScale.**colorMid**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L496) | ||
@@ -147,3 +150,3 @@ Defines the color to be used for the midpoint of a diverging scale, based on the current value of the `midpoint` method (defaults to `0`). Colors in between this value and the values of `colorMin` and `colorMax` will be interpolated, unless a custom Array of colors has been specified using the `color` method. | ||
<a name="ColorScale.colorMin" href="#ColorScale.colorMin">#</a> ColorScale.**colorMin**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L438) | ||
<a name="ColorScale.colorMin" href="#ColorScale.colorMin">#</a> ColorScale.**colorMin**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L506) | ||
@@ -156,3 +159,3 @@ Defines the color to be used for numbers less than the value of the `midpoint` on the scale (defaults to `0`). Colors in between this value and the value of `colorMid` will be interpolated, unless a custom Array of colors has been specified using the `color` method. | ||
<a name="ColorScale.data" href="#ColorScale.data">#</a> ColorScale.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L448) | ||
<a name="ColorScale.data" href="#ColorScale.data">#</a> ColorScale.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L516) | ||
@@ -165,3 +168,3 @@ If *data* is specified, sets the data array to the specified array and returns the current class instance. If *data* is not specified, returns the current data array. A shape key will be drawn for each object in the array. | ||
<a name="ColorScale.duration" href="#ColorScale.duration">#</a> ColorScale.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L458) | ||
<a name="ColorScale.duration" href="#ColorScale.duration">#</a> ColorScale.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L526) | ||
@@ -174,3 +177,3 @@ If *value* is specified, sets the transition duration of the ColorScale and returns the current class instance. If *value* is not specified, returns the current duration. | ||
<a name="ColorScale.height" href="#ColorScale.height">#</a> ColorScale.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L468) | ||
<a name="ColorScale.height" href="#ColorScale.height">#</a> ColorScale.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L536) | ||
@@ -183,4 +186,28 @@ If *value* is specified, sets the overall height of the ColorScale and returns the current class instance. If *value* is not specified, returns the current height value. | ||
<a name="ColorScale.legendConfig" href="#ColorScale.legendConfig">#</a> ColorScale.**legendConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L478) | ||
<a name="ColorScale.labelConfig" href="#ColorScale.labelConfig">#</a> ColorScale.**labelConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L546) | ||
A pass-through for the [TextBox](http://d3plus.org/docs/#TextBox) class used to style the labelMin and labelMax text. | ||
This is a static method of [<code>ColorScale</code>](#ColorScale), and is chainable with other methods of this Class. | ||
<a name="ColorScale.labelMin" href="#ColorScale.labelMin">#</a> ColorScale.**labelMin**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L556) | ||
Defines a text label to be displayed off of the end of the minimum point in the scale (currently only available in horizontal orientation). | ||
This is a static method of [<code>ColorScale</code>](#ColorScale), and is chainable with other methods of this Class. | ||
<a name="ColorScale.labelMax" href="#ColorScale.labelMax">#</a> ColorScale.**labelMax**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L566) | ||
Defines a text label to be displayed off of the end of the maximum point in the scale (currently only available in horizontal orientation). | ||
This is a static method of [<code>ColorScale</code>](#ColorScale), and is chainable with other methods of this Class. | ||
<a name="ColorScale.legendConfig" href="#ColorScale.legendConfig">#</a> ColorScale.**legendConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L576) | ||
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/). | ||
@@ -192,3 +219,3 @@ | ||
<a name="ColorScale.midpoint" href="#ColorScale.midpoint">#</a> ColorScale.**midpoint**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L488) | ||
<a name="ColorScale.midpoint" href="#ColorScale.midpoint">#</a> ColorScale.**midpoint**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L586) | ||
@@ -201,3 +228,3 @@ The number value to be used as the anchor for `colorMid`, and defines the center point of the diverging color scale. | ||
<a name="ColorScale.orient" href="#ColorScale.orient">#</a> ColorScale.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L498) | ||
<a name="ColorScale.orient" href="#ColorScale.orient">#</a> ColorScale.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L596) | ||
@@ -210,3 +237,3 @@ Sets the flow of the items inside the ColorScale. If no value is passed, the current flow will be returned. | ||
<a name="ColorScale.outerBounds" href="#ColorScale.outerBounds">#</a> ColorScale.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L508) | ||
<a name="ColorScale.outerBounds" href="#ColorScale.outerBounds">#</a> ColorScale.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L606) | ||
@@ -224,3 +251,3 @@ If called after the elements have been drawn to DOM, will returns the outer bounds of the ColorScale content. | ||
<a name="ColorScale.padding" href="#ColorScale.padding">#</a> ColorScale.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L518) | ||
<a name="ColorScale.padding" href="#ColorScale.padding">#</a> ColorScale.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L616) | ||
@@ -233,3 +260,3 @@ If *value* is specified, sets the padding between each key to the specified number and returns the current class instance. If *value* is not specified, returns the current padding value. | ||
<a name="ColorScale.rectConfig" href="#ColorScale.rectConfig">#</a> ColorScale.**rectConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L528) | ||
<a name="ColorScale.rectConfig" href="#ColorScale.rectConfig">#</a> ColorScale.**rectConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L626) | ||
@@ -242,3 +269,3 @@ 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 [Rect](http://d3plus.org/docs/#Rect). An example usage of this method can be seen [here](http://d3plus.org/examples/d3plus-legend/colorScale-dark/). | ||
<a name="ColorScale.scale" href="#ColorScale.scale">#</a> ColorScale.**scale**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L538) | ||
<a name="ColorScale.scale" href="#ColorScale.scale">#</a> ColorScale.**scale**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L636) | ||
@@ -251,3 +278,3 @@ If *value* is specified, sets the scale of the ColorScale and returns the current class instance. If *value* is not specified, returns the current scale value. | ||
<a name="ColorScale.select" href="#ColorScale.select">#</a> ColorScale.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L548) | ||
<a name="ColorScale.select" href="#ColorScale.select">#</a> ColorScale.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L646) | ||
@@ -260,3 +287,3 @@ If *selector* is specified, sets the SVG container element to the specified d3 selector or DOM element and returns the current class instance. If *selector* is not specified, returns the current SVG container element. | ||
<a name="ColorScale.size" href="#ColorScale.size">#</a> ColorScale.**size**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L558) | ||
<a name="ColorScale.size" href="#ColorScale.size">#</a> ColorScale.**size**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L656) | ||
@@ -269,3 +296,3 @@ The height of horizontal color scales, and width when positioned vertical. | ||
<a name="ColorScale.value" href="#ColorScale.value">#</a> ColorScale.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L572) | ||
<a name="ColorScale.value" href="#ColorScale.value">#</a> ColorScale.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L670) | ||
@@ -285,3 +312,3 @@ If *value* is specified, sets the value accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current value accessor. | ||
<a name="ColorScale.width" href="#ColorScale.width">#</a> ColorScale.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L582) | ||
<a name="ColorScale.width" href="#ColorScale.width">#</a> ColorScale.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L680) | ||
@@ -500,2 +527,2 @@ If *value* is specified, sets the overall width of the ColorScale and returns the current class instance. If *value* is not specified, returns the current width value. | ||
###### <sub>Documentation generated on Thu, 19 Dec 2019 16:46:00 GMT</sub> | ||
###### <sub>Documentation generated on Wed, 19 Feb 2020 22:39:37 GMT</sub> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
340127
3754
502
Updatedd3plus-axis@^0.4.18
Updatedd3plus-common@^0.6.60