From 4f23b8c9d49564d56587633ba05d37d1aa3d7074 Mon Sep 17 00:00:00 2001 From: andres-rubio-go <132520982+andres-rubio-go@users.noreply.github.com> Date: Thu, 5 Oct 2023 21:44:23 +0000 Subject: [PATCH] feat: add additional tests (#10) chore(bootstrap): add pnpm installation fix: ensure bootstrap works on distros with apt as the package manager feat: use pnpm to build our binaries fix: Failing unit tests fix: Updated build --- .pre-commit-config.yaml | 9 +- bargauge.js | 2 +- bin/bootstrap | 16 +- bin/build | 12 +- bin/test | 10 +- package.json | 7 +- src/helpers.js | 21 +- src/tests/viz-gauge-test-data.js | 809 ----------------------------- src/tests/viz-gauge.test.js | 33 -- src/viz-config.js | 6 +- src/viz-gauge-test-data.js | 849 +++++++++++++++++++++++++++++++ src/viz-gauge.js | 4 +- src/viz-gauge.test.js | 75 +++ 13 files changed, 972 insertions(+), 881 deletions(-) delete mode 100644 src/tests/viz-gauge-test-data.js delete mode 100644 src/tests/viz-gauge.test.js create mode 100644 src/viz-gauge-test-data.js create mode 100644 src/viz-gauge.test.js diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11d45cf..3ff0b85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,13 @@ repos: - id: mixed-line-ending args: [--fix, lf] - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v3.0.0-alpha.9-for-vscode' + rev: 'v3.0.3' hooks: - id: prettier + - repo: local + hooks: + - id: unit-tests-suite + name: unit-tests-suite + description: Runs test suites + entry: bin/test + language: script diff --git a/bargauge.js b/bargauge.js index 802d874..5d699dc 100644 --- a/bargauge.js +++ b/bargauge.js @@ -27,4 +27,4 @@ object-assign * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var r,a,i,l,o;if("undefined"==typeof window||"function"!=typeof MessageChannel){var u=null,c=null,s=function(){if(null!==u)try{var e=t.unstable_now();u(!0,e),u=null}catch(e){throw setTimeout(s,0),e}},f=Date.now();t.unstable_now=function(){return Date.now()-f},r=function(e){null!==u?setTimeout(r,0,e):(u=e,setTimeout(s,0))},a=function(e,t){c=setTimeout(e,t)},i=function(){clearTimeout(c)},l=function(){return!1},o=t.unstable_forceFrameRate=function(){}}else{var d=window.performance,h=window.Date,p=window.setTimeout,g=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills")}if("object"==typeof d&&"function"==typeof d.now)t.unstable_now=function(){return d.now()};else{var v=h.now();t.unstable_now=function(){return h.now()-v}}var y=!1,b=null,_=-1,w=5,x=0;l=function(){return t.unstable_now()>=x},o=function(){},t.unstable_forceFrameRate=function(e){0>e||125>>1,a=e[r];if(!(void 0!==a&&0M(l,n))void 0!==u&&0>M(u,l)?(e[r]=u,e[o]=n,r=o):(e[r]=l,e[i]=n,r=i);else{if(!(void 0!==u&&0>M(u,n)))break e;e[r]=u,e[o]=n,r=o}}}return t}return null}function M(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var P=[],N=[],A=1,O=null,z=3,B=!1,D=!1,L=!1;function R(e){for(var t=C(N);null!==t;){if(null===t.callback)S(N);else{if(!(t.startTime<=e))break;S(N),t.sortIndex=t.expirationTime,E(P,t)}t=C(N)}}function F(e){if(L=!1,R(e),!D)if(null!==C(P))D=!0,r(U);else{var t=C(N);null!==t&&a(F,t.startTime-e)}}function U(e,n){D=!1,L&&(L=!1,i()),B=!0;var r=z;try{for(R(n),O=C(P);null!==O&&(!(O.expirationTime>n)||e&&!l());){var o=O.callback;if(null!==o){O.callback=null,z=O.priorityLevel;var u=o(O.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?O.callback=u:O===C(P)&&S(P),R(n)}else S(P);O=C(P)}if(null!==O)var c=!0;else{var s=C(N);null!==s&&a(F,s.startTime-n),c=!1}return c}finally{O=null,z=r,B=!1}}function I(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var $=o;t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){D||B||(D=!0,r(U))},t.unstable_getCurrentPriorityLevel=function(){return z},t.unstable_getFirstCallbackNode=function(){return C(P)},t.unstable_next=function(e){switch(z){case 1:case 2:case 3:var t=3;break;default:t=z}var n=z;z=t;try{return e()}finally{z=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=$,t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=z;z=e;try{return t()}finally{z=n}},t.unstable_scheduleCallback=function(e,n,l){var o=t.unstable_now();if("object"==typeof l&&null!==l){var u=l.delay;u="number"==typeof u&&0o?(e.sortIndex=u,E(N,e),null===C(P)&&e===C(N)&&(L?i():L=!0,a(F,u-o))):(e.sortIndex=l,E(P,e),D||B||(D=!0,r(U))),e},t.unstable_shouldYield=function(){var e=t.unstable_now();R(e);var n=C(P);return n!==O&&null!==O&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTimet?1:e>=t?0:NaN},l=function(e){return 1===e.length&&(e=function(e){return function(t,n){return i(e(t),n)}}(e)),{left:function(t,n,r,a){for(null==r&&(r=0),null==a&&(a=t.length);r>>1;e(t[i],n)<0?r=i+1:a=i}return r},right:function(t,n,r,a){for(null==r&&(r=0),null==a&&(a=t.length);r>>1;e(t[i],n)>0?a=i:r=i+1}return r}}}(i);l.right,l.left;var o=Array.prototype;o.slice,o.map,Math.sqrt(50),Math.sqrt(10),Math.sqrt(2),Array.prototype.slice;var u={value:function(){}};function c(){for(var e,t=0,n=arguments.length,r={};t=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}(e+"",r),i=-1,l=a.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++i0)for(var n,r,a=new Array(n),i=0;it?1:e>=t?0:NaN}var T="http://www.w3.org/1999/xhtml",E={svg:"http://www.w3.org/2000/svg",xhtml:T,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},C=function(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),E.hasOwnProperty(t)?{space:E[t],local:e}:e},S=function(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView};function M(e,t){return e.style.getPropertyValue(t)||S(e).getComputedStyle(e,null).getPropertyValue(t)}function P(e){return e.trim().split(/^|\s+/)}function N(e){return e.classList||new A(e)}function A(e){this._node=e,this._names=P(e.getAttribute("class")||"")}function O(e,t){for(var n=N(e),r=-1,a=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var F=function(e){var t=C(e);return(t.local?function(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===T&&t.documentElement.namespaceURI===T?t.createElement(e):t.createElementNS(n,e)}})(t)};function U(){return null}function I(){var e=this.parentNode;e&&e.removeChild(this)}function $(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function j(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}var H={},V=null;function W(e,t,n){return e=Y(e,t,n),function(t){var n=t.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||e.call(this,t)}}function Y(e,t,n){return function(r){var a=V;V=r;try{e.call(this,this.__data__,t,n)}finally{V=a}}}function q(e){return function(){var t=this.__on;if(t){for(var n,r=0,a=-1,i=t.length;r=_&&(_=b+1);!(y=m[_])&&++_=0;)(r=a[i])&&(l&&4^r.compareDocumentPosition(l)&&l.parentNode.insertBefore(r,l),l=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=k);for(var n=this._groups,r=n.length,a=new Array(r),i=0;i1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):M(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=P(e+"");if(arguments.length<2){for(var r=N(this.node()),a=-1,i=n.length;++a=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),l=i.length;if(!(arguments.length<2)){for(o=t?Q:q,null==n&&(n=!1),r=0;r>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?be(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?be(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=ue.exec(e))?new we(t[1],t[2],t[3],1):(t=ce.exec(e))?new we(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=se.exec(e))?be(t[1],t[2],t[3],t[4]):(t=fe.exec(e))?be(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=de.exec(e))?Ee(t[1],t[2]/100,t[3]/100,1):(t=he.exec(e))?Ee(t[1],t[2]/100,t[3]/100,t[4]):pe.hasOwnProperty(e)?ye(pe[e]):"transparent"===e?new we(NaN,NaN,NaN,0):null}function ye(e){return new we(e>>16&255,e>>8&255,255&e,1)}function be(e,t,n,r){return r<=0&&(e=t=n=NaN),new we(e,t,n,r)}function _e(e,t,n,r){return 1===arguments.length?function(e){return e instanceof re||(e=ve(e)),e?new we((e=e.rgb()).r,e.g,e.b,e.opacity):new we}(e):new we(e,t,n,null==r?1:r)}function we(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function xe(){return"#"+Te(this.r)+Te(this.g)+Te(this.b)}function ke(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function Te(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function Ee(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Se(e,t,n,r)}function Ce(e){if(e instanceof Se)return new Se(e.h,e.s,e.l,e.opacity);if(e instanceof re||(e=ve(e)),!e)return new Se;if(e instanceof Se)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),i=Math.max(t,n,r),l=NaN,o=i-a,u=(i+a)/2;return o?(l=t===i?(n-r)/o+6*(n0&&u<1?0:l,new Se(l,o,u,e.opacity)}function Se(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function Me(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function Pe(e,t,n,r,a){var i=e*e,l=i*e;return((1-3*e+3*i-l)*t+(4-6*i+3*l)*n+(1+3*e+3*i-3*l)*r+l*a)/6}te(re,ve,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:ge,formatHex:ge,formatHsl:function(){return Ce(this).formatHsl()},formatRgb:me,toString:me}),te(we,_e,ne(re,{brighter:function(e){return e=null==e?1/.7:Math.pow(1/.7,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?.7:Math.pow(.7,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xe,formatHex:xe,formatRgb:ke,toString:ke})),te(Se,(function(e,t,n,r){return 1===arguments.length?Ce(e):new Se(e,t,n,null==r?1:r)}),ne(re,{brighter:function(e){return e=null==e?1/.7:Math.pow(1/.7,e),new Se(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?.7:Math.pow(.7,e),new Se(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new we(Me(e>=240?e-240:e+120,a,r),Me(e,a,r),Me(e<120?e+240:e-120,a,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));var Ne=function(e){return function(){return e}};function Ae(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):Ne(isNaN(e)?t:e)}var Oe=function e(t){var n=function(e){return 1==(e=+e)?Ae:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):Ne(isNaN(t)?n:t)}}(t);function r(e,t){var r=n((e=_e(e)).r,(t=_e(t)).r),a=n(e.g,t.g),i=n(e.b,t.b),l=Ae(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=a(t),e.b=i(t),e.opacity=l(t),e+""}}return r.gamma=e,r}(1);function ze(e){return function(t){var n,r,a=t.length,i=new Array(a),l=new Array(a),o=new Array(a);for(n=0;n=1?(n=1,t-1):Math.floor(n*t),a=e[r],i=e[r+1],l=r>0?e[r-1]:2*a-i,o=ri&&(a=t.slice(i,a),o[l]?o[l]+=a:o[++l]=a),(n=n[0])===(r=r[0])?o[l]?o[l]+=r:o[++l]=r:(o[++l]=null,u.push({i:l,x:Le(n,r)})),i=Fe.lastIndex;return i=0&&t._call.call(null,e),t=t._next;--Ie}()}finally{Ie=0,function(){for(var e,t,n=Be,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Be=t);De=e,et(r)}(),Ve=0}}function Je(){var e=Ye.now(),t=e-He;t>1e3&&(We-=t,He=e)}function et(e){Ie||($e&&($e=clearTimeout($e)),e-Ve>24?(e<1/0&&($e=setTimeout(Ze,e-Ye.now()-We)),je&&(je=clearInterval(je))):(je||(He=Ye.now(),je=setInterval(Je,1e3)),Ie=1,qe(Ze)))}Ke.prototype=Ge.prototype={constructor:Ke,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Qe():+n)+(null==t?0:+t),this._next||De===this||(De?De._next=this:Be=this,De=this),this._call=e,this._time=n,et()},stop:function(){this._call&&(this._call=null,this._time=1/0,et())}};var tt=function(e,t,n){var r=new Ke;return t=null==t?0:+t,r.restart((function(n){r.stop(),e(n+t)}),t,n),r},nt=h("start","end","cancel","interrupt"),rt=[],at=function(e,t,n,r,a,i){var l=e.__transition;if(l){if(n in l)return}else e.__transition={};!function(e,t,n){var r,a=e.__transition;function i(u){var c,s,f,d;if(1!==n.state)return o();for(c in a)if((d=a[c]).name===n.name){if(3===d.state)return tt(i);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete a[c]):+c0)throw new Error("too late; already scheduled");return n}function lt(e,t){var n=ot(e,t);if(n.state>3)throw new Error("too late; already running");return n}function ot(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}var ut,ct,st,ft,dt=180/Math.PI,ht={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},pt=function(e,t,n,r,a,i){var l,o,u;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,u/=o),e*r180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(a(n)+"rotate(",null,r)-2,x:Le(e,t)})):t&&n.push(a(n)+"rotate("+t+r)}(i.rotate,l.rotate,o,u),function(e,t,n,i){e!==t?i.push({i:n.push(a(n)+"skewX(",null,r)-2,x:Le(e,t)}):t&&n.push(a(n)+"skewX("+t+r)}(i.skewX,l.skewX,o,u),function(e,t,n,r,i,l){if(e!==n||t!==r){var o=i.push(a(i)+"scale(",null,",",null,")");l.push({i:o-4,x:Le(e,n)},{i:o-2,x:Le(t,r)})}else 1===n&&1===r||i.push(a(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,l.scaleX,l.scaleY,o,u),i=l=null,function(e){for(var t,n=-1,r=u.length;++n=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?it:lt;return function(){var l=i(this,e),o=l.on;o!==r&&(a=(r=o).copy()).on(t,n),l.on=a}}(n,e,t))},attr:function(e,t){var n=C(e),r="transform"===n?vt:bt;return this.attrTween(e,"function"==typeof t?(n.local?function(e,t,n){var r,a,i;return function(){var l,o,u=n(this);if(null!=u)return(l=this.getAttributeNS(e.space,e.local))===(o=u+"")?null:l===r&&o===a?i:(a=o,i=t(r=l,u));this.removeAttributeNS(e.space,e.local)}}:function(e,t,n){var r,a,i;return function(){var l,o,u=n(this);if(null!=u)return(l=this.getAttribute(e))===(o=u+"")?null:l===r&&o===a?i:(a=o,i=t(r=l,u));this.removeAttribute(e)}})(n,r,yt(this,"attr."+e,t)):null==t?(n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}})(n):(n.local?function(e,t,n){var r,a,i=n+"";return function(){var l=this.getAttributeNS(e.space,e.local);return l===i?null:l===r?a:a=t(r=l,n)}}:function(e,t,n){var r,a,i=n+"";return function(){var l=this.getAttribute(e);return l===i?null:l===r?a:a=t(r=l,n)}})(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=C(e);return this.tween(n,(r.local?function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,a)),n}return a._value=t,a}:function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,a)),n}return a._value=t,a})(r,t))},style:function(e,t,n){var r="transform"==(e+="")?mt:bt;return null==t?this.styleTween(e,function(e,t){var n,r,a;return function(){var i=M(this,e),l=(this.style.removeProperty(e),M(this,e));return i===l?null:i===n&&l===r?a:a=t(n=i,r=l)}}(e,r)).on("end.style."+e,wt(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var r,a,i;return function(){var l=M(this,e),o=n(this),u=o+"";return null==o&&(this.style.removeProperty(e),u=o=M(this,e)),l===u?null:l===r&&u===a?i:(a=u,i=t(r=l,o))}}(e,r,yt(this,"style."+e,t))).each(function(e,t){var n,r,a,i,l="style."+t,o="end."+l;return function(){var u=lt(this,e),c=u.on,s=null==u.value[l]?i||(i=wt(t)):void 0;c===n&&a===s||(r=(n=c).copy()).on(o,a=s),u.on=r}}(this._id,e)):this.styleTween(e,function(e,t,n){var r,a,i=n+"";return function(){var l=M(this,e);return l===i?null:l===r?a:a=t(r=l,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function(e,t,n){var r,a;function i(){var i=t.apply(this,arguments);return i!==a&&(r=(a=i)&&function(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,i,n)),r}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(yt(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&function(e){return function(t){this.textContent=e.call(this,t)}}(r)),t}return r._value=e,r}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,a=ot(this.node(),n).tween,i=0,l=a.length;i2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[a]):l=!1;l&&delete e.__transition}}(this,e)}))},J.prototype.transition=function(e){var t,n;e instanceof kt?(t=e._id,e=e._name):(t=Tt(),(n=Ct).time=Qe(),e=null==e?null:e+"");for(var r=this._groups,a=r.length,i=0;i1e-6)if(Math.abs(s*o-u*c)>1e-6&&a){var d=n-i,h=r-l,p=o*o+u*u,g=d*d+h*h,m=Math.sqrt(p),v=Math.sqrt(f),y=a*Math.tan((Pt-Math.acos((p+f-g)/(2*m*v)))/2),b=y/v,_=y/m;Math.abs(b-1)>1e-6&&(this._+="L"+(e+b*c)+","+(t+b*s)),this._+="A"+a+","+a+",0,0,"+ +(s*d>c*h)+","+(this._x1=e+_*o)+","+(this._y1=t+_*u)}else this._+="L"+(this._x1=e)+","+(this._y1=t)},arc:function(e,t,n,r,a,i){e=+e,t=+t,i=!!i;var l=(n=+n)*Math.cos(r),o=n*Math.sin(r),u=e+l,c=t+o,s=1^i,f=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+u+","+c:(Math.abs(this._x1-u)>1e-6||Math.abs(this._y1-c)>1e-6)&&(this._+="L"+u+","+c),n&&(f<0&&(f=f%Nt+Nt),f>At?this._+="A"+n+","+n+",0,1,"+s+","+(e-l)+","+(t-o)+"A"+n+","+n+",0,1,"+s+","+(this._x1=u)+","+(this._y1=c):f>1e-6&&(this._+="A"+n+","+n+",0,"+ +(f>=Pt)+","+s+","+(this._x1=e+n*Math.cos(a))+","+(this._y1=t+n*Math.sin(a))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}},zt.prototype=Bt.prototype={constructor:zt,has:function(e){return"$"+e in this},get:function(e){return this["$"+e]},set:function(e,t){return this["$"+e]=t,this},remove:function(e){var t="$"+e;return t in this&&delete this[t]},clear:function(){for(var e in this)"$"===e[0]&&delete this[e]},keys:function(){var e=[];for(var t in this)"$"===t[0]&&e.push(t.slice(1));return e},values:function(){var e=[];for(var t in this)"$"===t[0]&&e.push(this[t]);return e},entries:function(){var e=[];for(var t in this)"$"===t[0]&&e.push({key:t.slice(1),value:this[t]});return e},size:function(){var e=0;for(var t in this)"$"===t[0]&&++e;return e},empty:function(){for(var e in this)if("$"===e[0])return!1;return!0},each:function(e){for(var t in this)"$"===t[0]&&e(this[t],t.slice(1),this)}};var Lt=Bt.prototype;Dt.prototype=function(e,t){var n=new Dt;if(e instanceof Dt)e.each((function(e){n.add(e)}));else if(e){var r=-1,a=e.length;if(null==t)for(;++r=i?u=!0:10===(r=e.charCodeAt(l++))?c=!0:13===r&&(c=!0,10===e.charCodeAt(l)&&++l),e.slice(a+1,t-1).replace(/""/g,'"')}for(;l9999?"+"+$t(e,6):$t(e,4)}(e.getUTCFullYear())+"-"+$t(e.getUTCMonth()+1,2)+"-"+$t(e.getUTCDate(),2)+(a?"T"+$t(t,2)+":"+$t(n,2)+":"+$t(r,2)+"."+$t(a,3)+"Z":r?"T"+$t(t,2)+":"+$t(n,2)+":"+$t(r,2)+"Z":n||t?"T"+$t(t,2)+":"+$t(n,2)+"Z":"")}(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,i=r(e,(function(e,r){if(n)return n(e,r-1);a=e,n=t?function(e,t){var n=Ut(e);return function(r,a){return t(n(r),a,e)}}(e,t):Ut(e)}));return i.columns=a||[],i},parseRows:r,format:function(t,n){return null==n&&(n=It(t)),[n.map(l).join(e)].concat(a(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=It(e)),a(e,t).join("\n")},formatRows:function(e){return e.map(i).join("\n")},formatRow:i,formatValue:l}},Ht=jt(","),Vt=Ht.parse,Wt=(Ht.parseRows,Ht.format,Ht.formatBody,Ht.formatRows,Ht.formatRow,Ht.formatValue,jt("\t")),Yt=Wt.parse;function qt(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.text()}Wt.parseRows,Wt.format,Wt.formatBody,Wt.formatRows,Wt.formatRow,Wt.formatValue;var Qt=function(e,t){return fetch(e,t).then(qt)};function Xt(e){return function(t,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),Qt(t,n).then((function(t){return e(t,r)}))}}function Kt(e){return function(t,n){return Qt(t,n).then((function(t){return(new DOMParser).parseFromString(t,e)}))}}function Gt(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var a,i,l,o,u,c,s,f,d,h=e._root,p={data:r},g=e._x0,m=e._y0,v=e._x1,y=e._y1;if(!h)return e._root=p,e;for(;h.length;)if((c=t>=(i=(g+v)/2))?g=i:v=i,(s=n>=(l=(m+y)/2))?m=l:y=l,a=h,!(h=h[f=s<<1|c]))return a[f]=p,e;if(o=+e._x.call(null,h.data),u=+e._y.call(null,h.data),t===o&&n===u)return p.next=h,a?a[f]=p:e._root=p,e;do{a=a?a[f]=new Array(4):e._root=new Array(4),(c=t>=(i=(g+v)/2))?g=i:v=i,(s=n>=(l=(m+y)/2))?m=l:y=l}while((f=s<<1|c)==(d=(u>=l)<<1|o>=i));return a[d]=h,a[f]=p,e}Xt(Vt),Xt(Yt),Kt("application/xml"),Kt("text/html"),Kt("image/svg+xml");var Zt=function(e,t,n,r,a){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=a};function Jt(e){return e[0]}function en(e){return e[1]}function tn(e,t,n,r,a,i){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=a,this._y1=i,this._root=void 0}function nn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var rn=function(e,t,n){var r=new tn(null==t?Jt:t,null==n?en:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}.prototype=tn.prototype;rn.copy=function(){var e,t,n=new tn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=nn(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var a=0;a<4;++a)(t=r.source[a])&&(t.length?e.push({source:t,target:r.target[a]=new Array(4)}):r.target[a]=nn(t));return n},rn.add=function(e){var t=+this._x.call(null,e),n=+this._y.call(null,e);return Gt(this.cover(t,n),t,n,e)},rn.addAll=function(e){var t,n,r,a,i=e.length,l=new Array(i),o=new Array(i),u=1/0,c=1/0,s=-1/0,f=-1/0;for(n=0;ns&&(s=r),af&&(f=a));if(u>s||c>f)return this;for(this.cover(u,c).cover(s,f),n=0;ne||e>=a||r>t||t>=i;)switch(o=(td||(i=u.y0)>h||(l=u.x1)=v)<<1|e>=m)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u)}else{var y=e-+this._x.call(null,g.data),b=t-+this._y.call(null,g.data),_=y*y+b*b;if(_=(o=(p+m)/2))?p=o:m=o,(s=l>=(u=(g+v)/2))?g=u:v=u,t=h,!(h=h[f=s<<1|c]))return this;if(!h.length)break;(t[f+1&3]||t[f+2&3]||t[f+3&3])&&(n=t,d=f)}for(;h.data!==e;)if(r=h,!(h=h.next))return this;return(a=h.next)&&delete h.next,r?(a?r.next=a:delete r.next,this):t?(a?t[f]=a:delete t[f],(h=t[0]||t[1]||t[2]||t[3])&&h===(t[3]||t[2]||t[1]||t[0])&&!h.length&&(n?n[d]=h:this._root=h),this):(this._root=a,this)},rn.removeAll=function(e){for(var t=0,n=e.length;t1);return e+n*i*Math.sqrt(-2*Math.log(a)/a)}}return n.source=e,n}(an)),on=(function e(t){function n(){var e=ln.source(t).apply(this,arguments);return function(){return Math.exp(e())}}return n.source=e,n}(an),function e(t){function n(e){return function(){for(var n=0,r=0;r=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sn(e){if(!(t=cn.exec(e)))throw new Error("invalid format: "+e);var t;return new fn({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function fn(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}sn.prototype=fn.prototype,fn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var dn,hn,pn=function(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]},gn=function(e,t){var n=pn(e,t);if(!n)return e+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")},mn={"%":function(e,t){return(100*e).toFixed(t)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:function(e){return Math.round(e).toString(10)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},g:function(e,t){return e.toPrecision(t)},o:function(e){return Math.round(e).toString(8)},p:function(e,t){return gn(100*e,t)},r:gn,s:function(e,t){var n=pn(e,t);if(!n)return e+"";var r=n[0],a=n[1],i=a-(dn=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,l=r.length;return i===l?r:i>l?r+new Array(i-l+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+pn(e,Math.max(0,t+i-1))[0]},X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}},vn=function(e){return e},yn=Array.prototype.map,bn=["y","z","a","f","p","n","ยต","m","","k","M","G","T","P","E","Z","Y"];(hn=function(e){var t=void 0===e.grouping||void 0===e.thousands?vn:function(e,t){return function(n,r){for(var a=n.length,i=[],l=0,o=e[0],u=0;a>0&&o>0&&(u+o+1>r&&(o=Math.max(1,r-u)),i.push(n.substring(a-=o,a+o)),!((u+=o+1)>r));)o=e[l=(l+1)%e.length];return i.reverse().join(t)}}(yn.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",r=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",i=void 0===e.numerals?vn:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(yn.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",o=void 0===e.minus?"-":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function c(e){var c=(e=sn(e)).fill,s=e.align,f=e.sign,d=e.symbol,h=e.zero,p=e.width,g=e.comma,m=e.precision,v=e.trim,y=e.type;"n"===y?(g=!0,y="g"):mn[y]||(void 0===m&&(m=12),v=!0,y="g"),(h||"0"===c&&"="===s)&&(h=!0,c="0",s="=");var b="$"===d?n:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===d?r:/[%p]/.test(y)?l:"",w=mn[y],x=/[defgprs%]/.test(y);function k(e){var n,r,l,d=b,k=_;if("c"===y)k=w(e)+k,e="";else{var T=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:w(Math.abs(e),m),v&&(e=function(e){e:for(var t,n=e.length,r=1,a=-1;r0&&(a=0)}return a>0?e.slice(0,a)+e.slice(t+1):e}(e)),T&&0==+e&&"+"!==f&&(T=!1),d=(T?"("===f?f:o:"-"===f||"("===f?"":f)+d,k=("s"===y?bn[8+dn/3]:"")+k+(T&&"("===f?")":""),x)for(n=-1,r=e.length;++n(l=e.charCodeAt(n))||l>57){k=(46===l?a+e.slice(n+1):e.slice(n))+k,e=e.slice(0,n);break}}g&&!h&&(e=t(e,1/0));var E=d.length+e.length+k.length,C=E>1)+d+e+k+C.slice(E);break;default:e=C+d+e+k}return i(e)}return m=void 0===m?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),k.toString=function(){return e+""},k}return{format:c,formatPrefix:function(e,t){var n=c(((e=sn(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(function(e){return(e=pn(Math.abs(e)))?e[1]:NaN}(t)/3))),a=Math.pow(10,-r),i=bn[8+r/3];return function(e){return n(a*e)+i}}}}({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"})).format,hn.formatPrefix;var _n=new Date,wn=new Date;function xn(e,t,n,r){function a(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return a.floor=function(t){return e(t=new Date(+t)),t},a.ceil=function(n){return e(n=new Date(n-1)),t(n,1),e(n),n},a.round=function(e){var t=a(e),n=a.ceil(e);return e-t0))return o;do{o.push(l=new Date(+n)),t(n,i),e(n)}while(l=t)for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,r){if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}))},n&&(a.count=function(t,r){return _n.setTime(+t),wn.setTime(+r),e(_n),e(wn),Math.floor(n(_n,wn))},a.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?a.filter(r?function(t){return r(t)%e==0}:function(t){return a.count(0,t)%e==0}):a:null}),a}var kn=xn((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));kn.every=function(e){return isFinite(e=Math.floor(e))&&e>0?xn((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null};var Tn=kn,En=((kn.range,xn((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()}))).range,6e4),Cn=6048e5;function Sn(e){return xn((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*En)/Cn}))}var Mn=Sn(0),Pn=Sn(1),Nn=Sn(2),An=Sn(3),On=Sn(4),zn=Sn(5),Bn=Sn(6),Dn=(Mn.range,Pn.range,Nn.range,An.range,On.range,zn.range,Bn.range,xn((function(e){e.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*En)/864e5}),(function(e){return e.getDate()-1}))),Ln=Dn,Rn=((((Dn.range,xn((function(e){e.setTime(e-e.getMilliseconds()-1e3*e.getSeconds()-e.getMinutes()*En)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getHours()}))).range,xn((function(e){e.setTime(e-e.getMilliseconds()-1e3*e.getSeconds())}),(function(e,t){e.setTime(+e+t*En)}),(function(e,t){return(t-e)/En}),(function(e){return e.getMinutes()}))).range,xn((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+1e3*t)}),(function(e,t){return(t-e)/1e3}),(function(e){return e.getUTCSeconds()}))).range,xn((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e})));function Fn(e){return xn((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/Cn}))}Rn.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?xn((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Rn:null},Rn.range;var Un=Fn(0),In=Fn(1),$n=Fn(2),jn=Fn(3),Hn=Fn(4),Vn=Fn(5),Wn=Fn(6),Yn=(Un.range,In.range,$n.range,jn.range,Hn.range,Vn.range,Wn.range,xn((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/864e5}),(function(e){return e.getUTCDate()-1}))),qn=Yn,Qn=(Yn.range,xn((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()})));Qn.every=function(e){return isFinite(e=Math.floor(e))&&e>0?xn((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null};var Xn=Qn;function Kn(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Gn(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Zn(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}Qn.range;var Jn,er={"-":"",_:" ",0:"0"},tr=/^\s*\d+/,nr=/^%/,rr=/[\\^$*+?|[\]().{}]/g;function ar(e,t,n){var r=e<0?"-":"",a=(r?-e:e)+"",i=a.length;return r+(i68?1900:2e3),n+r[0].length):-1}function gr(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function mr(e,t,n){var r=tr.exec(t.slice(n,n+1));return r?(e.q=3*r[0]-3,n+r[0].length):-1}function vr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function yr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function br(e,t,n){var r=tr.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function _r(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function wr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function xr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function kr(e,t,n){var r=tr.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Tr(e,t,n){var r=tr.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Er(e,t,n){var r=nr.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Cr(e,t,n){var r=tr.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Sr(e,t,n){var r=tr.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function Mr(e,t){return ar(e.getDate(),t,2)}function Pr(e,t){return ar(e.getHours(),t,2)}function Nr(e,t){return ar(e.getHours()%12||12,t,2)}function Ar(e,t){return ar(1+Ln.count(Tn(e),e),t,3)}function Or(e,t){return ar(e.getMilliseconds(),t,3)}function zr(e,t){return Or(e,t)+"000"}function Br(e,t){return ar(e.getMonth()+1,t,2)}function Dr(e,t){return ar(e.getMinutes(),t,2)}function Lr(e,t){return ar(e.getSeconds(),t,2)}function Rr(e){var t=e.getDay();return 0===t?7:t}function Fr(e,t){return ar(Mn.count(Tn(e)-1,e),t,2)}function Ur(e,t){var n=e.getDay();return e=n>=4||0===n?On(e):On.ceil(e),ar(On.count(Tn(e),e)+(4===Tn(e).getDay()),t,2)}function Ir(e){return e.getDay()}function $r(e,t){return ar(Pn.count(Tn(e)-1,e),t,2)}function jr(e,t){return ar(e.getFullYear()%100,t,2)}function Hr(e,t){return ar(e.getFullYear()%1e4,t,4)}function Vr(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+ar(t/60|0,"0",2)+ar(t%60,"0",2)}function Wr(e,t){return ar(e.getUTCDate(),t,2)}function Yr(e,t){return ar(e.getUTCHours(),t,2)}function qr(e,t){return ar(e.getUTCHours()%12||12,t,2)}function Qr(e,t){return ar(1+qn.count(Xn(e),e),t,3)}function Xr(e,t){return ar(e.getUTCMilliseconds(),t,3)}function Kr(e,t){return Xr(e,t)+"000"}function Gr(e,t){return ar(e.getUTCMonth()+1,t,2)}function Zr(e,t){return ar(e.getUTCMinutes(),t,2)}function Jr(e,t){return ar(e.getUTCSeconds(),t,2)}function ea(e){var t=e.getUTCDay();return 0===t?7:t}function ta(e,t){return ar(Un.count(Xn(e)-1,e),t,2)}function na(e,t){var n=e.getUTCDay();return e=n>=4||0===n?Hn(e):Hn.ceil(e),ar(Hn.count(Xn(e),e)+(4===Xn(e).getUTCDay()),t,2)}function ra(e){return e.getUTCDay()}function aa(e,t){return ar(In.count(Xn(e)-1,e),t,2)}function ia(e,t){return ar(e.getUTCFullYear()%100,t,2)}function la(e,t){return ar(e.getUTCFullYear()%1e4,t,4)}function oa(){return"+0000"}function ua(){return"%"}function ca(e){return+e}function sa(e){return Math.floor(+e/1e3)}function fa(){this._=null}function da(e){e.U=e.C=e.L=e.R=e.P=e.N=null}function ha(e,t){var n=t,r=t.R,a=n.U;a?a.L===n?a.L=r:a.R=r:e._=r,r.U=a,n.U=r,n.R=r.L,n.R&&(n.R.U=n),r.L=n}function pa(e,t){var n=t,r=t.L,a=n.U;a?a.L===n?a.L=r:a.R=r:e._=r,r.U=a,n.U=r,n.L=r.R,n.L&&(n.L.U=n),r.R=n}function ga(e){for(;e.L;)e=e.L;return e}(Jn=function(e){var t=e.dateTime,n=e.date,r=e.time,a=e.periods,i=e.days,l=e.shortDays,o=e.months,u=e.shortMonths,c=lr(a),s=or(a),f=lr(i),d=or(i),h=lr(l),p=or(l),g=lr(o),m=or(o),v=lr(u),y=or(u),b={a:function(e){return l[e.getDay()]},A:function(e){return i[e.getDay()]},b:function(e){return u[e.getMonth()]},B:function(e){return o[e.getMonth()]},c:null,d:Mr,e:Mr,f:zr,H:Pr,I:Nr,j:Ar,L:Or,m:Br,M:Dr,p:function(e){return a[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:ca,s:sa,S:Lr,u:Rr,U:Fr,V:Ur,w:Ir,W:$r,x:null,X:null,y:jr,Y:Hr,Z:Vr,"%":ua},_={a:function(e){return l[e.getUTCDay()]},A:function(e){return i[e.getUTCDay()]},b:function(e){return u[e.getUTCMonth()]},B:function(e){return o[e.getUTCMonth()]},c:null,d:Wr,e:Wr,f:Kr,H:Yr,I:qr,j:Qr,L:Xr,m:Gr,M:Zr,p:function(e){return a[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:ca,s:sa,S:Jr,u:ea,U:ta,V:na,w:ra,W:aa,x:null,X:null,y:ia,Y:la,Z:oa,"%":ua},w={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=p[r[0].toLowerCase()],n+r[0].length):-1},A:function(e,t,n){var r=f.exec(t.slice(n));return r?(e.w=d[r[0].toLowerCase()],n+r[0].length):-1},b:function(e,t,n){var r=v.exec(t.slice(n));return r?(e.m=y[r[0].toLowerCase()],n+r[0].length):-1},B:function(e,t,n){var r=g.exec(t.slice(n));return r?(e.m=m[r[0].toLowerCase()],n+r[0].length):-1},c:function(e,n,r){return T(e,t,n,r)},d:yr,e:yr,f:Tr,H:_r,I:_r,j:br,L:kr,m:vr,M:wr,p:function(e,t,n){var r=c.exec(t.slice(n));return r?(e.p=s[r[0].toLowerCase()],n+r[0].length):-1},q:mr,Q:Cr,s:Sr,S:xr,u:cr,U:sr,V:fr,w:ur,W:dr,x:function(e,t,r){return T(e,n,t,r)},X:function(e,t,n){return T(e,r,t,n)},y:pr,Y:hr,Z:gr,"%":Er};function x(e,t){return function(n){var r,a,i,l=[],o=-1,u=0,c=e.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in i||(i.w=1),"Z"in i?(r=(a=(r=Gn(Zn(i.y,0,1))).getUTCDay())>4||0===a?In.ceil(r):In(r),r=qn.offset(r,7*(i.V-1)),i.y=r.getUTCFullYear(),i.m=r.getUTCMonth(),i.d=r.getUTCDate()+(i.w+6)%7):(r=(a=(r=Kn(Zn(i.y,0,1))).getDay())>4||0===a?Pn.ceil(r):Pn(r),r=Ln.offset(r,7*(i.V-1)),i.y=r.getFullYear(),i.m=r.getMonth(),i.d=r.getDate()+(i.w+6)%7)}else("W"in i||"U"in i)&&("w"in i||(i.w="u"in i?i.u%7:"W"in i?1:0),a="Z"in i?Gn(Zn(i.y,0,1)).getUTCDay():Kn(Zn(i.y,0,1)).getDay(),i.m=0,i.d="W"in i?(i.w+6)%7+7*i.W-(a+5)%7:i.w+7*i.U-(a+6)%7);return"Z"in i?(i.H+=i.Z/100|0,i.M+=i.Z%100,Gn(i)):Kn(i)}}function T(e,t,n,r){for(var a,i,l=0,o=t.length,u=n.length;l=u)return-1;if(37===(a=t.charCodeAt(l++))){if(a=t.charAt(l++),!(i=w[a in er?t.charAt(l++):a])||(r=i(e,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}return b.x=x(n,b),b.X=x(r,b),b.c=x(t,b),_.x=x(n,_),_.X=x(r,_),_.c=x(t,_),{format:function(e){var t=x(e+="",b);return t.toString=function(){return e},t},parse:function(e){var t=k(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=x(e+="",_);return t.toString=function(){return e},t},utcParse:function(e){var t=k(e+="",!0);return t.toString=function(){return e},t}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]})).format,Jn.parse,Jn.utcFormat,Jn.utcParse,((xn((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()})).range,xn((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getUTCHours()}))).range,xn((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*En)}),(function(e,t){return(t-e)/En}),(function(e){return e.getUTCMinutes()}))).range,fa.prototype={constructor:fa,insert:function(e,t){var n,r,a;if(e){if(t.P=e,t.N=e.N,e.N&&(e.N.P=t),e.N=t,e.R){for(e=e.R;e.L;)e=e.L;e.L=t}else e.R=t;n=e}else this._?(e=ga(this._),t.P=null,t.N=e,e.P=e.L=t,n=e):(t.P=t.N=null,this._=t,n=null);for(t.L=t.R=null,t.U=n,t.C=!0,e=t;n&&n.C;)n===(r=n.U).L?(a=r.R)&&a.C?(n.C=a.C=!1,r.C=!0,e=r):(e===n.R&&(ha(this,n),n=(e=n).U),n.C=!1,r.C=!0,pa(this,r)):(a=r.L)&&a.C?(n.C=a.C=!1,r.C=!0,e=r):(e===n.L&&(pa(this,n),n=(e=n).U),n.C=!1,r.C=!0,ha(this,r)),n=e.U;this._.C=!1},remove:function(e){e.N&&(e.N.P=e.P),e.P&&(e.P.N=e.N),e.N=e.P=null;var t,n,r,a=e.U,i=e.L,l=e.R;if(n=i?l?ga(l):i:l,a?a.L===e?a.L=n:a.R=n:this._=n,i&&l?(r=n.C,n.C=e.C,n.L=i,i.U=n,n!==l?(a=n.U,n.U=e.U,e=n.R,a.L=e,n.R=l,l.U=n):(n.U=a,a=n,e=n.R)):(r=e.C,e=n),e&&(e.U=a),!r)if(e&&e.C)e.C=!1;else{do{if(e===this._)break;if(e===a.L){if((t=a.R).C&&(t.C=!1,a.C=!0,ha(this,a),t=a.R),t.L&&t.L.C||t.R&&t.R.C){t.R&&t.R.C||(t.L.C=!1,t.C=!0,pa(this,t),t=a.R),t.C=a.C,a.C=t.R.C=!1,ha(this,a),e=this._;break}}else if((t=a.L).C&&(t.C=!1,a.C=!0,pa(this,a),t=a.L),t.L&&t.L.C||t.R&&t.R.C){t.L&&t.L.C||(t.R.C=!1,t.C=!0,ha(this,t),t=a.L),t.C=a.C,a.C=t.L.C=!1,pa(this,a),e=this._;break}t.C=!0,e=a,a=a.U}while(!e.C);e&&(e.C=!1)}}};var ma=fa;function va(e,t,n,r){var a=[null,null],i=Ua.push(a)-1;return a.left=e,a.right=t,n&&ba(a,e,t,n),r&&ba(a,t,e,r),Ra[e.index].halfedges.push(i),Ra[t.index].halfedges.push(i),a}function ya(e,t,n){var r=[t,n];return r.left=e,r}function ba(e,t,n,r){e[0]||e[1]?e.left===n?e[1]=r:e[0]=r:(e[0]=r,e.left=t,e.right=n)}function _a(e,t,n,r,a){var i,l=e[0],o=e[1],u=l[0],c=l[1],s=0,f=1,d=o[0]-u,h=o[1]-c;if(i=t-u,d||!(i>0)){if(i/=d,d<0){if(i0){if(i>f)return;i>s&&(s=i)}if(i=r-u,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>s&&(s=i)}else if(d>0){if(i0)){if(i/=h,h<0){if(i0){if(i>f)return;i>s&&(s=i)}if(i=a-c,h||!(i<0)){if(i/=h,h<0){if(i>f)return;i>s&&(s=i)}else if(h>0){if(i0||f<1)||(s>0&&(e[0]=[u+s*d,c+s*h]),f<1&&(e[1]=[u+f*d,c+f*h]),!0)}}}}}function wa(e,t,n,r,a){var i=e[1];if(i)return!0;var l,o,u=e[0],c=e.left,s=e.right,f=c[0],d=c[1],h=s[0],p=s[1],g=(f+h)/2,m=(d+p)/2;if(p===d){if(g=r)return;if(f>h){if(u){if(u[1]>=a)return}else u=[g,n];i=[g,a]}else{if(u){if(u[1]1)if(f>h){if(u){if(u[1]>=a)return}else u=[(n-o)/l,n];i=[(a-o)/l,a]}else{if(u){if(u[1]=r)return}else u=[t,l*t+o];i=[r,l*r+o]}else{if(u){if(u[0]=-$a)){var h=u*u+c*c,p=s*s+f*f,g=(f*h-c*p)/d,m=(u*p-s*h)/d,v=Ca.pop()||new function(){da(this),this.x=this.y=this.arc=this.site=this.cy=null};v.arc=e,v.site=a,v.x=g+l,v.y=(v.cy=m+o)+Math.sqrt(g*g+m*m),e.circle=v;for(var y=null,b=Fa._;b;)if(v.yIa)o=o.L;else{if(!((a=i-Da(o,l))>Ia)){r>-Ia?(t=o.P,n=o):a>-Ia?(t=o,n=o.N):t=n=o;break}if(!o.R){t=o;break}o=o.R}!function(e){Ra[e.index]={site:e,halfedges:[]}}(e);var u=Na(e);if(La.insert(t,u),t||n){if(t===n)return Ma(t),n=Na(t.site),La.insert(u,n),u.edge=n.edge=va(t.site,u.site),Sa(t),void Sa(n);if(n){Ma(t),Ma(n);var c=t.site,s=c[0],f=c[1],d=e[0]-s,h=e[1]-f,p=n.site,g=p[0]-s,m=p[1]-f,v=2*(d*m-h*g),y=d*d+h*h,b=g*g+m*m,_=[(m*y-h*b)/v+s,(d*b-g*y)/v+f];ba(n.edge,c,p,_),u.edge=va(c,e,null,_),n.edge=va(e,p,null,_),Sa(t),Sa(n)}else u.edge=va(t.site,u.site)}}function Ba(e,t){var n=e.site,r=n[0],a=n[1],i=a-t;if(!i)return r;var l=e.P;if(!l)return-1/0;var o=(n=l.site)[0],u=n[1],c=u-t;if(!c)return o;var s=o-r,f=1/i-1/c,d=s/c;return f?(-d+Math.sqrt(d*d-2*f*(s*s/(-2*c)-u+c/2+a-i/2)))/f+r:(r+o)/2}function Da(e,t){var n=e.N;if(n)return Ba(n,t);var r=e.site;return r[1]===t?r[0]:1/0}var La,Ra,Fa,Ua,Ia=1e-6,$a=1e-12;function ja(e,t,n){return(e[0]-n[0])*(t[1]-e[1])-(e[0]-t[0])*(n[1]-e[1])}function Ha(e,t){return t[1]-e[1]||t[0]-e[0]}function Va(e,t){var n,r,a,i=e.sort(Ha).pop();for(Ua=[],Ra=new Array(e.length),La=new ma,Fa=new ma;;)if(a=Ea,i&&(!a||i[1]Ia||Math.abs(a[0][1]-a[1][1])>Ia)||delete Ua[i]}(l,o,u,c),function(e,t,n,r){var a,i,l,o,u,c,s,f,d,h,p,g,m=Ra.length,v=!0;for(a=0;aIa||Math.abs(g-d)>Ia)&&(u.splice(o,0,Ua.push(ya(l,h,Math.abs(p-e)Ia?[e,Math.abs(f-e)Ia?[Math.abs(d-r)Ia?[n,Math.abs(f-n)Ia?[Math.abs(d-t)=o)return null;var u=e-a.site[0],c=t-a.site[1],s=u*u+c*c;do{a=i.cells[r=l],l=null,a.halfedges.forEach((function(n){var r=i.edges[n],o=r.left;if(o!==a.site&&o||(o=r.right)){var u=e-o[0],c=t-o[1],f=u*u+c*c;f *").remove(),function(e){ee(".viz > *").remove(),ee(".viz").style("overflow-x","hidden").style("overflow-y","hidden").style("position","fixed").attr("height","100%");var t=ee(".viz").append("svg");t.attr("width",e.w).attr("height",e.h).attr("id","svg-viz").attr("preserveAspectRatio","xMidYMid meet").attr("viewBox","".concat(e.w/-2," ").concat(e.h/-2," ").concat(e.w," ").concat(.9*e.h));var n=Qa(e.value,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","vertical-gauge").attr("width",50).attr("height","100%").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",e.h/-2),t.append("rect").attr("class","top-arm").attr("width",ee(".vertical-gauge").attr("width")*(e.arm/100+1)).attr("height","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",e.h/-2),t.append("rect").attr("class","bottom-arm").attr("width",ee(".vertical-gauge").attr("width")*(e.arm/100+1)).attr("height","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("text").attr("class","max-label").attr("dx","-.35em").style("font-weight","bold").text(void 0===e.range_formatting||""===e.range_formatting?e.range[1]:qa.a.format(e.range_formatting,e.range[1])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2-ee(".max-label").node().getBBox().width).attr("y",e.h/-2+ee(".top-arm").node().getBBox().height),t.append("text").attr("class","min-label").attr("dx","-.35em").attr("dy",".7em").style("font-weight","bold").text(void 0===e.range_formatting||""===e.range_formatting?e.range[0]:qa.a.format(e.range_formatting,e.range[0])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2-ee(".min-label").node().getBBox().width).attr("y",ee(".bottom-arm").node().getBBox().y),t.append("rect").attr("class","vertical-fill").attr("width",ee(".vertical-gauge").attr("width")).attr("height","".concat(n*(ee(".vertical-gauge").node().getBBox().height-2*ee(".top-arm").node().getBBox().height))).style("fill",e.color).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".vertical-fill").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("rect").attr("class","value-line").attr("stroke",e.spinner_background).attr("width","".concat(e.spinner/2,"px")).attr("height","".concat(e.spinner_weight/2,"px")).style("fill",e.spinner_background).attr("x",0+ee(".vertical-gauge").attr("width")/2-e.spinner/2).attr("y",ee(".vertical-fill").attr("y")),"value"!==e.value_label_type&&"both"!==e.value_label_type&&"dboth"!==e.value_label_type||t.append("text").attr("class","value-label").text(e.value_rendered).attr("dy",".7em").attr("dx","-".concat(e.value_label_padding/100,"em")).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label").node().getBBox().width).attr("y",ee(".vertical-fill").attr("y")),"label"!==e.value_label_type&&"both"!==e.value_label_type||t.append("text").attr("class","value-label-label").text(e.value_label).attr("dx","-".concat(e.value_label_padding/100,"em")).attr("dy",".5em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.45*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label-label").node().getBBox().width).attr("y",ee(".value-line").node().getBBox().y+("label"===e.value_label_type?0:ee(".value-label").node().getBBox().height)),"dim"!==e.value_label_type&&"dboth"!==e.value_label_type||t.append("text").attr("class","value-label-label").text(e.value_dimension).attr("dx","-".concat(e.value_label_padding/100,"em")).attr("dy",".5em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.45*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label-label").node().getBBox().width).attr("y",ee(".value-line").node().getBBox().y+("dim"===e.value_label_type?0:ee(".value-label").node().getBBox().height)),"off"!==e.target_source){var r=Qa(e.target,0,1,e.range[0],e.range[1]);t.append("rect").attr("class","target-fill").attr("width",ee(".vertical-gauge").attr("width")).attr("height","".concat(r*(ee(".vertical-gauge").node().getBBox().height-2*ee(".top-arm").node().getBBox().height))).style("fill","none").attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".target-fill").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("line").attr("class","target-line").attr("stroke-width","4").attr("fill","none").style("stroke",e.target_background).attr("stroke-dasharray","5").attr("x1",0-.5*ee(".vertical-gauge").attr("width")).attr("y1",ee(".target-fill").attr("y")).attr("x2",0+.7*ee(".vertical-gauge").attr("width")).attr("y2",ee(".target-fill").attr("y")),"value"!==e.target_label_type&&"both"!==e.target_label_type&&"dboth"!==e.target_label_type||t.append("text").attr("class","target-label").text(e.target_rendered).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-fill").attr("y")),"label"!==e.target_label_type&&"both"!==e.target_label_type||t.append("text").attr("class","target-label-label").text(e.target_label).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-line").node().getBBox().y+("label"===e.target_label_type?0:ee(".target-label").node().getBBox().height)),"dim"!==e.target_label_type&&"dboth"!==e.target_label_type||t.append("text").attr("class","target-label-label").text(e.target_dimension).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-line").node().getBBox().y+("dim"===e.target_label_type?0:ee(".target-label").node().getBBox().height))}ee(".value-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})})),ee(".value-label-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})}))}(e)}),[e]),a.a.createElement("div",{className:"viz"})};function Ka(e,t,n,r,a){return(n-t)*(e-r)/(a-r)+t}var Ga,Za=function(e){return Object(r.useEffect)((function(){ee(".viz > *").remove(),function(e){ee(".viz > *").remove(),ee(".viz").style("background-color","#FFF").style("overflow-x","hidden").style("overflow-y","hidden").style("position","fixed").attr("height","100%");var t=ee(".viz").append("svg");t.attr("width",e.w).attr("height",e.h).attr("id","svg-viz").attr("preserveAspectRatio","xMidYMid meet").attr("viewBox","".concat(e.w/-2," ").concat(e.h/-2," ").concat(e.w," ").concat(.9*e.h));var n,r=Ka(e.value,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","horizontal-gauge").attr("width","100%").attr("height",50).style("fill",e.gauge_background).attr("y",0-ee(".horizontal-gauge").node().getBBox().height).attr("x",e.w/-2),t.append("rect").attr("class","left-arm").attr("height",ee(".horizontal-gauge").attr("height")*(e.arm/100+1)).attr("width","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("y",ee(".horizontal-gauge").node().getBBox().y-(ee(".left-arm").node().getBBox().height-ee(".horizontal-gauge").node().getBBox().height)).attr("x",e.w/-2),t.append("rect").attr("class","right-arm").attr("height",ee(".horizontal-gauge").attr("height")*(e.arm/100+1)).attr("width","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",e.w/2-ee(".right-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y-(ee(".right-arm").node().getBBox().height-ee(".horizontal-gauge").node().getBBox().height)),t.append("text").attr("class","max-label").style("font-weight","bold").attr("dy",".7em").text(void 0===e.range_formatting||""===e.range_formatting?e.range[1]:qa.a.format(e.range_formatting,e.range[1])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0+ee(".horizontal-gauge").node().getBBox().width/2-ee(".left-arm").node().getBBox().width-ee(".max-label").node().getBBox().width).attr("y",ee(".right-arm").node().getBBox().y-ee(".max-label").node().getBBox().height),t.append("text").attr("class","min-label").style("font-weight","bold").attr("dy",".7em").text(void 0===e.range_formatting||""===e.range_formatting?e.range[0]:qa.a.format(e.range_formatting,e.range[0])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".horizontal-gauge").node().getBBox().width/2+ee(".left-arm").node().getBBox().width).attr("y",ee(".left-arm").node().getBBox().y-ee(".min-label").node().getBBox().height),t.append("rect").attr("class","horizontal-fill").attr("height",ee(".horizontal-gauge").attr("height")).attr("width","".concat(r*(ee(".horizontal-gauge").node().getBBox().width-2*ee(".left-arm").node().getBBox().width))).style("fill",e.color).attr("x",e.w/-2+ee(".left-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y),t.append("rect").attr("class","value-line").attr("stroke",e.spinner_background).attr("height",ee(".horizontal-gauge").attr("height")*(e.spinner/400+1)).attr("width","".concat(e.spinner_weight/2,"px")).style("fill",e.spinner_background).attr("y",ee(".horizontal-fill").attr("y")).attr("x",ee(".horizontal-fill").node().getBBox().x+ee(".horizontal-fill").node().getBBox().width-ee(".value-line").node().getBBox().width),"value"===e.value_label_type||"both"===e.value_label_type||"dboth"===e.value_label_type){var a=t.append("text").attr("class","value-label").text(e.value_rendered).attr("dy","".concat(e.value_label_padding/3)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(e.value_label_font).concat(e.limiting_aspect));n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+3*ee(".value-label").node().getBBox().height/4)}("label"!==e.value_label_type&&"both"!==e.value_label_type||(a=t.append("text").attr("class","value-label-label").text(e.value_label).attr("dy","".concat(e.value_label_padding/2)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(3*e.value_label_font/4).concat(e.limiting_aspect)),n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+("label"===e.value_label_type?ee(".value-line").node().getBBox().height/3:1.3*ee(".value-label").node().getBBox().height))),"dim"===e.value_label_type||"dboth"===e.value_label_type)&&(a=t.append("text").attr("class","value-label-label").text(e.value_dimension).attr("dy","".concat(e.value_label_padding)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(3*e.value_label_font/4).concat(e.limiting_aspect)),n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+("dim"===e.value_label_type?ee(".value-line").node().getBBox().height/3:1.3*ee(".value-label").node().getBBox().height)));if("off"!==e.target_source){var i=Ka(e.target,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","target-fill").attr("height",ee(".horizontal-gauge").attr("height")).attr("width","".concat(i*(ee(".horizontal-gauge").node().getBBox().width-2*ee(".left-arm").node().getBBox().width))).style("fill","none").attr("x",e.w/-2+ee(".left-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y),"none"!==e.target_label_type){if(t.append("line").attr("class","target-line").attr("stroke-width","4").attr("fill","none").style("stroke",e.target_background).attr("stroke-dasharray","5").attr("x1",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y1",ee(".target-fill").node().getBBox().y).attr("x2",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y2",ee(".target-fill").node().getBBox().y+ee(".target-fill").node().getBBox().height),"value"===e.target_label_type)var l="".concat(e.target_rendered);else"label"===e.target_label_type?l="".concat(e.target_label):"both"===e.target_label_type?l="".concat(e.target_rendered," ").concat(e.target_label):"dim"===e.target_label_type?l="".concat(e.target_dimension):"dboth"===e.target_label_type&&(l="".concat(e.target_rendered," ").concat(e.target_dimension));t.append("text").attr("class","target-label").text(l).style("font-size","".concat(e.target_label_font).concat(e.limiting_aspect)).style("font-family","Arial, Helvetica, sans-serif").attr("x",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y",ee(".target-fill").node().getBBox().y-ee(".target-label").node().getBBox().height/2)}}ee(".value-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})})),ee(".value-label-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})}))}(e)}),[e]),a.a.createElement("div",{className:"viz"})};function Ja(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ei={id:"gauge",label:"Gauge Visualization",options:{bar_arm_length:{type:"number",label:"Arm Length",default:9,section:"Plot",display:"range",min:0,max:50,step:.5,order:200,display_size:"half"},bar_arm_weight:{type:"number",label:"Thickness",default:48,section:"Plot",display:"range",min:0,max:100,order:300,display_size:"half"},bar_spinner_length:{type:"number",label:"Pointer Length",default:121,section:"Plot",display:"range",min:0,max:200,order:400,display_size:"half"},bar_spinner_weight:(Ga={type:"number",label:"Thickness",default:25,section:"Plot",display:"range",min:0,max:100},Ja(Ga,"default",25),Ja(Ga,"order",500),Ja(Ga,"display_size","half"),Ga),bar_style:{type:"string",label:"Gauge Type",display:"select",section:"Plot",values:[{Vertical:"vertical"},{Horizontal:"horizontal"}],default:"vertical",order:0},bar_range_min:{type:"number",label:"Range Min Override",section:"Plot",order:30,default:0,display_size:"half"},bar_range_max:{type:"number",label:"Range Max Override",section:"Plot",order:31,default:100.701,display_size:"half"},bar_value_label_type:{type:"string",label:"Value Label Type",display:"select",section:"Value",values:[{"Value and Measure Label":"both"},{"Value and Dimension":"dboth"},{"Only Value":"value"},{"Only Label":"label"},{"Only Dimension":"dim"},{None:"none"}],default:"both",order:40},bar_value_label_font:{type:"number",label:"Value Label Font Size",section:"Value",default:8,order:50},bar_value_formatting:{type:"string",label:"Value Formatting Override",section:"Value",order:51},bar_value_label_override:{type:"string",label:"Value Label Override",section:"Value",order:60},bar_value_label_padding:{type:"number",label:"Value Label Padding",default:45,section:"Value",display:"range",min:0,max:120,order:70},bar_target_source:{type:"string",label:"Target Source",display:"select",section:"Target",values:[{"First Measure":"first"},{"Second Measure":"second"},{Override:"override"},{"No Target":"off"}],default:"off",order:80},bar_target_label_type:{type:"string",label:"Target Label Type",display:"select",section:"Target",values:[{"Value and Label":"both"},{"Only Value":"value"},{"Only Label":"label"},{"Value and Dimension":"dboth"},{"Only Dimension":"dim"},{"No Label":"nolabel"}],default:"none",order:90},bar_target_label_font:{type:"number",label:"Target Label Font Size",section:"Target",default:3,order:100},bar_target_label_override:{type:"string",label:"Target Label Override",section:"Target",order:120},bar_target_value_override:{type:"string",label:"Target Value Override",section:"Target",order:110},bar_target_value_format:{type:"string",label:"Target Value Formatting",section:"Target",order:120},bar_label_font_size:{type:"number",label:"Range Label Font Size",section:"Plot",default:3,order:140},bar_range_formatting:{type:"string",label:"Range Label Value Formatting",section:"Plot",order:150},bar_fill_color:{type:"string",label:"Gauge Fill Color",section:"Style",display:"color",default:"#0092E5",order:10},bar_background_color:{type:"string",label:"Background Color",default:"#CECECE",section:"Style",display:"color",order:20},bar_spinner_color:{type:"string",label:"Pointer Color",default:"#282828",section:"Style",display:"color",order:30},bar_range_color:{type:"string",label:"Range Label Color",default:"#282828",section:"Style",display:"color",order:40}}},ti=n(11),ni=n.n(ti);function ri(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ai(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}looker.plugins.visualizations.add(function(e){for(var t=1;t1||r.fields.measure_like.length>2)this.addError({title:"Invalid Input.",message:"This chart accepts up to 1 dimension and 2 measures."});else{var c;if(c=function(e,t,n,r){var a,i,l,o,u,c,s,f,d,h,p,g,m,v;return a=t.fields.dimension_like,l=t.fields.measure_like,a.length>0&&(i=a[0].name,e[0][i]),"dim"!==n.bar_value_label_type&&"dboth"!==n.bar_value_label_type||0===a.length&&r&&r.addError({title:"Invalid Input.",message:"Add a dimension or modify label type."}),"dim"!==n.bar_target_label_type&&"dboth"!==n.bar_target_label_type||0===a.length&&r&&r.addError({title:"Invalid Input.",message:"Add a dimension or modify label type."}),o=l[0].name,u=e[0][o],c=void 0===l[0].label_short?l[0].label:l[0].label_short,s=void 0===u.rendered?u.value:u.rendered,"second"===n.bar_target_source?(l.length<2&&r&&r.addError({title:"Invalid Input.",message:"Add a second measure or modify label type."}),f=l[1].name,h=(d=e[0][f]).value,p=void 0===l[1].label_short?l[1].label:l[1].label_short,g=void 0===d.rendered?d.value:d.rendered,m=void 0===n.bar_target_value_format||""===n.bar_target_value_format?g:qa.a.format(n.bar_target_value_format,h),a.length>0&&(v=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[0][i].value:n.bar_target_label_override)):"first"===n.bar_target_source?(e.length<2&&r&&r.addError({title:"Invalid Input.",message:"No value to target. Add a second row or modify label type."}),h=(d=e[1][o]).value,g=void 0===d.rendered||""===d.rendered?h:d.rendered,p=c,m=void 0===n.bar_target_value_format||""===n.bar_target_value_format?g:qa.a.format(n.bar_target_value_format,h),a.length>0&&(v=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[1][i].value:n.bar_target_label_override)):"override"===n.bar_target_source&&((void 0===n.bar_target_value_override||""===n.bar_target_value_override&&r)&&r.addError({title:"Invalid Input.",message:"No target override. Add an override value or modify label type."}),g=h=parseFloat(n.bar_target_value_override),p=n.bar_target_label_override,m=void 0===n.bar_target_value_format||""===n.bar_target_value_format?g:qa.a.format(n.bar_target_value_format,h),a.length>0&&(v=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[0][i].value:n.bar_target_label_override)),{value:u.value,value_links:u.links,value_label:void 0===n.bar_value_label_override||""===n.bar_value_label_override?c:n.bar_value_label_override,value_rendered:void 0===n.bar_value_formatting||""===n.bar_value_formatting?s:qa.a.format(n.bar_value_formatting,u.value),value_dimension:a.length>0?void 0===n.bar_value_label_override||""===n.bar_value_label_override?e[0][i].value:n.bar_value_label_override:null,value_formatting:n.bar_value_formatting,target:h,target_rendered:m,target_label:void 0===n.bar_target_label_override||""===n.bar_target_label_override?p:n.bar_target_label_override,target_dimension:v}}(e,r,n,this),!n.bar_range_max){var s=Math.max(Math.ceil(c.value),c.target?Math.ceil(c.target):0),f=(s+"").length,d=Math.pow(10,f-1),h=Math.ceil(s/d)*d;n.bar_range_max=h}this.barDefaults=function(e,t,n,r,a){var i;return{w:e,h:t,limiting_aspect:er.bar_range_max?r.bar_range_max:a.value,value_rendered:a.value_rendered,target:a.target>r.bar_range_max?r.bar_range_max:a.target,value_label:a.value_label,target_label:a.target_label,value_dimension:a.value_dimension,target_dimension:a.target_dimension,target_rendered:a.target_rendered,value_links:a.value_links,label_font:r.bar_label_font_size,range_formatting:null!==(i=r.bar_range_formatting)&&void 0!==i?i:a.value_formatting,range_x:r.bar_range_x,range_y:r.bar_range_y,gauge_fill_type:r.bar_gauge_fill_type,fill_colors:r.bar_fill_colors,range_color:r.bar_range_color,spinner:r.bar_spinner_length,spinner_weight:r.bar_spinner_weight,spinner_background:r.bar_spinner_color,arm:r.bar_arm_length,arm_weight:r.bar_arm_weight,target_length:r.bar_target_length,target_gap:r.bar_target_gap,target_weight:r.bar_target_weight,target_background:"#282828",target_source:r.bar_target_source,value_label_type:r.bar_value_label_type,value_label_font:r.bar_value_label_font,value_label_padding:r.bar_value_label_padding,target_label_type:r.bar_target_label_type,target_label_font:r.bar_target_label_font,target_label_padding:r.bar_target_label_padding,wrap_width:100}}(o,u,0,n,c),"vertical"===n.bar_style?this.chart=ni.a.render(a.a.createElement(Xa,this.barDefaults),this.container):"horizontal"===n.bar_style&&(this.chart=ni.a.render(a.a.createElement(Za,this.barDefaults),this.container)),l()}}}))}])})); \ No newline at end of file + */var r,a,i,l,o;if("undefined"==typeof window||"function"!=typeof MessageChannel){var u=null,c=null,s=function(){if(null!==u)try{var e=t.unstable_now();u(!0,e),u=null}catch(e){throw setTimeout(s,0),e}},f=Date.now();t.unstable_now=function(){return Date.now()-f},r=function(e){null!==u?setTimeout(r,0,e):(u=e,setTimeout(s,0))},a=function(e,t){c=setTimeout(e,t)},i=function(){clearTimeout(c)},l=function(){return!1},o=t.unstable_forceFrameRate=function(){}}else{var d=window.performance,h=window.Date,p=window.setTimeout,g=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills")}if("object"==typeof d&&"function"==typeof d.now)t.unstable_now=function(){return d.now()};else{var v=h.now();t.unstable_now=function(){return h.now()-v}}var y=!1,b=null,_=-1,w=5,x=0;l=function(){return t.unstable_now()>=x},o=function(){},t.unstable_forceFrameRate=function(e){0>e||125>>1,a=e[r];if(!(void 0!==a&&0M(l,n))void 0!==u&&0>M(u,l)?(e[r]=u,e[o]=n,r=o):(e[r]=l,e[i]=n,r=i);else{if(!(void 0!==u&&0>M(u,n)))break e;e[r]=u,e[o]=n,r=o}}}return t}return null}function M(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var P=[],N=[],A=1,O=null,z=3,B=!1,D=!1,L=!1;function R(e){for(var t=C(N);null!==t;){if(null===t.callback)S(N);else{if(!(t.startTime<=e))break;S(N),t.sortIndex=t.expirationTime,E(P,t)}t=C(N)}}function F(e){if(L=!1,R(e),!D)if(null!==C(P))D=!0,r(U);else{var t=C(N);null!==t&&a(F,t.startTime-e)}}function U(e,n){D=!1,L&&(L=!1,i()),B=!0;var r=z;try{for(R(n),O=C(P);null!==O&&(!(O.expirationTime>n)||e&&!l());){var o=O.callback;if(null!==o){O.callback=null,z=O.priorityLevel;var u=o(O.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?O.callback=u:O===C(P)&&S(P),R(n)}else S(P);O=C(P)}if(null!==O)var c=!0;else{var s=C(N);null!==s&&a(F,s.startTime-n),c=!1}return c}finally{O=null,z=r,B=!1}}function I(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var $=o;t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){D||B||(D=!0,r(U))},t.unstable_getCurrentPriorityLevel=function(){return z},t.unstable_getFirstCallbackNode=function(){return C(P)},t.unstable_next=function(e){switch(z){case 1:case 2:case 3:var t=3;break;default:t=z}var n=z;z=t;try{return e()}finally{z=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=$,t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=z;z=e;try{return t()}finally{z=n}},t.unstable_scheduleCallback=function(e,n,l){var o=t.unstable_now();if("object"==typeof l&&null!==l){var u=l.delay;u="number"==typeof u&&0o?(e.sortIndex=u,E(N,e),null===C(P)&&e===C(N)&&(L?i():L=!0,a(F,u-o))):(e.sortIndex=l,E(P,e),D||B||(D=!0,r(U))),e},t.unstable_shouldYield=function(){var e=t.unstable_now();R(e);var n=C(P);return n!==O&&null!==O&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTimet?1:e>=t?0:NaN},l=function(e){return 1===e.length&&(e=function(e){return function(t,n){return i(e(t),n)}}(e)),{left:function(t,n,r,a){for(null==r&&(r=0),null==a&&(a=t.length);r>>1;e(t[i],n)<0?r=i+1:a=i}return r},right:function(t,n,r,a){for(null==r&&(r=0),null==a&&(a=t.length);r>>1;e(t[i],n)>0?a=i:r=i+1}return r}}}(i);l.right,l.left;var o=Array.prototype;o.slice,o.map,Math.sqrt(50),Math.sqrt(10),Math.sqrt(2),Array.prototype.slice;var u={value:function(){}};function c(){for(var e,t=0,n=arguments.length,r={};t=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}(e+"",r),i=-1,l=a.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++i0)for(var n,r,a=new Array(n),i=0;it?1:e>=t?0:NaN}var T="http://www.w3.org/1999/xhtml",E={svg:"http://www.w3.org/2000/svg",xhtml:T,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},C=function(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),E.hasOwnProperty(t)?{space:E[t],local:e}:e},S=function(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView};function M(e,t){return e.style.getPropertyValue(t)||S(e).getComputedStyle(e,null).getPropertyValue(t)}function P(e){return e.trim().split(/^|\s+/)}function N(e){return e.classList||new A(e)}function A(e){this._node=e,this._names=P(e.getAttribute("class")||"")}function O(e,t){for(var n=N(e),r=-1,a=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var F=function(e){var t=C(e);return(t.local?function(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===T&&t.documentElement.namespaceURI===T?t.createElement(e):t.createElementNS(n,e)}})(t)};function U(){return null}function I(){var e=this.parentNode;e&&e.removeChild(this)}function $(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function j(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}var H={},V=null;function W(e,t,n){return e=Y(e,t,n),function(t){var n=t.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||e.call(this,t)}}function Y(e,t,n){return function(r){var a=V;V=r;try{e.call(this,this.__data__,t,n)}finally{V=a}}}function q(e){return function(){var t=this.__on;if(t){for(var n,r=0,a=-1,i=t.length;r=_&&(_=b+1);!(y=m[_])&&++_=0;)(r=a[i])&&(l&&4^r.compareDocumentPosition(l)&&l.parentNode.insertBefore(r,l),l=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=k);for(var n=this._groups,r=n.length,a=new Array(r),i=0;i1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):M(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=P(e+"");if(arguments.length<2){for(var r=N(this.node()),a=-1,i=n.length;++a=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),l=i.length;if(!(arguments.length<2)){for(o=t?Q:q,null==n&&(n=!1),r=0;r>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?be(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?be(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=ue.exec(e))?new we(t[1],t[2],t[3],1):(t=ce.exec(e))?new we(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=se.exec(e))?be(t[1],t[2],t[3],t[4]):(t=fe.exec(e))?be(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=de.exec(e))?Ee(t[1],t[2]/100,t[3]/100,1):(t=he.exec(e))?Ee(t[1],t[2]/100,t[3]/100,t[4]):pe.hasOwnProperty(e)?ye(pe[e]):"transparent"===e?new we(NaN,NaN,NaN,0):null}function ye(e){return new we(e>>16&255,e>>8&255,255&e,1)}function be(e,t,n,r){return r<=0&&(e=t=n=NaN),new we(e,t,n,r)}function _e(e,t,n,r){return 1===arguments.length?function(e){return e instanceof re||(e=ve(e)),e?new we((e=e.rgb()).r,e.g,e.b,e.opacity):new we}(e):new we(e,t,n,null==r?1:r)}function we(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function xe(){return"#"+Te(this.r)+Te(this.g)+Te(this.b)}function ke(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function Te(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function Ee(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Se(e,t,n,r)}function Ce(e){if(e instanceof Se)return new Se(e.h,e.s,e.l,e.opacity);if(e instanceof re||(e=ve(e)),!e)return new Se;if(e instanceof Se)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),i=Math.max(t,n,r),l=NaN,o=i-a,u=(i+a)/2;return o?(l=t===i?(n-r)/o+6*(n0&&u<1?0:l,new Se(l,o,u,e.opacity)}function Se(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function Me(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function Pe(e,t,n,r,a){var i=e*e,l=i*e;return((1-3*e+3*i-l)*t+(4-6*i+3*l)*n+(1+3*e+3*i-3*l)*r+l*a)/6}te(re,ve,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:ge,formatHex:ge,formatHsl:function(){return Ce(this).formatHsl()},formatRgb:me,toString:me}),te(we,_e,ne(re,{brighter:function(e){return e=null==e?1/.7:Math.pow(1/.7,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?.7:Math.pow(.7,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xe,formatHex:xe,formatRgb:ke,toString:ke})),te(Se,(function(e,t,n,r){return 1===arguments.length?Ce(e):new Se(e,t,n,null==r?1:r)}),ne(re,{brighter:function(e){return e=null==e?1/.7:Math.pow(1/.7,e),new Se(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?.7:Math.pow(.7,e),new Se(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new we(Me(e>=240?e-240:e+120,a,r),Me(e,a,r),Me(e<120?e+240:e-120,a,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));var Ne=function(e){return function(){return e}};function Ae(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):Ne(isNaN(e)?t:e)}var Oe=function e(t){var n=function(e){return 1==(e=+e)?Ae:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):Ne(isNaN(t)?n:t)}}(t);function r(e,t){var r=n((e=_e(e)).r,(t=_e(t)).r),a=n(e.g,t.g),i=n(e.b,t.b),l=Ae(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=a(t),e.b=i(t),e.opacity=l(t),e+""}}return r.gamma=e,r}(1);function ze(e){return function(t){var n,r,a=t.length,i=new Array(a),l=new Array(a),o=new Array(a);for(n=0;n=1?(n=1,t-1):Math.floor(n*t),a=e[r],i=e[r+1],l=r>0?e[r-1]:2*a-i,o=ri&&(a=t.slice(i,a),o[l]?o[l]+=a:o[++l]=a),(n=n[0])===(r=r[0])?o[l]?o[l]+=r:o[++l]=r:(o[++l]=null,u.push({i:l,x:Le(n,r)})),i=Fe.lastIndex;return i=0&&t._call.call(null,e),t=t._next;--Ie}()}finally{Ie=0,function(){for(var e,t,n=Be,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Be=t);De=e,et(r)}(),Ve=0}}function Je(){var e=Ye.now(),t=e-He;t>1e3&&(We-=t,He=e)}function et(e){Ie||($e&&($e=clearTimeout($e)),e-Ve>24?(e<1/0&&($e=setTimeout(Ze,e-Ye.now()-We)),je&&(je=clearInterval(je))):(je||(He=Ye.now(),je=setInterval(Je,1e3)),Ie=1,qe(Ze)))}Ke.prototype=Ge.prototype={constructor:Ke,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Qe():+n)+(null==t?0:+t),this._next||De===this||(De?De._next=this:Be=this,De=this),this._call=e,this._time=n,et()},stop:function(){this._call&&(this._call=null,this._time=1/0,et())}};var tt=function(e,t,n){var r=new Ke;return t=null==t?0:+t,r.restart((function(n){r.stop(),e(n+t)}),t,n),r},nt=h("start","end","cancel","interrupt"),rt=[],at=function(e,t,n,r,a,i){var l=e.__transition;if(l){if(n in l)return}else e.__transition={};!function(e,t,n){var r,a=e.__transition;function i(u){var c,s,f,d;if(1!==n.state)return o();for(c in a)if((d=a[c]).name===n.name){if(3===d.state)return tt(i);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete a[c]):+c0)throw new Error("too late; already scheduled");return n}function lt(e,t){var n=ot(e,t);if(n.state>3)throw new Error("too late; already running");return n}function ot(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}var ut,ct,st,ft,dt=180/Math.PI,ht={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},pt=function(e,t,n,r,a,i){var l,o,u;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,u/=o),e*r180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(a(n)+"rotate(",null,r)-2,x:Le(e,t)})):t&&n.push(a(n)+"rotate("+t+r)}(i.rotate,l.rotate,o,u),function(e,t,n,i){e!==t?i.push({i:n.push(a(n)+"skewX(",null,r)-2,x:Le(e,t)}):t&&n.push(a(n)+"skewX("+t+r)}(i.skewX,l.skewX,o,u),function(e,t,n,r,i,l){if(e!==n||t!==r){var o=i.push(a(i)+"scale(",null,",",null,")");l.push({i:o-4,x:Le(e,n)},{i:o-2,x:Le(t,r)})}else 1===n&&1===r||i.push(a(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,l.scaleX,l.scaleY,o,u),i=l=null,function(e){for(var t,n=-1,r=u.length;++n=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?it:lt;return function(){var l=i(this,e),o=l.on;o!==r&&(a=(r=o).copy()).on(t,n),l.on=a}}(n,e,t))},attr:function(e,t){var n=C(e),r="transform"===n?vt:bt;return this.attrTween(e,"function"==typeof t?(n.local?function(e,t,n){var r,a,i;return function(){var l,o,u=n(this);if(null!=u)return(l=this.getAttributeNS(e.space,e.local))===(o=u+"")?null:l===r&&o===a?i:(a=o,i=t(r=l,u));this.removeAttributeNS(e.space,e.local)}}:function(e,t,n){var r,a,i;return function(){var l,o,u=n(this);if(null!=u)return(l=this.getAttribute(e))===(o=u+"")?null:l===r&&o===a?i:(a=o,i=t(r=l,u));this.removeAttribute(e)}})(n,r,yt(this,"attr."+e,t)):null==t?(n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}})(n):(n.local?function(e,t,n){var r,a,i=n+"";return function(){var l=this.getAttributeNS(e.space,e.local);return l===i?null:l===r?a:a=t(r=l,n)}}:function(e,t,n){var r,a,i=n+"";return function(){var l=this.getAttribute(e);return l===i?null:l===r?a:a=t(r=l,n)}})(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=C(e);return this.tween(n,(r.local?function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,a)),n}return a._value=t,a}:function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,a)),n}return a._value=t,a})(r,t))},style:function(e,t,n){var r="transform"==(e+="")?mt:bt;return null==t?this.styleTween(e,function(e,t){var n,r,a;return function(){var i=M(this,e),l=(this.style.removeProperty(e),M(this,e));return i===l?null:i===n&&l===r?a:a=t(n=i,r=l)}}(e,r)).on("end.style."+e,wt(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var r,a,i;return function(){var l=M(this,e),o=n(this),u=o+"";return null==o&&(this.style.removeProperty(e),u=o=M(this,e)),l===u?null:l===r&&u===a?i:(a=u,i=t(r=l,o))}}(e,r,yt(this,"style."+e,t))).each(function(e,t){var n,r,a,i,l="style."+t,o="end."+l;return function(){var u=lt(this,e),c=u.on,s=null==u.value[l]?i||(i=wt(t)):void 0;c===n&&a===s||(r=(n=c).copy()).on(o,a=s),u.on=r}}(this._id,e)):this.styleTween(e,function(e,t,n){var r,a,i=n+"";return function(){var l=M(this,e);return l===i?null:l===r?a:a=t(r=l,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function(e,t,n){var r,a;function i(){var i=t.apply(this,arguments);return i!==a&&(r=(a=i)&&function(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,i,n)),r}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(yt(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&function(e){return function(t){this.textContent=e.call(this,t)}}(r)),t}return r._value=e,r}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,a=ot(this.node(),n).tween,i=0,l=a.length;i2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[a]):l=!1;l&&delete e.__transition}}(this,e)}))},J.prototype.transition=function(e){var t,n;e instanceof kt?(t=e._id,e=e._name):(t=Tt(),(n=Ct).time=Qe(),e=null==e?null:e+"");for(var r=this._groups,a=r.length,i=0;i1e-6)if(Math.abs(s*o-u*c)>1e-6&&a){var d=n-i,h=r-l,p=o*o+u*u,g=d*d+h*h,m=Math.sqrt(p),v=Math.sqrt(f),y=a*Math.tan((Pt-Math.acos((p+f-g)/(2*m*v)))/2),b=y/v,_=y/m;Math.abs(b-1)>1e-6&&(this._+="L"+(e+b*c)+","+(t+b*s)),this._+="A"+a+","+a+",0,0,"+ +(s*d>c*h)+","+(this._x1=e+_*o)+","+(this._y1=t+_*u)}else this._+="L"+(this._x1=e)+","+(this._y1=t)},arc:function(e,t,n,r,a,i){e=+e,t=+t,i=!!i;var l=(n=+n)*Math.cos(r),o=n*Math.sin(r),u=e+l,c=t+o,s=1^i,f=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+u+","+c:(Math.abs(this._x1-u)>1e-6||Math.abs(this._y1-c)>1e-6)&&(this._+="L"+u+","+c),n&&(f<0&&(f=f%Nt+Nt),f>At?this._+="A"+n+","+n+",0,1,"+s+","+(e-l)+","+(t-o)+"A"+n+","+n+",0,1,"+s+","+(this._x1=u)+","+(this._y1=c):f>1e-6&&(this._+="A"+n+","+n+",0,"+ +(f>=Pt)+","+s+","+(this._x1=e+n*Math.cos(a))+","+(this._y1=t+n*Math.sin(a))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}},zt.prototype=Bt.prototype={constructor:zt,has:function(e){return"$"+e in this},get:function(e){return this["$"+e]},set:function(e,t){return this["$"+e]=t,this},remove:function(e){var t="$"+e;return t in this&&delete this[t]},clear:function(){for(var e in this)"$"===e[0]&&delete this[e]},keys:function(){var e=[];for(var t in this)"$"===t[0]&&e.push(t.slice(1));return e},values:function(){var e=[];for(var t in this)"$"===t[0]&&e.push(this[t]);return e},entries:function(){var e=[];for(var t in this)"$"===t[0]&&e.push({key:t.slice(1),value:this[t]});return e},size:function(){var e=0;for(var t in this)"$"===t[0]&&++e;return e},empty:function(){for(var e in this)if("$"===e[0])return!1;return!0},each:function(e){for(var t in this)"$"===t[0]&&e(this[t],t.slice(1),this)}};var Lt=Bt.prototype;Dt.prototype=function(e,t){var n=new Dt;if(e instanceof Dt)e.each((function(e){n.add(e)}));else if(e){var r=-1,a=e.length;if(null==t)for(;++r=i?u=!0:10===(r=e.charCodeAt(l++))?c=!0:13===r&&(c=!0,10===e.charCodeAt(l)&&++l),e.slice(a+1,t-1).replace(/""/g,'"')}for(;l9999?"+"+$t(e,6):$t(e,4)}(e.getUTCFullYear())+"-"+$t(e.getUTCMonth()+1,2)+"-"+$t(e.getUTCDate(),2)+(a?"T"+$t(t,2)+":"+$t(n,2)+":"+$t(r,2)+"."+$t(a,3)+"Z":r?"T"+$t(t,2)+":"+$t(n,2)+":"+$t(r,2)+"Z":n||t?"T"+$t(t,2)+":"+$t(n,2)+"Z":"")}(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,i=r(e,(function(e,r){if(n)return n(e,r-1);a=e,n=t?function(e,t){var n=Ut(e);return function(r,a){return t(n(r),a,e)}}(e,t):Ut(e)}));return i.columns=a||[],i},parseRows:r,format:function(t,n){return null==n&&(n=It(t)),[n.map(l).join(e)].concat(a(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=It(e)),a(e,t).join("\n")},formatRows:function(e){return e.map(i).join("\n")},formatRow:i,formatValue:l}},Ht=jt(","),Vt=Ht.parse,Wt=(Ht.parseRows,Ht.format,Ht.formatBody,Ht.formatRows,Ht.formatRow,Ht.formatValue,jt("\t")),Yt=Wt.parse;function qt(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.text()}Wt.parseRows,Wt.format,Wt.formatBody,Wt.formatRows,Wt.formatRow,Wt.formatValue;var Qt=function(e,t){return fetch(e,t).then(qt)};function Xt(e){return function(t,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),Qt(t,n).then((function(t){return e(t,r)}))}}function Kt(e){return function(t,n){return Qt(t,n).then((function(t){return(new DOMParser).parseFromString(t,e)}))}}function Gt(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var a,i,l,o,u,c,s,f,d,h=e._root,p={data:r},g=e._x0,m=e._y0,v=e._x1,y=e._y1;if(!h)return e._root=p,e;for(;h.length;)if((c=t>=(i=(g+v)/2))?g=i:v=i,(s=n>=(l=(m+y)/2))?m=l:y=l,a=h,!(h=h[f=s<<1|c]))return a[f]=p,e;if(o=+e._x.call(null,h.data),u=+e._y.call(null,h.data),t===o&&n===u)return p.next=h,a?a[f]=p:e._root=p,e;do{a=a?a[f]=new Array(4):e._root=new Array(4),(c=t>=(i=(g+v)/2))?g=i:v=i,(s=n>=(l=(m+y)/2))?m=l:y=l}while((f=s<<1|c)==(d=(u>=l)<<1|o>=i));return a[d]=h,a[f]=p,e}Xt(Vt),Xt(Yt),Kt("application/xml"),Kt("text/html"),Kt("image/svg+xml");var Zt=function(e,t,n,r,a){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=a};function Jt(e){return e[0]}function en(e){return e[1]}function tn(e,t,n,r,a,i){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=a,this._y1=i,this._root=void 0}function nn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var rn=function(e,t,n){var r=new tn(null==t?Jt:t,null==n?en:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}.prototype=tn.prototype;rn.copy=function(){var e,t,n=new tn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=nn(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var a=0;a<4;++a)(t=r.source[a])&&(t.length?e.push({source:t,target:r.target[a]=new Array(4)}):r.target[a]=nn(t));return n},rn.add=function(e){var t=+this._x.call(null,e),n=+this._y.call(null,e);return Gt(this.cover(t,n),t,n,e)},rn.addAll=function(e){var t,n,r,a,i=e.length,l=new Array(i),o=new Array(i),u=1/0,c=1/0,s=-1/0,f=-1/0;for(n=0;ns&&(s=r),af&&(f=a));if(u>s||c>f)return this;for(this.cover(u,c).cover(s,f),n=0;ne||e>=a||r>t||t>=i;)switch(o=(td||(i=u.y0)>h||(l=u.x1)=v)<<1|e>=m)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u)}else{var y=e-+this._x.call(null,g.data),b=t-+this._y.call(null,g.data),_=y*y+b*b;if(_=(o=(p+m)/2))?p=o:m=o,(s=l>=(u=(g+v)/2))?g=u:v=u,t=h,!(h=h[f=s<<1|c]))return this;if(!h.length)break;(t[f+1&3]||t[f+2&3]||t[f+3&3])&&(n=t,d=f)}for(;h.data!==e;)if(r=h,!(h=h.next))return this;return(a=h.next)&&delete h.next,r?(a?r.next=a:delete r.next,this):t?(a?t[f]=a:delete t[f],(h=t[0]||t[1]||t[2]||t[3])&&h===(t[3]||t[2]||t[1]||t[0])&&!h.length&&(n?n[d]=h:this._root=h),this):(this._root=a,this)},rn.removeAll=function(e){for(var t=0,n=e.length;t1);return e+n*i*Math.sqrt(-2*Math.log(a)/a)}}return n.source=e,n}(an)),on=(function e(t){function n(){var e=ln.source(t).apply(this,arguments);return function(){return Math.exp(e())}}return n.source=e,n}(an),function e(t){function n(e){return function(){for(var n=0,r=0;r=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sn(e){if(!(t=cn.exec(e)))throw new Error("invalid format: "+e);var t;return new fn({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function fn(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}sn.prototype=fn.prototype,fn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var dn,hn,pn=function(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]},gn=function(e,t){var n=pn(e,t);if(!n)return e+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")},mn={"%":function(e,t){return(100*e).toFixed(t)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:function(e){return Math.round(e).toString(10)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},g:function(e,t){return e.toPrecision(t)},o:function(e){return Math.round(e).toString(8)},p:function(e,t){return gn(100*e,t)},r:gn,s:function(e,t){var n=pn(e,t);if(!n)return e+"";var r=n[0],a=n[1],i=a-(dn=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,l=r.length;return i===l?r:i>l?r+new Array(i-l+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+pn(e,Math.max(0,t+i-1))[0]},X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}},vn=function(e){return e},yn=Array.prototype.map,bn=["y","z","a","f","p","n","ยต","m","","k","M","G","T","P","E","Z","Y"];(hn=function(e){var t=void 0===e.grouping||void 0===e.thousands?vn:function(e,t){return function(n,r){for(var a=n.length,i=[],l=0,o=e[0],u=0;a>0&&o>0&&(u+o+1>r&&(o=Math.max(1,r-u)),i.push(n.substring(a-=o,a+o)),!((u+=o+1)>r));)o=e[l=(l+1)%e.length];return i.reverse().join(t)}}(yn.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",r=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",i=void 0===e.numerals?vn:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(yn.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",o=void 0===e.minus?"-":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function c(e){var c=(e=sn(e)).fill,s=e.align,f=e.sign,d=e.symbol,h=e.zero,p=e.width,g=e.comma,m=e.precision,v=e.trim,y=e.type;"n"===y?(g=!0,y="g"):mn[y]||(void 0===m&&(m=12),v=!0,y="g"),(h||"0"===c&&"="===s)&&(h=!0,c="0",s="=");var b="$"===d?n:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===d?r:/[%p]/.test(y)?l:"",w=mn[y],x=/[defgprs%]/.test(y);function k(e){var n,r,l,d=b,k=_;if("c"===y)k=w(e)+k,e="";else{var T=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:w(Math.abs(e),m),v&&(e=function(e){e:for(var t,n=e.length,r=1,a=-1;r0&&(a=0)}return a>0?e.slice(0,a)+e.slice(t+1):e}(e)),T&&0==+e&&"+"!==f&&(T=!1),d=(T?"("===f?f:o:"-"===f||"("===f?"":f)+d,k=("s"===y?bn[8+dn/3]:"")+k+(T&&"("===f?")":""),x)for(n=-1,r=e.length;++n(l=e.charCodeAt(n))||l>57){k=(46===l?a+e.slice(n+1):e.slice(n))+k,e=e.slice(0,n);break}}g&&!h&&(e=t(e,1/0));var E=d.length+e.length+k.length,C=E>1)+d+e+k+C.slice(E);break;default:e=C+d+e+k}return i(e)}return m=void 0===m?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),k.toString=function(){return e+""},k}return{format:c,formatPrefix:function(e,t){var n=c(((e=sn(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(function(e){return(e=pn(Math.abs(e)))?e[1]:NaN}(t)/3))),a=Math.pow(10,-r),i=bn[8+r/3];return function(e){return n(a*e)+i}}}}({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"})).format,hn.formatPrefix;var _n=new Date,wn=new Date;function xn(e,t,n,r){function a(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return a.floor=function(t){return e(t=new Date(+t)),t},a.ceil=function(n){return e(n=new Date(n-1)),t(n,1),e(n),n},a.round=function(e){var t=a(e),n=a.ceil(e);return e-t0))return o;do{o.push(l=new Date(+n)),t(n,i),e(n)}while(l=t)for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,r){if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}))},n&&(a.count=function(t,r){return _n.setTime(+t),wn.setTime(+r),e(_n),e(wn),Math.floor(n(_n,wn))},a.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?a.filter(r?function(t){return r(t)%e==0}:function(t){return a.count(0,t)%e==0}):a:null}),a}var kn=xn((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));kn.every=function(e){return isFinite(e=Math.floor(e))&&e>0?xn((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null};var Tn=kn,En=((kn.range,xn((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()}))).range,6e4),Cn=6048e5;function Sn(e){return xn((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*En)/Cn}))}var Mn=Sn(0),Pn=Sn(1),Nn=Sn(2),An=Sn(3),On=Sn(4),zn=Sn(5),Bn=Sn(6),Dn=(Mn.range,Pn.range,Nn.range,An.range,On.range,zn.range,Bn.range,xn((function(e){e.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*En)/864e5}),(function(e){return e.getDate()-1}))),Ln=Dn,Rn=((((Dn.range,xn((function(e){e.setTime(e-e.getMilliseconds()-1e3*e.getSeconds()-e.getMinutes()*En)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getHours()}))).range,xn((function(e){e.setTime(e-e.getMilliseconds()-1e3*e.getSeconds())}),(function(e,t){e.setTime(+e+t*En)}),(function(e,t){return(t-e)/En}),(function(e){return e.getMinutes()}))).range,xn((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+1e3*t)}),(function(e,t){return(t-e)/1e3}),(function(e){return e.getUTCSeconds()}))).range,xn((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e})));function Fn(e){return xn((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/Cn}))}Rn.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?xn((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Rn:null},Rn.range;var Un=Fn(0),In=Fn(1),$n=Fn(2),jn=Fn(3),Hn=Fn(4),Vn=Fn(5),Wn=Fn(6),Yn=(Un.range,In.range,$n.range,jn.range,Hn.range,Vn.range,Wn.range,xn((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/864e5}),(function(e){return e.getUTCDate()-1}))),qn=Yn,Qn=(Yn.range,xn((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()})));Qn.every=function(e){return isFinite(e=Math.floor(e))&&e>0?xn((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null};var Xn=Qn;function Kn(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Gn(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Zn(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}Qn.range;var Jn,er={"-":"",_:" ",0:"0"},tr=/^\s*\d+/,nr=/^%/,rr=/[\\^$*+?|[\]().{}]/g;function ar(e,t,n){var r=e<0?"-":"",a=(r?-e:e)+"",i=a.length;return r+(i68?1900:2e3),n+r[0].length):-1}function gr(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function mr(e,t,n){var r=tr.exec(t.slice(n,n+1));return r?(e.q=3*r[0]-3,n+r[0].length):-1}function vr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function yr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function br(e,t,n){var r=tr.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function _r(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function wr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function xr(e,t,n){var r=tr.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function kr(e,t,n){var r=tr.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Tr(e,t,n){var r=tr.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Er(e,t,n){var r=nr.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Cr(e,t,n){var r=tr.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Sr(e,t,n){var r=tr.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function Mr(e,t){return ar(e.getDate(),t,2)}function Pr(e,t){return ar(e.getHours(),t,2)}function Nr(e,t){return ar(e.getHours()%12||12,t,2)}function Ar(e,t){return ar(1+Ln.count(Tn(e),e),t,3)}function Or(e,t){return ar(e.getMilliseconds(),t,3)}function zr(e,t){return Or(e,t)+"000"}function Br(e,t){return ar(e.getMonth()+1,t,2)}function Dr(e,t){return ar(e.getMinutes(),t,2)}function Lr(e,t){return ar(e.getSeconds(),t,2)}function Rr(e){var t=e.getDay();return 0===t?7:t}function Fr(e,t){return ar(Mn.count(Tn(e)-1,e),t,2)}function Ur(e,t){var n=e.getDay();return e=n>=4||0===n?On(e):On.ceil(e),ar(On.count(Tn(e),e)+(4===Tn(e).getDay()),t,2)}function Ir(e){return e.getDay()}function $r(e,t){return ar(Pn.count(Tn(e)-1,e),t,2)}function jr(e,t){return ar(e.getFullYear()%100,t,2)}function Hr(e,t){return ar(e.getFullYear()%1e4,t,4)}function Vr(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+ar(t/60|0,"0",2)+ar(t%60,"0",2)}function Wr(e,t){return ar(e.getUTCDate(),t,2)}function Yr(e,t){return ar(e.getUTCHours(),t,2)}function qr(e,t){return ar(e.getUTCHours()%12||12,t,2)}function Qr(e,t){return ar(1+qn.count(Xn(e),e),t,3)}function Xr(e,t){return ar(e.getUTCMilliseconds(),t,3)}function Kr(e,t){return Xr(e,t)+"000"}function Gr(e,t){return ar(e.getUTCMonth()+1,t,2)}function Zr(e,t){return ar(e.getUTCMinutes(),t,2)}function Jr(e,t){return ar(e.getUTCSeconds(),t,2)}function ea(e){var t=e.getUTCDay();return 0===t?7:t}function ta(e,t){return ar(Un.count(Xn(e)-1,e),t,2)}function na(e,t){var n=e.getUTCDay();return e=n>=4||0===n?Hn(e):Hn.ceil(e),ar(Hn.count(Xn(e),e)+(4===Xn(e).getUTCDay()),t,2)}function ra(e){return e.getUTCDay()}function aa(e,t){return ar(In.count(Xn(e)-1,e),t,2)}function ia(e,t){return ar(e.getUTCFullYear()%100,t,2)}function la(e,t){return ar(e.getUTCFullYear()%1e4,t,4)}function oa(){return"+0000"}function ua(){return"%"}function ca(e){return+e}function sa(e){return Math.floor(+e/1e3)}function fa(){this._=null}function da(e){e.U=e.C=e.L=e.R=e.P=e.N=null}function ha(e,t){var n=t,r=t.R,a=n.U;a?a.L===n?a.L=r:a.R=r:e._=r,r.U=a,n.U=r,n.R=r.L,n.R&&(n.R.U=n),r.L=n}function pa(e,t){var n=t,r=t.L,a=n.U;a?a.L===n?a.L=r:a.R=r:e._=r,r.U=a,n.U=r,n.L=r.R,n.L&&(n.L.U=n),r.R=n}function ga(e){for(;e.L;)e=e.L;return e}(Jn=function(e){var t=e.dateTime,n=e.date,r=e.time,a=e.periods,i=e.days,l=e.shortDays,o=e.months,u=e.shortMonths,c=lr(a),s=or(a),f=lr(i),d=or(i),h=lr(l),p=or(l),g=lr(o),m=or(o),v=lr(u),y=or(u),b={a:function(e){return l[e.getDay()]},A:function(e){return i[e.getDay()]},b:function(e){return u[e.getMonth()]},B:function(e){return o[e.getMonth()]},c:null,d:Mr,e:Mr,f:zr,H:Pr,I:Nr,j:Ar,L:Or,m:Br,M:Dr,p:function(e){return a[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:ca,s:sa,S:Lr,u:Rr,U:Fr,V:Ur,w:Ir,W:$r,x:null,X:null,y:jr,Y:Hr,Z:Vr,"%":ua},_={a:function(e){return l[e.getUTCDay()]},A:function(e){return i[e.getUTCDay()]},b:function(e){return u[e.getUTCMonth()]},B:function(e){return o[e.getUTCMonth()]},c:null,d:Wr,e:Wr,f:Kr,H:Yr,I:qr,j:Qr,L:Xr,m:Gr,M:Zr,p:function(e){return a[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:ca,s:sa,S:Jr,u:ea,U:ta,V:na,w:ra,W:aa,x:null,X:null,y:ia,Y:la,Z:oa,"%":ua},w={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=p[r[0].toLowerCase()],n+r[0].length):-1},A:function(e,t,n){var r=f.exec(t.slice(n));return r?(e.w=d[r[0].toLowerCase()],n+r[0].length):-1},b:function(e,t,n){var r=v.exec(t.slice(n));return r?(e.m=y[r[0].toLowerCase()],n+r[0].length):-1},B:function(e,t,n){var r=g.exec(t.slice(n));return r?(e.m=m[r[0].toLowerCase()],n+r[0].length):-1},c:function(e,n,r){return T(e,t,n,r)},d:yr,e:yr,f:Tr,H:_r,I:_r,j:br,L:kr,m:vr,M:wr,p:function(e,t,n){var r=c.exec(t.slice(n));return r?(e.p=s[r[0].toLowerCase()],n+r[0].length):-1},q:mr,Q:Cr,s:Sr,S:xr,u:cr,U:sr,V:fr,w:ur,W:dr,x:function(e,t,r){return T(e,n,t,r)},X:function(e,t,n){return T(e,r,t,n)},y:pr,Y:hr,Z:gr,"%":Er};function x(e,t){return function(n){var r,a,i,l=[],o=-1,u=0,c=e.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in i||(i.w=1),"Z"in i?(r=(a=(r=Gn(Zn(i.y,0,1))).getUTCDay())>4||0===a?In.ceil(r):In(r),r=qn.offset(r,7*(i.V-1)),i.y=r.getUTCFullYear(),i.m=r.getUTCMonth(),i.d=r.getUTCDate()+(i.w+6)%7):(r=(a=(r=Kn(Zn(i.y,0,1))).getDay())>4||0===a?Pn.ceil(r):Pn(r),r=Ln.offset(r,7*(i.V-1)),i.y=r.getFullYear(),i.m=r.getMonth(),i.d=r.getDate()+(i.w+6)%7)}else("W"in i||"U"in i)&&("w"in i||(i.w="u"in i?i.u%7:"W"in i?1:0),a="Z"in i?Gn(Zn(i.y,0,1)).getUTCDay():Kn(Zn(i.y,0,1)).getDay(),i.m=0,i.d="W"in i?(i.w+6)%7+7*i.W-(a+5)%7:i.w+7*i.U-(a+6)%7);return"Z"in i?(i.H+=i.Z/100|0,i.M+=i.Z%100,Gn(i)):Kn(i)}}function T(e,t,n,r){for(var a,i,l=0,o=t.length,u=n.length;l=u)return-1;if(37===(a=t.charCodeAt(l++))){if(a=t.charAt(l++),!(i=w[a in er?t.charAt(l++):a])||(r=i(e,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}return b.x=x(n,b),b.X=x(r,b),b.c=x(t,b),_.x=x(n,_),_.X=x(r,_),_.c=x(t,_),{format:function(e){var t=x(e+="",b);return t.toString=function(){return e},t},parse:function(e){var t=k(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=x(e+="",_);return t.toString=function(){return e},t},utcParse:function(e){var t=k(e+="",!0);return t.toString=function(){return e},t}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]})).format,Jn.parse,Jn.utcFormat,Jn.utcParse,((xn((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()})).range,xn((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getUTCHours()}))).range,xn((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*En)}),(function(e,t){return(t-e)/En}),(function(e){return e.getUTCMinutes()}))).range,fa.prototype={constructor:fa,insert:function(e,t){var n,r,a;if(e){if(t.P=e,t.N=e.N,e.N&&(e.N.P=t),e.N=t,e.R){for(e=e.R;e.L;)e=e.L;e.L=t}else e.R=t;n=e}else this._?(e=ga(this._),t.P=null,t.N=e,e.P=e.L=t,n=e):(t.P=t.N=null,this._=t,n=null);for(t.L=t.R=null,t.U=n,t.C=!0,e=t;n&&n.C;)n===(r=n.U).L?(a=r.R)&&a.C?(n.C=a.C=!1,r.C=!0,e=r):(e===n.R&&(ha(this,n),n=(e=n).U),n.C=!1,r.C=!0,pa(this,r)):(a=r.L)&&a.C?(n.C=a.C=!1,r.C=!0,e=r):(e===n.L&&(pa(this,n),n=(e=n).U),n.C=!1,r.C=!0,ha(this,r)),n=e.U;this._.C=!1},remove:function(e){e.N&&(e.N.P=e.P),e.P&&(e.P.N=e.N),e.N=e.P=null;var t,n,r,a=e.U,i=e.L,l=e.R;if(n=i?l?ga(l):i:l,a?a.L===e?a.L=n:a.R=n:this._=n,i&&l?(r=n.C,n.C=e.C,n.L=i,i.U=n,n!==l?(a=n.U,n.U=e.U,e=n.R,a.L=e,n.R=l,l.U=n):(n.U=a,a=n,e=n.R)):(r=e.C,e=n),e&&(e.U=a),!r)if(e&&e.C)e.C=!1;else{do{if(e===this._)break;if(e===a.L){if((t=a.R).C&&(t.C=!1,a.C=!0,ha(this,a),t=a.R),t.L&&t.L.C||t.R&&t.R.C){t.R&&t.R.C||(t.L.C=!1,t.C=!0,pa(this,t),t=a.R),t.C=a.C,a.C=t.R.C=!1,ha(this,a),e=this._;break}}else if((t=a.L).C&&(t.C=!1,a.C=!0,pa(this,a),t=a.L),t.L&&t.L.C||t.R&&t.R.C){t.L&&t.L.C||(t.R.C=!1,t.C=!0,ha(this,t),t=a.L),t.C=a.C,a.C=t.L.C=!1,pa(this,a),e=this._;break}t.C=!0,e=a,a=a.U}while(!e.C);e&&(e.C=!1)}}};var ma=fa;function va(e,t,n,r){var a=[null,null],i=Ua.push(a)-1;return a.left=e,a.right=t,n&&ba(a,e,t,n),r&&ba(a,t,e,r),Ra[e.index].halfedges.push(i),Ra[t.index].halfedges.push(i),a}function ya(e,t,n){var r=[t,n];return r.left=e,r}function ba(e,t,n,r){e[0]||e[1]?e.left===n?e[1]=r:e[0]=r:(e[0]=r,e.left=t,e.right=n)}function _a(e,t,n,r,a){var i,l=e[0],o=e[1],u=l[0],c=l[1],s=0,f=1,d=o[0]-u,h=o[1]-c;if(i=t-u,d||!(i>0)){if(i/=d,d<0){if(i0){if(i>f)return;i>s&&(s=i)}if(i=r-u,d||!(i<0)){if(i/=d,d<0){if(i>f)return;i>s&&(s=i)}else if(d>0){if(i0)){if(i/=h,h<0){if(i0){if(i>f)return;i>s&&(s=i)}if(i=a-c,h||!(i<0)){if(i/=h,h<0){if(i>f)return;i>s&&(s=i)}else if(h>0){if(i0||f<1)||(s>0&&(e[0]=[u+s*d,c+s*h]),f<1&&(e[1]=[u+f*d,c+f*h]),!0)}}}}}function wa(e,t,n,r,a){var i=e[1];if(i)return!0;var l,o,u=e[0],c=e.left,s=e.right,f=c[0],d=c[1],h=s[0],p=s[1],g=(f+h)/2,m=(d+p)/2;if(p===d){if(g=r)return;if(f>h){if(u){if(u[1]>=a)return}else u=[g,n];i=[g,a]}else{if(u){if(u[1]1)if(f>h){if(u){if(u[1]>=a)return}else u=[(n-o)/l,n];i=[(a-o)/l,a]}else{if(u){if(u[1]=r)return}else u=[t,l*t+o];i=[r,l*r+o]}else{if(u){if(u[0]=-$a)){var h=u*u+c*c,p=s*s+f*f,g=(f*h-c*p)/d,m=(u*p-s*h)/d,v=Ca.pop()||new function(){da(this),this.x=this.y=this.arc=this.site=this.cy=null};v.arc=e,v.site=a,v.x=g+l,v.y=(v.cy=m+o)+Math.sqrt(g*g+m*m),e.circle=v;for(var y=null,b=Fa._;b;)if(v.yIa)o=o.L;else{if(!((a=i-Da(o,l))>Ia)){r>-Ia?(t=o.P,n=o):a>-Ia?(t=o,n=o.N):t=n=o;break}if(!o.R){t=o;break}o=o.R}!function(e){Ra[e.index]={site:e,halfedges:[]}}(e);var u=Na(e);if(La.insert(t,u),t||n){if(t===n)return Ma(t),n=Na(t.site),La.insert(u,n),u.edge=n.edge=va(t.site,u.site),Sa(t),void Sa(n);if(n){Ma(t),Ma(n);var c=t.site,s=c[0],f=c[1],d=e[0]-s,h=e[1]-f,p=n.site,g=p[0]-s,m=p[1]-f,v=2*(d*m-h*g),y=d*d+h*h,b=g*g+m*m,_=[(m*y-h*b)/v+s,(d*b-g*y)/v+f];ba(n.edge,c,p,_),u.edge=va(c,e,null,_),n.edge=va(e,p,null,_),Sa(t),Sa(n)}else u.edge=va(t.site,u.site)}}function Ba(e,t){var n=e.site,r=n[0],a=n[1],i=a-t;if(!i)return r;var l=e.P;if(!l)return-1/0;var o=(n=l.site)[0],u=n[1],c=u-t;if(!c)return o;var s=o-r,f=1/i-1/c,d=s/c;return f?(-d+Math.sqrt(d*d-2*f*(s*s/(-2*c)-u+c/2+a-i/2)))/f+r:(r+o)/2}function Da(e,t){var n=e.N;if(n)return Ba(n,t);var r=e.site;return r[1]===t?r[0]:1/0}var La,Ra,Fa,Ua,Ia=1e-6,$a=1e-12;function ja(e,t,n){return(e[0]-n[0])*(t[1]-e[1])-(e[0]-t[0])*(n[1]-e[1])}function Ha(e,t){return t[1]-e[1]||t[0]-e[0]}function Va(e,t){var n,r,a,i=e.sort(Ha).pop();for(Ua=[],Ra=new Array(e.length),La=new ma,Fa=new ma;;)if(a=Ea,i&&(!a||i[1]Ia||Math.abs(a[0][1]-a[1][1])>Ia)||delete Ua[i]}(l,o,u,c),function(e,t,n,r){var a,i,l,o,u,c,s,f,d,h,p,g,m=Ra.length,v=!0;for(a=0;aIa||Math.abs(g-d)>Ia)&&(u.splice(o,0,Ua.push(ya(l,h,Math.abs(p-e)Ia?[e,Math.abs(f-e)Ia?[Math.abs(d-r)Ia?[n,Math.abs(f-n)Ia?[Math.abs(d-t)=o)return null;var u=e-a.site[0],c=t-a.site[1],s=u*u+c*c;do{a=i.cells[r=l],l=null,a.halfedges.forEach((function(n){var r=i.edges[n],o=r.left;if(o!==a.site&&o||(o=r.right)){var u=e-o[0],c=t-o[1],f=u*u+c*c;f *").remove(),function(e){ee(".viz > *").remove(),ee(".viz").style("overflow-x","hidden").style("overflow-y","hidden").style("position","fixed").attr("height","100%");var t=ee(".viz").append("svg");t.attr("width",e.w).attr("height",e.h).attr("id","svg-viz").attr("preserveAspectRatio","xMidYMid meet").attr("viewBox","".concat(e.w/-2," ").concat(e.h/-2," ").concat(e.w," ").concat(.9*e.h));var n=Qa(e.value,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","vertical-gauge").attr("width",50).attr("height","100%").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",e.h/-2),t.append("rect").attr("class","top-arm").attr("width",ee(".vertical-gauge").attr("width")*(e.arm/100+1)).attr("height","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",e.h/-2),t.append("rect").attr("class","bottom-arm").attr("width",ee(".vertical-gauge").attr("width")*(e.arm/100+1)).attr("height","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("text").attr("class","max-label").attr("dx","-.35em").style("font-weight","bold").text(void 0===e.range_formatting||""===e.range_formatting?e.range[1]:qa.a.format(e.range_formatting,e.range[1])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2-ee(".max-label").node().getBBox().width).attr("y",e.h/-2+ee(".top-arm").node().getBBox().height),t.append("text").attr("class","min-label").attr("dx","-.35em").attr("dy",".7em").style("font-weight","bold").text(void 0===e.range_formatting||""===e.range_formatting?e.range[0]:qa.a.format(e.range_formatting,e.range[0])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2-ee(".min-label").node().getBBox().width).attr("y",ee(".bottom-arm").node().getBBox().y),t.append("rect").attr("class","vertical-fill").attr("width",ee(".vertical-gauge").attr("width")).attr("height","".concat(n*(ee(".vertical-gauge").node().getBBox().height-2*ee(".top-arm").node().getBBox().height))).style("fill",e.color).attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".vertical-fill").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("rect").attr("class","value-line").attr("stroke",e.spinner_background).attr("width","".concat(e.spinner/2,"px")).attr("height","".concat(e.spinner_weight/2,"px")).style("fill",e.spinner_background).attr("x",0+ee(".vertical-gauge").attr("width")/2-e.spinner/2).attr("y",ee(".vertical-fill").attr("y")),"value"!==e.value_label_type&&"both"!==e.value_label_type&&"dboth"!==e.value_label_type||t.append("text").attr("class","value-label").text(e.value_rendered).attr("dy",".7em").attr("dx","-".concat(e.value_label_padding/100,"em")).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label").node().getBBox().width).attr("y",ee(".vertical-fill").attr("y")),"label"!==e.value_label_type&&"both"!==e.value_label_type||t.append("text").attr("class","value-label-label").text(e.value_label).attr("dx","-".concat(e.value_label_padding/100,"em")).attr("dy",".5em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.45*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label-label").node().getBBox().width).attr("y",ee(".value-line").node().getBBox().y+("label"===e.value_label_type?0:ee(".value-label").node().getBBox().height)),"dim"!==e.value_label_type&&"dboth"!==e.value_label_type||t.append("text").attr("class","value-label-label").text(e.value_dimension).attr("dx","-".concat(e.value_label_padding/100,"em")).attr("dy",".5em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.45*e.value_label_font).concat(e.limiting_aspect)).attr("x",ee(".value-line").node().getBBox().x-ee(".value-label-label").node().getBBox().width).attr("y",ee(".value-line").node().getBBox().y+("dim"===e.value_label_type?0:ee(".value-label").node().getBBox().height)),"off"!==e.target_source){var r=Qa(e.target,0,1,e.range[0],e.range[1]);t.append("rect").attr("class","target-fill").attr("width",ee(".vertical-gauge").attr("width")).attr("height","".concat(r*(ee(".vertical-gauge").node().getBBox().height-2*ee(".top-arm").node().getBBox().height))).style("fill","none").attr("x",0-ee(".vertical-gauge").node().getBBox().width/2).attr("y",ee(".vertical-gauge").node().getBBox().y+ee(".vertical-gauge").node().getBBox().height-ee(".target-fill").node().getBBox().height-ee(".bottom-arm").node().getBBox().height),t.append("line").attr("class","target-line").attr("stroke-width","4").attr("fill","none").style("stroke",e.target_background).attr("stroke-dasharray","5").attr("x1",0-.5*ee(".vertical-gauge").attr("width")).attr("y1",ee(".target-fill").attr("y")).attr("x2",0+.7*ee(".vertical-gauge").attr("width")).attr("y2",ee(".target-fill").attr("y")),"value"!==e.target_label_type&&"both"!==e.target_label_type&&"dboth"!==e.target_label_type||t.append("text").attr("class","target-label").text(e.target_rendered).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-fill").attr("y")),"label"!==e.target_label_type&&"both"!==e.target_label_type||t.append("text").attr("class","target-label-label").text(e.target_label).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-line").node().getBBox().y+("label"===e.target_label_type?0:ee(".target-label").node().getBBox().height)),"dim"!==e.target_label_type&&"dboth"!==e.target_label_type||t.append("text").attr("class","target-label-label").text(e.target_dimension).attr("dy",".7em").style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(.75*e.target_label_font).concat(e.limiting_aspect)).attr("x",0+3*ee(".vertical-gauge").attr("width")/4).attr("y",ee(".target-line").node().getBBox().y+("dim"===e.target_label_type?0:ee(".target-label").node().getBBox().height))}ee(".value-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})})),ee(".value-label-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})}))}(e)}),[e]),a.a.createElement("div",{className:"viz"})};function Ka(e,t,n,r,a){return(n-t)*(e-r)/(a-r)+t}var Ga,Za=function(e){return Object(r.useEffect)((function(){ee(".viz > *").remove(),function(e){ee(".viz > *").remove(),ee(".viz").style("background-color","#FFF").style("overflow-x","hidden").style("overflow-y","hidden").style("position","fixed").attr("height","100%");var t=ee(".viz").append("svg");t.attr("width",e.w).attr("height",e.h).attr("id","svg-viz").attr("preserveAspectRatio","xMidYMid meet").attr("viewBox","".concat(e.w/-2," ").concat(e.h/-2," ").concat(e.w," ").concat(.9*e.h));var n,r=Ka(e.value,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","horizontal-gauge").attr("width","100%").attr("height",50).style("fill",e.gauge_background).attr("y",0-ee(".horizontal-gauge").node().getBBox().height).attr("x",e.w/-2),t.append("rect").attr("class","left-arm").attr("height",ee(".horizontal-gauge").attr("height")*(e.arm/100+1)).attr("width","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("y",ee(".horizontal-gauge").node().getBBox().y-(ee(".left-arm").node().getBBox().height-ee(".horizontal-gauge").node().getBBox().height)).attr("x",e.w/-2),t.append("rect").attr("class","right-arm").attr("height",ee(".horizontal-gauge").attr("height")*(e.arm/100+1)).attr("width","".concat(e.arm_weight/3,"px")).attr("z-index","5").style("fill",e.gauge_background).attr("x",e.w/2-ee(".right-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y-(ee(".right-arm").node().getBBox().height-ee(".horizontal-gauge").node().getBBox().height)),t.append("text").attr("class","max-label").style("font-weight","bold").attr("dy",".7em").text(void 0===e.range_formatting||""===e.range_formatting?e.range[1]:qa.a.format(e.range_formatting,e.range[1])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0+ee(".horizontal-gauge").node().getBBox().width/2-ee(".left-arm").node().getBBox().width-ee(".max-label").node().getBBox().width).attr("y",ee(".right-arm").node().getBBox().y-ee(".max-label").node().getBBox().height),t.append("text").attr("class","min-label").style("font-weight","bold").attr("dy",".7em").text(void 0===e.range_formatting||""===e.range_formatting?e.range[0]:qa.a.format(e.range_formatting,e.range[0])).style("font-family","Arial, Helvetica, sans-serif").style("fill",e.range_color).style("font-size","".concat(e.label_font).concat(e.limiting_aspect)).attr("x",0-ee(".horizontal-gauge").node().getBBox().width/2+ee(".left-arm").node().getBBox().width).attr("y",ee(".left-arm").node().getBBox().y-ee(".min-label").node().getBBox().height),t.append("rect").attr("class","horizontal-fill").attr("height",ee(".horizontal-gauge").attr("height")).attr("width","".concat(r*(ee(".horizontal-gauge").node().getBBox().width-2*ee(".left-arm").node().getBBox().width))).style("fill",e.color).attr("x",e.w/-2+ee(".left-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y),t.append("rect").attr("class","value-line").attr("stroke",e.spinner_background).attr("height",ee(".horizontal-gauge").attr("height")*(e.spinner/400+1)).attr("width","".concat(e.spinner_weight/2,"px")).style("fill",e.spinner_background).attr("y",ee(".horizontal-fill").attr("y")).attr("x",ee(".horizontal-fill").node().getBBox().x+ee(".horizontal-fill").node().getBBox().width-ee(".value-line").node().getBBox().width),"value"===e.value_label_type||"both"===e.value_label_type||"dboth"===e.value_label_type){var a=t.append("text").attr("class","value-label").text(e.value_rendered).attr("dy","".concat(e.value_label_padding/3)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(e.value_label_font).concat(e.limiting_aspect));n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+3*ee(".value-label").node().getBBox().height/4)}("label"!==e.value_label_type&&"both"!==e.value_label_type||(a=t.append("text").attr("class","value-label-label").text(e.value_label).attr("dy","".concat(e.value_label_padding/2)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(3*e.value_label_font/4).concat(e.limiting_aspect)),n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+("label"===e.value_label_type?ee(".value-line").node().getBBox().height/3:1.3*ee(".value-label").node().getBBox().height))),"dim"===e.value_label_type||"dboth"===e.value_label_type)&&(a=t.append("text").attr("class","value-label-label").text(e.value_dimension).attr("dy","".concat(e.value_label_padding)).style("font-family","Arial, Helvetica, sans-serif").style("font-size","".concat(3*e.value_label_font/4).concat(e.limiting_aspect)),n=(n=ee(".value-line").node().getBBox().x+ee(".value-line").node().getBBox().width-ee(".value-label-label").node().getBBox().width)<-.5*e.w?-.5*e.w:n,a.attr("x",n).attr("y",ee(".horizontal-fill").node().getBBox().y+ee(".value-line").node().getBBox().height+("dim"===e.value_label_type?ee(".value-line").node().getBBox().height/3:1.3*ee(".value-label").node().getBBox().height)));if("off"!==e.target_source){var i=Ka(e.target,0,1,e.range[0],e.range[1]);if(t.append("rect").attr("class","target-fill").attr("height",ee(".horizontal-gauge").attr("height")).attr("width","".concat(i*(ee(".horizontal-gauge").node().getBBox().width-2*ee(".left-arm").node().getBBox().width))).style("fill","none").attr("x",e.w/-2+ee(".left-arm").node().getBBox().width).attr("y",ee(".horizontal-gauge").node().getBBox().y),"none"!==e.target_label_type){if(t.append("line").attr("class","target-line").attr("stroke-width","4").attr("fill","none").style("stroke",e.target_background).attr("stroke-dasharray","5").attr("x1",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y1",ee(".target-fill").node().getBBox().y).attr("x2",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y2",ee(".target-fill").node().getBBox().y+ee(".target-fill").node().getBBox().height),"value"===e.target_label_type)var l="".concat(e.target_rendered);else"label"===e.target_label_type?l="".concat(e.target_label):"both"===e.target_label_type?l="".concat(e.target_rendered," ").concat(e.target_label):"dim"===e.target_label_type?l="".concat(e.target_dimension):"dboth"===e.target_label_type&&(l="".concat(e.target_rendered," ").concat(e.target_dimension));t.append("text").attr("class","target-label").text(l).style("font-size","".concat(e.target_label_font).concat(e.limiting_aspect)).style("font-family","Arial, Helvetica, sans-serif").attr("x",ee(".target-fill").node().getBBox().x+ee(".target-fill").node().getBBox().width).attr("y",ee(".target-fill").node().getBBox().y-ee(".target-label").node().getBBox().height/2)}}ee(".value-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})})),ee(".value-label-label").on("click",(function(t,n){LookerCharts.Utils.openDrillMenu({links:e.value_links,event:event})}))}(e)}),[e]),a.a.createElement("div",{className:"viz"})};function Ja(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ei={id:"gauge",label:"Gauge Visualization",options:{bar_arm_length:{type:"number",label:"Arm Length",default:9,section:"Plot",display:"range",min:0,max:50,step:.5,order:200,display_size:"half"},bar_arm_weight:{type:"number",label:"Thickness",default:48,section:"Plot",display:"range",min:0,max:100,order:300,display_size:"half"},bar_spinner_length:{type:"number",label:"Pointer Length",default:121,section:"Plot",display:"range",min:0,max:200,order:400,display_size:"half"},bar_spinner_weight:(Ga={type:"number",label:"Thickness",default:25,section:"Plot",display:"range",min:0,max:100},Ja(Ga,"default",25),Ja(Ga,"order",500),Ja(Ga,"display_size","half"),Ga),bar_style:{type:"string",label:"Gauge Type",display:"select",section:"Plot",values:[{Vertical:"vertical"},{Horizontal:"horizontal"}],default:"vertical",order:0},bar_range_min:{type:"number",label:"Range Min Override",section:"Plot",order:30,default:0,display_size:"half"},bar_range_max:{type:"number",label:"Range Max Override",section:"Plot",order:31,default:100.701,display_size:"half"},bar_value_label_type:{type:"string",label:"Value Label Type",display:"select",section:"Value",values:[{"Value and Measure Label":"both"},{"Value and Dimension":"dboth"},{"Only Value":"value"},{"Only Label":"label"},{"Only Dimension":"dim"},{None:"none"}],default:"both",order:40},bar_value_label_font:{type:"number",label:"Value Label Font Size",section:"Value",default:8,order:50},bar_value_formatting:{type:"string",label:"Value Formatting Override",section:"Value",order:51},bar_value_label_override:{type:"string",label:"Value Label Override",section:"Value",order:60},bar_value_label_padding:{type:"number",label:"Value Label Padding",default:45,section:"Value",display:"range",min:0,max:120,order:70},bar_target_source:{type:"string",label:"Target Source",display:"select",section:"Target",values:[{"First Measure":"first"},{"Second Measure":"second"},{Override:"override"},{"No Target":"off"}],default:"off",order:80},bar_target_label_type:{type:"string",label:"Target Label Type",display:"select",section:"Target",values:[{"Value and Label":"both"},{"Only Value":"value"},{"Only Label":"label"},{"Value and Dimension":"dboth"},{"Only Dimension":"dim"},{"No Label":"nolabel"}],default:"none",order:90},bar_target_label_font:{type:"number",label:"Target Label Font Size",section:"Target",default:3,order:100},bar_target_label_override:{type:"string",label:"Target Label Override",section:"Target",order:120},bar_target_value_override:{type:"string",label:"Target Value Override",section:"Target",order:110},bar_target_value_format:{type:"string",label:"Target Value Formatting",section:"Target",order:120},bar_label_font_size:{type:"number",label:"Range Label Font Size",section:"Plot",default:3,order:140},bar_range_formatting:{type:"string",label:"Range Label Value Formatting",section:"Plot",order:150},bar_fill_color:{type:"string",label:"Gauge Fill Color",section:"Style",display:"color",default:"#0092E5",order:10},bar_background_color:{type:"string",label:"Background Color",default:"#CECECE",section:"Style",display:"color",order:20},bar_spinner_color:{type:"string",label:"Pointer Color",default:"#282828",section:"Style",display:"color",order:30},bar_range_color:{type:"string",label:"Range Label Color",default:"#282828",section:"Style",display:"color",order:40}}},ti=n(11),ni=n.n(ti);function ri(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ai(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}looker.plugins.visualizations.add(function(e){for(var t=1;t1||r.fields.measure_like.length>2)this.addError({title:"Invalid Input.",message:"This chart accepts up to 1 dimension and 2 measures."});else{var c;if(c=function(e,t,n,r){var a,i,l,o,u,c,s,f,d,h,p,g,m=t.fields.dimension_like,v=t.fields.measure_like;return m.length>0&&(a=m[0].name,e[0][a]),"dim"!==n.bar_value_label_type&&"dboth"!==n.bar_value_label_type||0===m.length&&r&&r.addError({title:"Invalid Input.",message:"Add a dimension or modify label type."}),"dim"!==n.bar_target_label_type&&"dboth"!==n.bar_target_label_type||0===m.length&&r&&r.addError({title:"Invalid Input.",message:"Add a dimension or modify label type."}),i=v[0].name,l=e[0][i],o=void 0===v[0].label_short?v[0].label:v[0].label_short,u=void 0===l.rendered?l.value:l.rendered,"second"===n.bar_target_source?(v.length<2&&r&&r.addError({title:"Invalid Input.",message:"Add a second measure or modify label type."}),c=v[1].name,f=(s=e[0][c]).value,d=void 0===v[1].label_short?v[1].label:v[1].label_short,h=void 0===s.rendered?s.value:s.rendered,p=void 0===n.bar_target_value_format||""===n.bar_target_value_format?h:qa.a.format(n.bar_target_value_format,f),m.length>0&&(g=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[0][a].value:n.bar_target_label_override)):"first"===n.bar_target_source?(e.length<2&&r&&r.addError({title:"Invalid Input.",message:"No value to target. Add a second row or modify label type."}),f=(s=e[1][i]).value,h=void 0===s.rendered||""===s.rendered?f:s.rendered,d=o,p=void 0===n.bar_target_value_format||""===n.bar_target_value_format?h:qa.a.format(n.bar_target_value_format,f),m.length>0&&(g=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[1][a].value:n.bar_target_label_override)):"override"===n.bar_target_source&&((void 0===n.bar_target_value_override||""===n.bar_target_value_override&&r)&&r.addError({title:"Invalid Input.",message:"No target override. Add an override value or modify label type."}),h=f=parseFloat(n.bar_target_value_override),d=n.bar_target_label_override,p=void 0===n.bar_target_value_format||""===n.bar_target_value_format?h:qa.a.format(n.bar_target_value_format,f),m.length>0&&(g=void 0===n.bar_target_label_override||""===n.bar_target_label_override?e[0][a].value:n.bar_target_label_override)),{value:l.value,value_links:l.links,value_label:void 0===n.bar_value_label_override||""===n.bar_value_label_override?o:n.bar_value_label_override,value_rendered:void 0===n.bar_value_formatting||""===n.bar_value_formatting?u:qa.a.format(n.bar_value_formatting,l.value),value_dimension:m.length>0?void 0===n.bar_value_label_override||""===n.bar_value_label_override?e[0][a].value:n.bar_value_label_override:null,value_formatting:n.bar_value_formatting,target:f,target_rendered:p,target_label:void 0===n.bar_target_label_override||""===n.bar_target_label_override?d:n.bar_target_label_override,target_dimension:g}}(e,r,n,this),!n.bar_range_max){var s=Math.max(Math.ceil(c.value),c.target?Math.ceil(c.target):0),f=(s+"").length,d=Math.pow(10,f-1),h=Math.ceil(s/d)*d;n.bar_range_max=h}this.barDefaults=function(e,t,n,r,a){var i;return{w:e,h:t,limiting_aspect:er.bar_range_max?r.bar_range_max:a.value,value_rendered:a.value_rendered,target:a.target>r.bar_range_max?r.bar_range_max:a.target,value_label:a.value_label,target_label:a.target_label,value_dimension:a.value_dimension,target_dimension:a.target_dimension,target_rendered:a.target_rendered,value_links:a.value_links,label_font:r.bar_label_font_size,range_formatting:null!==(i=r.bar_range_formatting)&&void 0!==i?i:a.value_formatting,range_x:r.bar_range_x,range_y:r.bar_range_y,gauge_fill_type:r.bar_gauge_fill_type,fill_colors:r.bar_fill_colors,range_color:r.bar_range_color,spinner:r.bar_spinner_length,spinner_weight:r.bar_spinner_weight,spinner_background:r.bar_spinner_color,arm:r.bar_arm_length,arm_weight:r.bar_arm_weight,target_length:r.bar_target_length,target_gap:r.bar_target_gap,target_weight:r.bar_target_weight,target_background:"#282828",target_source:r.bar_target_source,value_label_type:r.bar_value_label_type,value_label_font:r.bar_value_label_font,value_label_padding:r.bar_value_label_padding,target_label_type:r.bar_target_label_type,target_label_font:r.bar_target_label_font,target_label_padding:r.bar_target_label_padding,wrap_width:100}}(o,u,0,n,c),"vertical"===n.bar_style?this.chart=ni.a.render(a.a.createElement(Xa,this.barDefaults),this.container):"horizontal"===n.bar_style&&(this.chart=ni.a.render(a.a.createElement(Za,this.barDefaults),this.container)),l()}}}))}])})); diff --git a/bin/bootstrap b/bin/bootstrap index d3fa9c4..4232b3a 100755 --- a/bin/bootstrap +++ b/bin/bootstrap @@ -6,18 +6,22 @@ GIT_ROOT_DIR=$(git rev-parse --show-toplevel) # Initialize and install pre-commit. function looker::install_pre_commit() { - pushd "$GIT_ROOT_DIR" &> /dev/null - if command -v pre-commit &> /dev/null; then - python3 -m pip install --upgrade pip - python3 -m pip install pre-commit + pushd "$GIT_ROOT_DIR" &>/dev/null + if ! command -v pre-commit &>/dev/null; then + if command -v apt &>/dev/null; then + sudo apt install -y pre-commit + else + python3 -m pip install --upgrade pip + python3 -m pip install pre-commit + fi fi pre-commit install - popd &> /dev/null + popd &>/dev/null } # Installs yarn if it is not already installed. function looker::install_yarn() { - if command -v yarn &> /dev/null; then + if ! command -v yarn &>/dev/null; then npm install -g yarn fi } diff --git a/bin/build b/bin/build index a360df3..a165ac6 100755 --- a/bin/build +++ b/bin/build @@ -6,7 +6,7 @@ GIT_ROOT_DIR=$(git rev-parse --show-toplevel) # Installs yarn if it is not already installed. function looker::install_yarn() { - if command -v yarn &> /dev/null; then + if ! command -v yarn &>/dev/null; then npm install -g yarn fi } @@ -14,18 +14,18 @@ function looker::install_yarn() { # Configures the project if the user has not already done so. function looker::configure() { looker::install_yarn - pushd "$GIT_ROOT_DIR" &> /dev/null + pushd "$GIT_ROOT_DIR" &>/dev/null if [[ ! -d "$GIT_ROOT_DIR/node_modules" ]]; then yarn fi - popd &> /dev/null + popd &>/dev/null } # Builds the target JS file from sources configuring if necessary. function looker::build() { - pushd "$GIT_ROOT_DIR" &> /dev/null - env NODE_OPTIONS="--openssl-legacy-provider" yarn build - popd &> /dev/null + pushd "$GIT_ROOT_DIR" &>/dev/null + env NODE_OPTIONS="--openssl-legacy-provider" yarn run build + popd &>/dev/null } # Entry-point. diff --git a/bin/test b/bin/test index c47a3e0..bde3b6c 100755 --- a/bin/test +++ b/bin/test @@ -6,7 +6,7 @@ GIT_ROOT_DIR=$(git rev-parse --show-toplevel) # Installs yarn if it is not already installed. function looker::install_yarn() { - if command -v yarn &> /dev/null; then + if ! command -v yarn &>/dev/null; then npm install -g yarn fi } @@ -14,18 +14,18 @@ function looker::install_yarn() { # Configures the project if the user has not already done so. function looker::configure() { looker::install_yarn - pushd "$GIT_ROOT_DIR" &> /dev/null + pushd "$GIT_ROOT_DIR" &>/dev/null if [[ ! -d "$GIT_ROOT_DIR/node_modules" ]]; then yarn fi - popd &> /dev/null + popd &>/dev/null } # Runs all the unit tests. function looker::test() { - pushd "$GIT_ROOT_DIR" &> /dev/null + pushd "$GIT_ROOT_DIR" &>/dev/null env NODE_OPTIONS="--openssl-legacy-provider" yarn test - popd &> /dev/null + popd &>/dev/null } # Entry-point. diff --git a/package.json b/package.json index f8d5414..06e6ce1 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "description": "", "main": "", "scripts": { - "build": "webpack --config webpack.config.js", + "prepare": "bin/bootstrap", + "build": "env NODE_OPTIONS='--openssl-legacy-provider' webpack --config webpack.config.js", "start": "webpack-dev-server --open", - "watch": "webpack --config webpack.config.js --watch --progress", - "format": "prettier --ignore-path .gitignore --write '**/*.js'", + "watch": "env NODE_OPTIONS='--openssl-legacy-provider' webpack --config webpack.config.js --watch --progress", + "format": "prettier --ignore-path .gitignore --write src", "test": "jest" }, "author": "Apps Team ", diff --git a/src/helpers.js b/src/helpers.js index 49050f5..848fd78 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,11 +1,12 @@ import SSF from 'ssf'; export function processData(data, queryResponse, config, viz) { - let dims, dimID, dimData; - let meas, mesID, mesData, mesLabel, mesRendered; + const dims = queryResponse['fields']['dimension_like']; + const meas = queryResponse['fields']['measure_like']; + + let dimID, dimData; + let mesID, mesData, mesLabel, mesRendered; let tarID, tarData, tarValue, tarLabel, tarBase, tarRendered, tarDim; - dims = queryResponse['fields']['dimension_like']; - meas = queryResponse['fields']['measure_like']; if (dims.length > 0) { dimID = dims[0]['name']; @@ -56,8 +57,7 @@ export function processData(data, queryResponse, config, viz) { meas[1]['label_short'] === undefined ? meas[1]['label'] : meas[1]['label_short']; - tarBase = - tarData.rendered === undefined ? tarData.value : tarData.rendered; + tarBase = tarData.rendered === undefined ? tarData.value : tarData.rendered; tarRendered = config.bar_target_value_format === undefined || config.bar_target_value_format === '' @@ -99,8 +99,7 @@ export function processData(data, queryResponse, config, viz) { } else if (config.bar_target_source === 'override') { if ( config.bar_target_value_override === undefined || - config.bar_target_value_override === '' && - viz + (config.bar_target_value_override === '' && viz) ) { viz.addError({ title: 'Invalid Input.', @@ -153,7 +152,7 @@ export function processData(data, queryResponse, config, viz) { config.bar_target_label_override === '' ? tarLabel : config.bar_target_label_override, - target_dimension: tarDim + target_dimension: tarDim, }; return chunk; } @@ -174,9 +173,7 @@ export function getBarDefaults(width, height, margin, config, chunk) { chunk.value > config.bar_range_max ? config.bar_range_max : chunk.value, value_rendered: chunk.value_rendered, target: - chunk.target > config.bar_range_max - ? config.bar_range_max - : chunk.target, + chunk.target > config.bar_range_max ? config.bar_range_max : chunk.target, value_label: chunk.value_label, target_label: chunk.target_label, value_dimension: chunk.value_dimension, diff --git a/src/tests/viz-gauge-test-data.js b/src/tests/viz-gauge-test-data.js deleted file mode 100644 index 329db1c..0000000 --- a/src/tests/viz-gauge-test-data.js +++ /dev/null @@ -1,809 +0,0 @@ -export const testData = [ - { - "flights.destination": { - "value": "ATL", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ATL", - "type_label_prefix": "Drill into", - "type_label_value": "ATL" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ATL", - "type_label_prefix": "Drill into", - "type_label_value": "ATL" - } - ] - }, - "flights.flight_count": { - "value": 1901518, - "rendered": "1,901,518", - "links": [ - { - "label": "Show All 1,901,518", - "label_prefix": "Show All", - "label_value": "1,901,518", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ATL&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - }, - { - "flights.destination": { - "value": "ORD", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ORD", - "type_label_prefix": "Drill into", - "type_label_value": "ORD" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ORD", - "type_label_prefix": "Drill into", - "type_label_value": "ORD" - } - ] - }, - "flights.flight_count": { - "value": 1895066, - "rendered": "1,895,066", - "links": [ - { - "label": "Show All 1,895,066", - "label_prefix": "Show All", - "label_value": "1,895,066", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ORD&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - }, - { - "flights.destination": { - "value": "DFW", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into DFW", - "type_label_prefix": "Drill into", - "type_label_value": "DFW" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into DFW", - "type_label_prefix": "Drill into", - "type_label_value": "DFW" - } - ] - }, - "flights.flight_count": { - "value": 1776593, - "rendered": "1,776,593", - "links": [ - { - "label": "Show All 1,776,593", - "label_prefix": "Show All", - "label_value": "1,776,593", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=DFW&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - } -] - -export const testQueryResponse = { - "aggregate_table_used_info": null, - "data": [ - { - "flights.destination": { - "value": "ATL", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ATL", - "type_label_prefix": "Drill into", - "type_label_value": "ATL" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ATL", - "type_label_prefix": "Drill into", - "type_label_value": "ATL" - } - ] - }, - "flights.flight_count": { - "value": 1901518, - "rendered": "1,901,518", - "links": [ - { - "label": "Show All 1,901,518", - "label_prefix": "Show All", - "label_value": "1,901,518", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ATL&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - }, - { - "flights.destination": { - "value": "ORD", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ORD", - "type_label_prefix": "Drill into", - "type_label_value": "ORD" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into ORD", - "type_label_prefix": "Drill into", - "type_label_value": "ORD" - } - ] - }, - "flights.flight_count": { - "value": 1895066, - "rendered": "1,895,066", - "links": [ - { - "label": "Show All 1,895,066", - "label_prefix": "Show All", - "label_value": "1,895,066", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ORD&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - }, - { - "flights.destination": { - "value": "DFW", - "links": [ - { - "label": "by Carrier", - "label_prefix": "by", - "label_value": "Carrier", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into DFW", - "type_label_prefix": "Drill into", - "type_label_value": "DFW" - }, - { - "label": "by Origin", - "label_prefix": "by", - "label_value": "Origin", - "url": "/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles", - "type": "drill", - "type_label": "Drill into DFW", - "type_label_prefix": "Drill into", - "type_label_value": "DFW" - } - ] - }, - "flights.flight_count": { - "value": 1776593, - "rendered": "1,776,593", - "links": [ - { - "label": "Show All 1,776,593", - "label_prefix": "Show All", - "label_value": "1,776,593", - "url": "/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=DFW&query_timezone=America%2FLos_Angeles&limit=500", - "type": "measure_default" - } - ] - } - } - ], - "drill_menu_build_time": 0.176502, - "expired": false, - "fields": { - "measures": [ - { - "align": "right", - "can_filter": true, - "category": "measure", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": true, - "label": "Flights Flight Count", - "label_from_parameter": null, - "label_short": "Flight Count", - "map_layer": null, - "name": "flights.flight_count", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "count", - "user_attribute_filter_types": [ - "number", - "advanced_filter_number" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Flight Count", - "measure": true, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.flight_count", - "suggest_explore": "flights", - "suggestable": false, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=220", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": null, - "sql_case": null, - "filters": null, - "times_used": 0, - "sorted": { - "sort_index": 0, - "desc": true, - "pivot_index": 0 - } - } - ], - "dimensions": [ - { - "align": "left", - "can_filter": true, - "category": "dimension", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": false, - "label": "Flights Destination", - "label_from_parameter": null, - "label_short": "Destination", - "map_layer": null, - "name": "flights.destination", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "string", - "user_attribute_filter_types": [ - "string", - "advanced_filter_string" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Destination", - "measure": false, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.destination", - "suggest_explore": "flights", - "suggestable": true, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=80", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": "${TABLE}.destination ", - "sql_case": null, - "filters": null, - "times_used": 0 - } - ], - "table_calculations": [], - "pivots": [], - "measure_like": [ - { - "align": "right", - "can_filter": true, - "category": "measure", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": true, - "label": "Flights Flight Count", - "label_from_parameter": null, - "label_short": "Flight Count", - "map_layer": null, - "name": "flights.flight_count", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "count", - "user_attribute_filter_types": [ - "number", - "advanced_filter_number" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Flight Count", - "measure": true, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.flight_count", - "suggest_explore": "flights", - "suggestable": false, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=220", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": null, - "sql_case": null, - "filters": null, - "times_used": 0, - "sorted": { - "sort_index": 0, - "desc": true, - "pivot_index": 0 - } - } - ], - "dimension_like": [ - { - "align": "left", - "can_filter": true, - "category": "dimension", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": false, - "label": "Flights Destination", - "label_from_parameter": null, - "label_short": "Destination", - "map_layer": null, - "name": "flights.destination", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "string", - "user_attribute_filter_types": [ - "string", - "advanced_filter_string" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Destination", - "measure": false, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.destination", - "suggest_explore": "flights", - "suggestable": true, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=80", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": "${TABLE}.destination ", - "sql_case": null, - "filters": null, - "times_used": 0 - } - ] - }, - "fill_fields": [], - "forecast_result": null, - "has_row_totals": false, - "has_totals": false, - "id": "177dcc6a712f8df8ff2cf5bdbabc7184:{\"hidden_points_if_no\":[],\"hidden_fields\":[]}", - "null_sort_treatment": "low", - "number_format": "1,234.56", - "ran_at": "2023-10-02T15:19:32+00:00", - "sql": "SELECT\n destination AS flights_destination,\n COUNT(*) AS flights_flight_count\nFROM\n faa.flights AS flights\nWHERE ((TIMESTAMP_DIFF(flights.arr_time , flights.dep_time , MINUTE)) > 0 and (TIMESTAMP_DIFF(flights.arr_time , flights.dep_time , MINUTE)) < 2000 ) AND carrier IS NOT NULL\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT 500", - "sql_explain": null, - "supports_pivot_in_db": true, - "timezone": "America/Los_Angeles", - "is_local": false, - "table_calcs_complete": true, - "tracked_attributes": { - "result.data.length": 298, - "result.drill_menu_build_time": 0.176502, - "result.from_cache": false, - "result.sql.length": 334, - "result.supports_pivot_in_db": true - }, - "sorts": [] -} - -export const testConfig = { - "bar_arm_length": 25, - "bar_arm_weight": 50, - "bar_spinner_length": 100, - "bar_spinner_weight": 50, - "bar_style": "horizontal", - "bar_range_min": 10000, - "bar_range_max": 1500000, - "bar_value_label_type": "both", - "bar_value_label_font": 8, - "bar_value_formatting": "#.00", - "bar_value_label_padding": 60, - "bar_target_source": "second", - "bar_target_label_type": "both", - "bar_target_label_font": 3, - "bar_target_label_override": "", - "bar_target_value_format": "#.00", - "bar_label_font_size": 3, - "bar_fill_color": "#4285F4", - "bar_background_color": "#DADCE0", - "bar_spinner_color": "#5F6368", - "bar_range_color": "#5F6368", - "type": "marketplace_viz_bar_gauge::bar_gauge-marketplace", - "query_fields": { - "measures": [ - { - "align": "right", - "can_filter": true, - "category": "measure", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": true, - "label": "Flights Flight Count", - "label_from_parameter": null, - "label_short": "Flight Count", - "map_layer": null, - "name": "flights.flight_count", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "count", - "user_attribute_filter_types": [ - "number", - "advanced_filter_number" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Flight Count", - "measure": true, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.flight_count", - "suggest_explore": "flights", - "suggestable": false, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=220", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": null, - "sql_case": null, - "filters": null, - "times_used": 0, - "sorted": { - "sort_index": 0, - "desc": true, - "pivot_index": 0 - } - }, - { - "align": "right", - "can_filter": true, - "category": "measure", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": true, - "label": "Flights Count Delayed Flights", - "label_from_parameter": null, - "label_short": "Count Delayed Flights", - "map_layer": null, - "name": "flights.count_delayed_flights", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "count", - "user_attribute_filter_types": [ - "number", - "advanced_filter_number" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Count Delayed Flights", - "measure": true, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.count_delayed_flights", - "suggest_explore": "flights", - "suggestable": false, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=107", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": null, - "sql_case": null, - "filters": [ - { - "field": "flights.is_flight_delayed", - "condition": "Yes" - } - ], - "times_used": 0 - } - ], - "dimensions": [ - { - "align": "left", - "can_filter": true, - "category": "dimension", - "default_filter_value": null, - "description": "", - "enumerations": null, - "field_group_label": null, - "fill_style": null, - "fiscal_month_offset": 0, - "has_allowed_values": false, - "hidden": false, - "is_filter": false, - "is_numeric": false, - "label": "Flights Destination", - "label_from_parameter": null, - "label_short": "Destination", - "map_layer": null, - "name": "flights.destination", - "strict_value_format": false, - "requires_refresh_on_sort": false, - "sortable": true, - "suggestions": null, - "tags": [], - "type": "string", - "user_attribute_filter_types": [ - "string", - "advanced_filter_string" - ], - "value_format": null, - "view": "flights", - "view_label": "Flights", - "dynamic": false, - "week_start_day": "monday", - "original_view": "flights", - "dimension_group": null, - "error": null, - "field_group_variant": "Destination", - "measure": false, - "parameter": false, - "primary_key": false, - "project_name": "faa", - "scope": "flights", - "suggest_dimension": "flights.destination", - "suggest_explore": "flights", - "suggestable": true, - "is_fiscal": false, - "is_timeframe": false, - "can_time_filter": false, - "time_interval": null, - "lookml_link": "/projects/faa/files/flights.view.lkml?line=80", - "permanent": null, - "source_file": "flights.view.lkml", - "source_file_path": "faa/flights.view.lkml", - "sql": "${TABLE}.destination ", - "sql_case": null, - "filters": null, - "times_used": 0 - } - ], - "table_calculations": [], - "pivots": [] - } -} - -export const testChunkProperties = [ - 'value', - 'value_links', - 'value_label', - 'value_rendered', - 'value_dimension', - 'value_formatting', - 'target', - 'target_rendered', - 'target_label', - 'target_dimension' -]; - -export const testBarDefaultProperties = [ - 'w', - 'h', - 'limiting_aspect', - 'margin', - 'style', - 'angle', - 'cutout', - 'color', - 'gauge_background', - 'range', - 'value', - 'value_rendered', - 'target', - 'value_label', - 'target_label', - 'value_dimension', - 'target_dimension', - 'target_rendered', - 'value_links', - 'label_font', - 'range_formatting', - 'range_x', - 'range_y', - 'gauge_fill_type', - 'fill_colors', - 'range_color', - 'spinner', - 'spinner_weight', - 'spinner_background', - 'arm', - 'arm_weight', - 'target_length', - 'target_gap', - 'target_weight', - 'target_background', - 'target_source', - 'value_label_type', - 'value_label_font', - 'value_label_padding', - 'target_label_type', - 'target_label_font', - 'target_label_padding', - 'wrap_width' -] diff --git a/src/tests/viz-gauge.test.js b/src/tests/viz-gauge.test.js deleted file mode 100644 index ec87e70..0000000 --- a/src/tests/viz-gauge.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import { getBarDefaults, processData } from "../viz-gauge"; -import { testBarDefaultProperties, testChunkProperties, testConfig, testData, testQueryResponse } from "./viz-gauge-test-data"; -import SSF from 'ssf'; - -describe('Should process data and return a chunk with needed configurations', () => { - test('should return all needed properties', () => { - const chunk = processData(testData, testQueryResponse, testConfig, undefined); - const hasAllProperties = testChunkProperties.every((k) => chunk.hasOwnProperty(k)); - - expect(hasAllProperties).toBe(true); - }); - test('should format rendered value if bar value formatting is set', () => { - const chunk = processData(testData, testQueryResponse, testConfig, undefined); - - expect(chunk.value_rendered).toEqual(SSF.format(config.bar_value_formatting, testData[0][mesID])); - }); - test('should format rendered target value if target formatting is set', () => { - const chunk = processData(testData, testQueryResponse, testConfig, undefined); - - expect(chunk.target_rendered).toEqual(SSF.format(config.bar_target_value_format, testData[0][tarID].value)); - }); -}); - -describe('Should set bar defaults from processed data', () => { - test('should return all needed properties', () => { - const chunk = processData(testData, testQueryResponse, testConfig, undefined); - const barDefaults = getBarDefaults(10, 10, 10, testConfig, chunk) - - const hasAllProperties = testBarDefaultProperties.every((k) => barDefaults.hasOwnProperty(k)); - - expect(hasAllProperties).toBe(true); - }); -}); diff --git a/src/viz-config.js b/src/viz-config.js index 12ef1b8..254746c 100644 --- a/src/viz-config.js +++ b/src/viz-config.js @@ -222,6 +222,6 @@ export const vizConfig = { section: 'Style', display: 'color', order: 40, - } - } -} + }, + }, +}; diff --git a/src/viz-gauge-test-data.js b/src/viz-gauge-test-data.js new file mode 100644 index 0000000..046b22f --- /dev/null +++ b/src/viz-gauge-test-data.js @@ -0,0 +1,849 @@ +export const testData = [ + { + 'flights.destination': { + value: 'ATL', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ATL', + type_label_prefix: 'Drill into', + type_label_value: 'ATL', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ATL', + type_label_prefix: 'Drill into', + type_label_value: 'ATL', + }, + ], + }, + 'flights.flight_count': { + value: 1901518, + rendered: '1,901,518', + links: [ + { + label: 'Show All 1,901,518', + label_prefix: 'Show All', + label_value: '1,901,518', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ATL&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, + { + 'flights.destination': { + value: 'ORD', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ORD', + type_label_prefix: 'Drill into', + type_label_value: 'ORD', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ORD', + type_label_prefix: 'Drill into', + type_label_value: 'ORD', + }, + ], + }, + 'flights.flight_count': { + value: 1895066, + rendered: '1,895,066', + links: [ + { + label: 'Show All 1,895,066', + label_prefix: 'Show All', + label_value: '1,895,066', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ORD&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, + { + 'flights.destination': { + value: 'DFW', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into DFW', + type_label_prefix: 'Drill into', + type_label_value: 'DFW', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into DFW', + type_label_prefix: 'Drill into', + type_label_value: 'DFW', + }, + ], + }, + 'flights.flight_count': { + value: 1776593, + rendered: '1,776,593', + links: [ + { + label: 'Show All 1,776,593', + label_prefix: 'Show All', + label_value: '1,776,593', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=DFW&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, +]; + +export const testQueryResponse = { + aggregate_table_used_info: null, + data: [ + { + 'flights.destination': { + value: 'ATL', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ATL', + type_label_prefix: 'Drill into', + type_label_value: 'ATL', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ATL&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ATL', + type_label_prefix: 'Drill into', + type_label_value: 'ATL', + }, + ], + }, + 'flights.flight_count': { + value: 1901518, + rendered: '1,901,518', + links: [ + { + label: 'Show All 1,901,518', + label_prefix: 'Show All', + label_value: '1,901,518', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ATL&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, + { + 'flights.destination': { + value: 'ORD', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ORD', + type_label_prefix: 'Drill into', + type_label_value: 'ORD', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=ORD&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into ORD', + type_label_prefix: 'Drill into', + type_label_value: 'ORD', + }, + ], + }, + 'flights.flight_count': { + value: 1895066, + rendered: '1,895,066', + links: [ + { + label: 'Show All 1,895,066', + label_prefix: 'Show All', + label_value: '1,895,066', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=ORD&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, + { + 'flights.destination': { + value: 'DFW', + links: [ + { + label: 'by Carrier', + label_prefix: 'by', + label_value: 'Carrier', + url: '/explore/faa/flights?fields=flights.flight_count,flights.carrier&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into DFW', + type_label_prefix: 'Drill into', + type_label_value: 'DFW', + }, + { + label: 'by Origin', + label_prefix: 'by', + label_value: 'Origin', + url: '/explore/faa/flights?fields=flights.flight_count,flights.origin&f[flights.destination]=DFW&sorts=flights.flight_count desc 0&limit=500&column_limit=50&query_timezone=America%2FLos_Angeles', + type: 'drill', + type_label: 'Drill into DFW', + type_label_prefix: 'Drill into', + type_label_value: 'DFW', + }, + ], + }, + 'flights.flight_count': { + value: 1776593, + rendered: '1,776,593', + links: [ + { + label: 'Show All 1,776,593', + label_prefix: 'Show All', + label_value: '1,776,593', + url: '/explore/faa/flights?fields=carriers.nickname,flights.origin,flights.count_delayed_flights,flights.flight_count&f[flights.destination]=DFW&query_timezone=America%2FLos_Angeles&limit=500', + type: 'measure_default', + }, + ], + }, + }, + ], + drill_menu_build_time: 0.176502, + expired: false, + fields: { + measures: [ + { + align: 'right', + can_filter: true, + category: 'measure', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: true, + label: 'Flights Flight Count', + label_from_parameter: null, + label_short: 'Flight Count', + map_layer: null, + name: 'flights.flight_count', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'count', + user_attribute_filter_types: ['number', 'advanced_filter_number'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Flight Count', + measure: true, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.flight_count', + suggest_explore: 'flights', + suggestable: false, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=220', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: null, + sql_case: null, + filters: null, + times_used: 0, + sorted: { + sort_index: 0, + desc: true, + pivot_index: 0, + }, + }, + ], + dimensions: [ + { + align: 'left', + can_filter: true, + category: 'dimension', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: false, + label: 'Flights Destination', + label_from_parameter: null, + label_short: 'Destination', + map_layer: null, + name: 'flights.destination', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'string', + user_attribute_filter_types: ['string', 'advanced_filter_string'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Destination', + measure: false, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.destination', + suggest_explore: 'flights', + suggestable: true, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=80', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: '${TABLE}.destination ', + sql_case: null, + filters: null, + times_used: 0, + }, + ], + table_calculations: [], + pivots: [], + measure_like: [ + { + align: 'right', + can_filter: true, + category: 'measure', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: true, + label: 'Flights Flight Count', + label_from_parameter: null, + label_short: 'Flight Count', + map_layer: null, + name: 'flights.flight_count', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'count', + user_attribute_filter_types: ['number', 'advanced_filter_number'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Flight Count', + measure: true, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.flight_count', + suggest_explore: 'flights', + suggestable: false, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=220', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: null, + sql_case: null, + filters: null, + times_used: 0, + sorted: { + sort_index: 0, + desc: true, + pivot_index: 0, + }, + }, + { + align: 'right', + can_filter: true, + category: 'measure', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: true, + label: 'Flights Flight Count', + label_from_parameter: null, + label_short: 'Flight Count', + map_layer: null, + name: 'flights.flight_count', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'count', + user_attribute_filter_types: ['number', 'advanced_filter_number'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Flight Count', + measure: true, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.flight_count', + suggest_explore: 'flights', + suggestable: false, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=220', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: null, + sql_case: null, + filters: null, + times_used: 0, + sorted: { + sort_index: 0, + desc: true, + pivot_index: 0, + }, + }, + ], + dimension_like: [ + { + align: 'left', + can_filter: true, + category: 'dimension', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: false, + label: 'Flights Destination', + label_from_parameter: null, + label_short: 'Destination', + map_layer: null, + name: 'flights.destination', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'string', + user_attribute_filter_types: ['string', 'advanced_filter_string'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Destination', + measure: false, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.destination', + suggest_explore: 'flights', + suggestable: true, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=80', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: '${TABLE}.destination ', + sql_case: null, + filters: null, + times_used: 0, + }, + ], + }, + fill_fields: [], + forecast_result: null, + has_row_totals: false, + has_totals: false, + id: '177dcc6a712f8df8ff2cf5bdbabc7184:{"hidden_points_if_no":[],"hidden_fields":[]}', + null_sort_treatment: 'low', + number_format: '1,234.56', + ran_at: '2023-10-02T15:19:32+00:00', + sql: 'SELECT\n destination AS flights_destination,\n COUNT(*) AS flights_flight_count\nFROM\n faa.flights AS flights\nWHERE ((TIMESTAMP_DIFF(flights.arr_time , flights.dep_time , MINUTE)) > 0 and (TIMESTAMP_DIFF(flights.arr_time , flights.dep_time , MINUTE)) < 2000 ) AND carrier IS NOT NULL\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT 500', + sql_explain: null, + supports_pivot_in_db: true, + timezone: 'America/Los_Angeles', + is_local: false, + table_calcs_complete: true, + tracked_attributes: { + 'result.data.length': 298, + 'result.drill_menu_build_time': 0.176502, + 'result.from_cache': false, + 'result.sql.length': 334, + 'result.supports_pivot_in_db': true, + }, + sorts: [], +}; + +export const testConfig = { + bar_arm_length: 25, + bar_arm_weight: 50, + bar_spinner_length: 100, + bar_spinner_weight: 50, + bar_style: 'horizontal', + bar_range_min: 10000, + bar_range_max: 1500000, + bar_value_label_type: 'both', + bar_value_label_font: 8, + bar_value_formatting: '#.00', + bar_value_label_padding: 60, + bar_target_source: 'second', + bar_target_label_type: 'both', + bar_target_label_font: 3, + bar_target_label_override: '', + bar_target_value_format: '#.00', + bar_label_font_size: 3, + bar_fill_color: '#4285F4', + bar_background_color: '#DADCE0', + bar_spinner_color: '#5F6368', + bar_range_color: '#5F6368', + type: 'marketplace_viz_bar_gauge::bar_gauge-marketplace', + query_fields: { + measures: [ + { + align: 'right', + can_filter: true, + category: 'measure', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: true, + label: 'Flights Flight Count', + label_from_parameter: null, + label_short: 'Flight Count', + map_layer: null, + name: 'flights.flight_count', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'count', + user_attribute_filter_types: ['number', 'advanced_filter_number'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Flight Count', + measure: true, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.flight_count', + suggest_explore: 'flights', + suggestable: false, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=220', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: null, + sql_case: null, + filters: null, + times_used: 0, + sorted: { + sort_index: 0, + desc: true, + pivot_index: 0, + }, + }, + { + align: 'right', + can_filter: true, + category: 'measure', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: true, + label: 'Flights Count Delayed Flights', + label_from_parameter: null, + label_short: 'Count Delayed Flights', + map_layer: null, + name: 'flights.count_delayed_flights', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'count', + user_attribute_filter_types: ['number', 'advanced_filter_number'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Count Delayed Flights', + measure: true, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.count_delayed_flights', + suggest_explore: 'flights', + suggestable: false, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=107', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: null, + sql_case: null, + filters: [ + { + field: 'flights.is_flight_delayed', + condition: 'Yes', + }, + ], + times_used: 0, + }, + ], + dimensions: [ + { + align: 'left', + can_filter: true, + category: 'dimension', + default_filter_value: null, + description: '', + enumerations: null, + field_group_label: null, + fill_style: null, + fiscal_month_offset: 0, + has_allowed_values: false, + hidden: false, + is_filter: false, + is_numeric: false, + label: 'Flights Destination', + label_from_parameter: null, + label_short: 'Destination', + map_layer: null, + name: 'flights.destination', + strict_value_format: false, + requires_refresh_on_sort: false, + sortable: true, + suggestions: null, + tags: [], + type: 'string', + user_attribute_filter_types: ['string', 'advanced_filter_string'], + value_format: null, + view: 'flights', + view_label: 'Flights', + dynamic: false, + week_start_day: 'monday', + original_view: 'flights', + dimension_group: null, + error: null, + field_group_variant: 'Destination', + measure: false, + parameter: false, + primary_key: false, + project_name: 'faa', + scope: 'flights', + suggest_dimension: 'flights.destination', + suggest_explore: 'flights', + suggestable: true, + is_fiscal: false, + is_timeframe: false, + can_time_filter: false, + time_interval: null, + lookml_link: '/projects/faa/files/flights.view.lkml?line=80', + permanent: null, + source_file: 'flights.view.lkml', + source_file_path: 'faa/flights.view.lkml', + sql: '${TABLE}.destination ', + sql_case: null, + filters: null, + times_used: 0, + }, + ], + table_calculations: [], + pivots: [], + }, +}; + +export const testChunkProperties = [ + 'value', + 'value_links', + 'value_label', + 'value_rendered', + 'value_dimension', + 'value_formatting', + 'target', + 'target_rendered', + 'target_label', + 'target_dimension', +]; + +export const testBarDefaultProperties = [ + 'w', + 'h', + 'limiting_aspect', + 'margin', + 'style', + 'angle', + 'cutout', + 'color', + 'gauge_background', + 'range', + 'value', + 'value_rendered', + 'target', + 'value_label', + 'target_label', + 'value_dimension', + 'target_dimension', + 'target_rendered', + 'value_links', + 'label_font', + 'range_formatting', + 'range_x', + 'range_y', + 'gauge_fill_type', + 'fill_colors', + 'range_color', + 'spinner', + 'spinner_weight', + 'spinner_background', + 'arm', + 'arm_weight', + 'target_length', + 'target_gap', + 'target_weight', + 'target_background', + 'target_source', + 'value_label_type', + 'value_label_font', + 'value_label_padding', + 'target_label_type', + 'target_label_font', + 'target_label_padding', + 'wrap_width', +]; diff --git a/src/viz-gauge.js b/src/viz-gauge.js index 2c82e75..4c40efe 100644 --- a/src/viz-gauge.js +++ b/src/viz-gauge.js @@ -1,9 +1,9 @@ import VerticalGauge from './VerticalGauge'; import HorizontalGauge from './HorizontalGauge'; -import { vizConfig } from './viz-config'; +import {vizConfig} from './viz-config'; import React from 'react'; import ReactDOM from 'react-dom'; -import { getBarDefaults, processData } from './helpers'; +import {getBarDefaults, processData} from './helpers'; // const formattedValue = dataPoints[0].valueFormat === "" ? dataPoints[0].formattedValue : SSF.format(dataPoints[0].valueFormat, dataPoints[0].value) looker.plugins.visualizations.add({ diff --git a/src/viz-gauge.test.js b/src/viz-gauge.test.js new file mode 100644 index 0000000..79113cc --- /dev/null +++ b/src/viz-gauge.test.js @@ -0,0 +1,75 @@ +import {getBarDefaults, processData} from './helpers'; +import { + testBarDefaultProperties, + testChunkProperties, + testConfig, + testData, + testQueryResponse, +} from './viz-gauge-test-data'; +import SSF from 'ssf'; + +const measures = testQueryResponse['fields']['measure_like']; + +describe('Should process data and return a chunk with needed configurations', () => { + test('should return all needed properties', () => { + const chunk = processData( + testData, + testQueryResponse, + testConfig, + undefined + ); + const hasAllProperties = testChunkProperties.every(k => + chunk.hasOwnProperty(k) + ); + + expect(hasAllProperties).toBe(true); + }); + test('should format rendered value if bar value formatting is set', () => { + const chunk = processData( + testData, + testQueryResponse, + testConfig, + undefined + ); + + const measureId = measures[0]['name']; + const measureData = testData[0][measureId]; + + expect(chunk.value_rendered).toEqual( + SSF.format(testConfig.bar_value_formatting, measureData.value) + ); + }); + test('should format rendered target value if target formatting is set', () => { + const chunk = processData( + testData, + testQueryResponse, + testConfig, + undefined + ); + + const targetId = measures[1]['name']; + const targetData = testData[0][targetId]; + + expect(chunk.target_rendered).toEqual( + SSF.format(testConfig.bar_target_value_format, targetData.value) + ); + }); +}); + +describe('Should set bar defaults from processed data', () => { + test('should return all needed properties', () => { + const chunk = processData( + testData, + testQueryResponse, + testConfig, + undefined + ); + const barDefaults = getBarDefaults(10, 10, 10, testConfig, chunk); + + const hasAllProperties = testBarDefaultProperties.every(k => + barDefaults.hasOwnProperty(k) + ); + + expect(hasAllProperties).toBe(true); + }); +});