Skip to content

Instantly share code, notes, and snippets.

@jb3-2
Forked from jeffrey-effendy/.gitignore
Created February 25, 2017 10:52
Show Gist options
  • Save jb3-2/21fcf6aebd2d68b8bd06084dd5d52af3 to your computer and use it in GitHub Desktop.
Save jb3-2/21fcf6aebd2d68b8bd06084dd5d52af3 to your computer and use it in GitHub Desktop.
d3-sankey demo
node_modules
import {drag} from "d3-drag";
import {format} from "d3-format";
import {scaleOrdinal, schemeCategory20} from "d3-scale";
import {event, select} from "d3-selection";
import {sankey} from "d3-sankey";
import {json} from "d3-request";
import {rgb} from "d3-color";
export {
event,
format,
scaleOrdinal,
schemeCategory20,
drag,
select,
sankey,
json,
rgb
}
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("d3",e):n.d3=e()}(this,function(){"use strict";function n(){for(var n,t=0,r=arguments.length,i={};t<r;++t){if(!(n=arguments[t]+"")||n in i)throw new Error("illegal type: "+n);i[n]=[]}return new e(i)}function e(n){this._=n}function t(n,e){return n.trim().split(/^|\s+/).map(function(n){var t="",r=n.indexOf(".");if(r>=0&&(t=n.slice(r+1),n=n.slice(0,r)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:t}})}function r(n,e){for(var t,r=0,i=n.length;r<i;++r)if((t=n[r]).name===e)return t.value}function i(n,e,t){for(var r=0,i=n.length;r<i;++r)if(n[r].name===e){n[r]=yr,n=n.slice(0,r).concat(n.slice(r+1));break}return null!=t&&n.push({name:e,value:t}),n}function u(n){var e=n+="",t=e.indexOf(":");return t>=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),mr.hasOwnProperty(e)?{space:mr[e],local:n}:n}function a(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===vr&&e.documentElement.namespaceURI===vr?e.createElement(n):e.createElementNS(t,n)}}function o(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function c(n){var e=u(n);return(e.local?o:a)(e)}function f(n,e,t){return n=s(n,e,t),function(e){var t=e.relatedTarget;t&&(t===this||8&t.compareDocumentPosition(this))||n.call(this,e)}}function s(n,e,t){return function(r){var i=Cr;Cr=r;try{n.call(this,this.__data__,e,t)}finally{Cr=i}}}function l(n){return n.trim().split(/^|\s+/).map(function(n){var e="",t=n.indexOf(".");return t>=0&&(e=n.slice(t+1),n=n.slice(0,t)),{type:n,name:e}})}function h(n){return function(){var e=this.__on;if(e){for(var t,r=0,i=-1,u=e.length;r<u;++r)t=e[r],n.type&&t.type!==n.type||t.name!==n.name?e[++i]=t:this.removeEventListener(t.type,t.listener,t.capture);++i?e.length=i:delete this.__on}}}function d(n,e,t){var r=xr.hasOwnProperty(n.type)?f:s;return function(i,u,a){var o,c=this.__on,f=r(e,u,a);if(c)for(var s=0,l=c.length;s<l;++s)if((o=c[s]).type===n.type&&o.name===n.name)return this.removeEventListener(o.type,o.listener,o.capture),this.addEventListener(o.type,o.listener=f,o.capture=t),void(o.value=e);this.addEventListener(n.type,f,t),o={type:n.type,name:n.name,value:e,listener:f,capture:t},c?c.push(o):this.__on=[o]}}function g(n,e,t){var r,i,u=l(n+""),a=u.length;{if(!(arguments.length<2)){for(o=e?d:h,null==t&&(t=!1),r=0;r<a;++r)this.each(o(u[r],e,t));return this}var o=this.node().__on;if(o)for(var c,f=0,s=o.length;f<s;++f)for(r=0,c=o[f];r<a;++r)if((i=u[r]).type===c.type&&i.name===c.name)return c.value}}function b(n,e,t,r){var i=Cr;n.sourceEvent=Cr,Cr=n;try{return e.apply(t,r)}finally{Cr=i}}function p(){for(var n,e=Cr;n=e.sourceEvent;)e=n;return e}function y(n,e){var t=n.ownerSVGElement||n;if(t.createSVGPoint){var r=t.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}function v(n){var e=p();return e.changedTouches&&(e=e.changedTouches[0]),y(n,e)}function m(){}function w(n){return null==n?m:function(){return this.querySelector(n)}}function M(n){"function"!=typeof n&&(n=w(n));for(var e=this._groups,t=e.length,r=new Array(t),i=0;i<t;++i)for(var u,a,o=e[i],c=o.length,f=r[i]=new Array(c),s=0;s<c;++s)(u=o[s])&&(a=n.call(u,u.__data__,s,o))&&("__data__"in u&&(a.__data__=u.__data__),f[s]=a);return new On(r,this._parents)}function _(){return[]}function T(n){return null==n?_:function(){return this.querySelectorAll(n)}}function x(n){"function"!=typeof n&&(n=T(n));for(var e=this._groups,t=e.length,r=[],i=[],u=0;u<t;++u)for(var a,o=e[u],c=o.length,f=0;f<c;++f)(a=o[f])&&(r.push(n.call(a,a.__data__,f,o)),i.push(a));return new On(r,i)}function C(n){"function"!=typeof n&&(n=Tr(n));for(var e=this._groups,t=e.length,r=new Array(t),i=0;i<t;++i)for(var u,a=e[i],o=a.length,c=r[i]=[],f=0;f<o;++f)(u=a[f])&&n.call(u,u.__data__,f,a)&&c.push(u);return new On(r,this._parents)}function k(n){return new Array(n.length)}function S(){return new On(this._enter||this._groups.map(k),this._parents)}function U(n,e){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=e}function A(n){return function(){return n}}function N(n,e,t,r,i,u){for(var a,o=0,c=e.length,f=u.length;o<f;++o)(a=e[o])?(a.__data__=u[o],r[o]=a):t[o]=new U(n,u[o]);for(;o<c;++o)(a=e[o])&&(i[o]=a)}function D(n,e,t,r,i,u,a){var o,c,f,s={},l=e.length,h=u.length,d=new Array(l);for(o=0;o<l;++o)(c=e[o])&&(d[o]=f=Sr+a.call(c,c.__data__,o,e),f in s?i[o]=c:s[f]=c);for(o=0;o<h;++o)f=Sr+a.call(n,u[o],o,u),(c=s[f])?(r[o]=c,c.__data__=u[o],s[f]=null):t[o]=new U(n,u[o]);for(o=0;o<l;++o)(c=e[o])&&s[d[o]]===c&&(i[o]=c)}function E(n,e){if(!n)return d=new Array(this.size()),f=-1,this.each(function(n){d[++f]=n}),d;var t=e?D:N,r=this._parents,i=this._groups;"function"!=typeof n&&(n=A(n));for(var u=i.length,a=new Array(u),o=new Array(u),c=new Array(u),f=0;f<u;++f){var s=r[f],l=i[f],h=l.length,d=n.call(s,s&&s.__data__,f,r),g=d.length,b=o[f]=new Array(g),p=a[f]=new Array(g),y=c[f]=new Array(h);t(s,l,b,p,y,d,e);for(var v,m,w=0,M=0;w<g;++w)if(v=b[w]){for(w>=M&&(M=w+1);!(m=p[M])&&++M<g;);v._next=m||null}}return a=new On(a,r),a._enter=o,a._exit=c,a}function L(){return new On(this._exit||this._groups.map(k),this._parents)}function F(n){for(var e=this._groups,t=n._groups,r=e.length,i=t.length,u=Math.min(r,i),a=new Array(r),o=0;o<u;++o)for(var c,f=e[o],s=t[o],l=f.length,h=a[o]=new Array(l),d=0;d<l;++d)(c=f[d]||s[d])&&(h[d]=c);for(;o<r;++o)a[o]=e[o];return new On(a,this._parents)}function H(){for(var n=this._groups,e=-1,t=n.length;++e<t;)for(var r,i=n[e],u=i.length-1,a=i[u];--u>=0;)(r=i[u])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this}function Y(n){function e(e,t){return e&&t?n(e.__data__,t.__data__):!e-!t}n||(n=j);for(var t=this._groups,r=t.length,i=new Array(r),u=0;u<r;++u){for(var a,o=t[u],c=o.length,f=i[u]=new Array(c),s=0;s<c;++s)(a=o[s])&&(f[s]=a);f.sort(e)}return new On(i,this._parents).order()}function j(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function O(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function P(){var n=new Array(this.size()),e=-1;return this.each(function(){n[++e]=this}),n}function q(){for(var n=this._groups,e=0,t=n.length;e<t;++e)for(var r=n[e],i=0,u=r.length;i<u;++i){var a=r[i];if(a)return a}return null}function z(){var n=0;return this.each(function(){++n}),n}function $(){return!this.node()}function I(n){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var i,u=e[t],a=0,o=u.length;a<o;++a)(i=u[a])&&n.call(i,i.__data__,a,u);return this}function X(n){return function(){this.removeAttribute(n)}}function R(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Z(n,e){return function(){this.setAttribute(n,e)}}function W(n,e){return function(){this.setAttributeNS(n.space,n.local,e)}}function B(n,e){return function(){var t=e.apply(this,arguments);null==t?this.removeAttribute(n):this.setAttribute(n,t)}}function J(n,e){return function(){var t=e.apply(this,arguments);null==t?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}}function V(n,e){var t=u(n);if(arguments.length<2){var r=this.node();return t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}return this.each((null==e?t.local?R:X:"function"==typeof e?t.local?J:B:t.local?W:Z)(t,e))}function G(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function K(n){return function(){this.style.removeProperty(n)}}function Q(n,e,t){return function(){this.style.setProperty(n,e,t)}}function nn(n,e,t){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(n):this.style.setProperty(n,r,t)}}function en(n,e,t){var r;return arguments.length>1?this.each((null==e?K:"function"==typeof e?nn:Q)(n,e,null==t?"":t)):G(r=this.node()).getComputedStyle(r,null).getPropertyValue(n)}function tn(n){return function(){delete this[n]}}function rn(n,e){return function(){this[n]=e}}function un(n,e){return function(){var t=e.apply(this,arguments);null==t?delete this[n]:this[n]=t}}function an(n,e){return arguments.length>1?this.each((null==e?tn:"function"==typeof e?un:rn)(n,e)):this.node()[n]}function on(n){return n.trim().split(/^|\s+/)}function cn(n){return n.classList||new fn(n)}function fn(n){this._node=n,this._names=on(n.getAttribute("class")||"")}function sn(n,e){for(var t=cn(n),r=-1,i=e.length;++r<i;)t.add(e[r])}function ln(n,e){for(var t=cn(n),r=-1,i=e.length;++r<i;)t.remove(e[r])}function hn(n){return function(){sn(this,n)}}function dn(n){return function(){ln(this,n)}}function gn(n,e){return function(){(e.apply(this,arguments)?sn:ln)(this,n)}}function bn(n,e){var t=on(n+"");if(arguments.length<2){for(var r=cn(this.node()),i=-1,u=t.length;++i<u;)if(!r.contains(t[i]))return!1;return!0}return this.each(("function"==typeof e?gn:e?hn:dn)(t,e))}function pn(){this.textContent=""}function yn(n){return function(){this.textContent=n}}function vn(n){return function(){var e=n.apply(this,arguments);this.textContent=null==e?"":e}}function mn(n){return arguments.length?this.each(null==n?pn:("function"==typeof n?vn:yn)(n)):this.node().textContent}function wn(){this.innerHTML=""}function Mn(n){return function(){this.innerHTML=n}}function _n(n){return function(){var e=n.apply(this,arguments);this.innerHTML=null==e?"":e}}function Tn(n){return arguments.length?this.each(null==n?wn:("function"==typeof n?_n:Mn)(n)):this.node().innerHTML}function xn(){this.nextSibling&&this.parentNode.appendChild(this)}function Cn(){return this.each(xn)}function kn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Sn(){return this.each(kn)}function Un(n){var e="function"==typeof n?n:c(n);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function An(){return null}function Nn(n,e){var t="function"==typeof n?n:c(n),r=null==e?An:"function"==typeof e?e:w(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),r.apply(this,arguments)||null)})}function Dn(){var n=this.parentNode;n&&n.removeChild(this)}function En(){return this.each(Dn)}function Ln(n){return arguments.length?this.property("__data__",n):this.node().__data__}function Fn(n,e,t){var r=G(n),i=r.CustomEvent;i?i=new i(e,t):(i=r.document.createEvent("Event"),t?(i.initEvent(e,t.bubbles,t.cancelable),i.detail=t.detail):i.initEvent(e,!1,!1)),n.dispatchEvent(i)}function Hn(n,e){return function(){return Fn(this,n,e)}}function Yn(n,e){return function(){return Fn(this,n,e.apply(this,arguments))}}function jn(n,e){return this.each(("function"==typeof e?Yn:Hn)(n,e))}function On(n,e){this._groups=n,this._parents=e}function Pn(){return new On([[document.documentElement]],Ur)}function qn(n){return"string"==typeof n?new On([[document.querySelector(n)]],[document.documentElement]):new On([[n]],Ur)}function zn(n,e,t){arguments.length<3&&(t=e,e=p().changedTouches);for(var r,i=0,u=e?e.length:0;i<u;++i)if((r=e[i]).identifier===t)return y(n,r);return null}function $n(){Cr.stopImmediatePropagation()}function In(){Cr.preventDefault(),Cr.stopImmediatePropagation()}function Xn(n){var e=n.document.documentElement,t=qn(n).on("dragstart.drag",In,!0);"onselectstart"in e?t.on("selectstart.drag",In,!0):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Rn(n,e){var t=n.document.documentElement,r=qn(n).on("dragstart.drag",null);e&&(r.on("click.drag",In,!0),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in t?r.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function Zn(n){return function(){return n}}function Wn(n,e,t,r,i,u,a,o,c,f){this.target=n,this.type=e,this.subject=t,this.identifier=r,this.active=i,this.x=u,this.y=a,this.dx=o,this.dy=c,this._=f}function Bn(){return!Cr.button}function Jn(){return this.parentNode}function Vn(n){return null==n?{x:Cr.x,y:Cr.y}:n}function Gn(){function e(n){n.on("mousedown.drag",t).on("touchstart.drag",u).on("touchmove.drag",a).on("touchend.drag touchcancel.drag",o).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function t(){if(!s&&l.apply(this,arguments)){var n=c("mouse",h.apply(this,arguments),v,this,arguments);n&&(qn(Cr.view).on("mousemove.drag",r,!0).on("mouseup.drag",i,!0),Xn(Cr.view),$n(),f=!1,n("start"))}}function r(){In(),f=!0,g.mouse("drag")}function i(){qn(Cr.view).on("mousemove.drag mouseup.drag",null),Rn(Cr.view,f),In(),g.mouse("end")}function u(){if(l.apply(this,arguments)){var n,e,t=Cr.changedTouches,r=h.apply(this,arguments),i=t.length;for(n=0;n<i;++n)(e=c(t[n].identifier,r,zn,this,arguments))&&($n(),e("start"))}}function a(){var n,e,t=Cr.changedTouches,r=t.length;for(n=0;n<r;++n)(e=g[t[n].identifier])&&(In(),e("drag"))}function o(){var n,e,t=Cr.changedTouches,r=t.length;for(s&&clearTimeout(s),s=setTimeout(function(){s=null},500),n=0;n<r;++n)(e=g[t[n].identifier])&&($n(),e("end"))}function c(n,t,r,i,u){var a,o,c,f=r(t,n),s=p.copy();if(b(new Wn(e,"beforestart",a,n,y,f[0],f[1],0,0,s),function(){return null!=(Cr.subject=a=d.apply(i,u))&&(o=a.x-f[0]||0,c=a.y-f[1]||0,!0)}))return function l(h){var d,p=f;switch(h){case"start":g[n]=l,d=y++;break;case"end":delete g[n],--y;case"drag":f=r(t,n),d=y}b(new Wn(e,h,a,n,d,f[0]+o,f[1]+c,f[0]-p[0],f[1]-p[1],s),s.apply,s,[h,i,u])}}var f,s,l=Bn,h=Jn,d=Vn,g={},p=n("start","drag","end"),y=0;return e.filter=function(n){return arguments.length?(l="function"==typeof n?n:Zn(!!n),e):l},e.container=function(n){return arguments.length?(h="function"==typeof n?n:Zn(n),e):h},e.subject=function(n){return arguments.length?(d="function"==typeof n?n:Zn(n),e):d},e.on=function(){var n=p.on.apply(p,arguments);return n===p?e:n},e}function Kn(n,e){if((t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"))<0)return null;var t,r=n.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+n.slice(t+1)]}function Qn(n){return n=Kn(Math.abs(n)),n?n[1]:NaN}function ne(n,e){return function(t,r){for(var i=t.length,u=[],a=0,o=n[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),u.push(t.substring(i-=o,i+o)),!((c+=o+1)>r));)o=n[a=(a+1)%n.length];return u.reverse().join(e)}}function ee(n,e){n=n.toPrecision(e);n:for(var t,r=n.length,i=1,u=-1;i<r;++i)switch(n[i]){case".":u=t=i;break;case"0":0===u&&(u=i),t=i;break;case"e":break n;default:u>0&&(u=0)}return u>0?n.slice(0,u)+n.slice(t+1):n}function te(n,e){var t=Kn(n,e);if(!t)return n+"";var r=t[0],i=t[1],u=i-(Ar=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return u===a?r:u>a?r+new Array(u-a+1).join("0"):u>0?r.slice(0,u)+"."+r.slice(u):"0."+new Array(1-u).join("0")+Kn(n,Math.max(0,e+u-1))[0]}function re(n,e){var t=Kn(n,e);if(!t)return n+"";var r=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}function ie(n){return new ue(n)}function ue(n){if(!(e=Dr.exec(n)))throw new Error("invalid format: "+n);var e,t=e[1]||" ",r=e[2]||">",i=e[3]||"-",u=e[4]||"",a=!!e[5],o=e[6]&&+e[6],c=!!e[7],f=e[8]&&+e[8].slice(1),s=e[9]||"";"n"===s?(c=!0,s="g"):Nr[s]||(s=""),(a||"0"===t&&"="===r)&&(a=!0,t="0",r="="),this.fill=t,this.align=r,this.sign=i,this.symbol=u,this.zero=a,this.width=o,this.comma=c,this.precision=f,this.type=s}function ae(n){return n}function oe(n){function e(n){function e(n){var e,i,c,v=g,m=b;if("c"===d)m=p(n)+m,n="";else{n=+n;var w=(n<0||1/n<0)&&(n*=-1,!0);if(n=p(n,h),w)for(e=-1,i=n.length,w=!1;++e<i;)if(c=n.charCodeAt(e),48<c&&c<58||"x"===d&&96<c&&c<103||"X"===d&&64<c&&c<71){w=!0;break}if(v=(w?"("===o?o:"-":"-"===o||"("===o?"":o)+v,m=m+("s"===d?Hr[8+Ar/3]:"")+(w&&"("===o?")":""),y)for(e=-1,i=n.length;++e<i;)if(c=n.charCodeAt(e),48>c||c>57){m=(46===c?u+n.slice(e+1):n.slice(e))+m,n=n.slice(0,e);break}}l&&!f&&(n=r(n,1/0));var M=v.length+n.length+m.length,_=M<s?new Array(s-M+1).join(t):"";switch(l&&f&&(n=r(_+n,_.length?s-m.length:1/0),_=""),a){case"<":return v+n+m+_;case"=":return v+_+n+m;case"^":return _.slice(0,M=_.length>>1)+v+n+m+_.slice(M)}return _+v+n+m}n=ie(n);var t=n.fill,a=n.align,o=n.sign,c=n.symbol,f=n.zero,s=n.width,l=n.comma,h=n.precision,d=n.type,g="$"===c?i[0]:"#"===c&&/[boxX]/.test(d)?"0"+d.toLowerCase():"",b="$"===c?i[1]:/[%p]/.test(d)?"%":"",p=Nr[d],y=!d||/[defgprs%]/.test(d);return h=null==h?d?6:12:/[gprs]/.test(d)?Math.max(1,Math.min(21,h)):Math.max(0,Math.min(20,h)),e.toString=function(){return n+""},e}function t(n,t){var r=e((n=ie(n),n.type="f",n)),i=3*Math.max(-8,Math.min(8,Math.floor(Qn(t)/3))),u=Math.pow(10,-i),a=Hr[8+i/3];return function(n){return r(u*n)+a}}var r=n.grouping&&n.thousands?ne(n.grouping,n.thousands):ae,i=n.currency,u=n.decimal;return{format:e,formatPrefix:t}}function ce(n){return Er=oe(n),Lr=Er.format,Fr=Er.formatPrefix,Er}function fe(n,e){return n<e?-1:n>e?1:n>=e?0:NaN}function se(n){return 1===n.length&&(n=le(n)),{left:function(e,t,r,i){for(null==r&&(r=0),null==i&&(i=e.length);r<i;){var u=r+i>>>1;n(e[u],t)<0?r=u+1:i=u}return r},right:function(e,t,r,i){for(null==r&&(r=0),null==i&&(i=e.length);r<i;){var u=r+i>>>1;n(e[u],t)>0?i=u:r=u+1}return r}}}function le(n){return function(e,t){return fe(n(e),t)}}function he(n,e){var t,r,i=-1,u=n.length;if(null==e){for(;++i<u;)if(null!=(r=n[i])&&r>=r){t=r;break}for(;++i<u;)null!=(r=n[i])&&t>r&&(t=r)}else{for(;++i<u;)if(null!=(r=e(n[i],i,n))&&r>=r){t=r;break}for(;++i<u;)null!=(r=e(n[i],i,n))&&t>r&&(t=r)}return t}function de(n,e){var t,r=0,i=n.length,u=-1;if(null==e)for(;++u<i;)(t=+n[u])&&(r+=t);else for(;++u<i;)(t=+e(n[u],u,n))&&(r+=t);return r}function ge(){}function be(n,e){var t=new ge;if(n instanceof ge)n.each(function(n,e){t.set(e,n)});else if(Array.isArray(n)){var r,i=-1,u=n.length;if(null==e)for(;++i<u;)t.set(i,n[i]);else for(;++i<u;)t.set(e(r=n[i],i,n),r)}else if(n)for(var a in n)t.set(a,n[a]);return t}function pe(){function n(e,i,a,o){if(i>=u.length)return null!=r?r(e):null!=t?e.sort(t):e;for(var c,f,s,l=-1,h=e.length,d=u[i++],g=be(),b=a();++l<h;)(s=g.get(c=d(f=e[l])+""))?s.push(f):g.set(c,[f]);return g.each(function(e,t){o(b,t,n(e,i,a,o))}),b}function e(n,t){if(++t>u.length)return n;var i,o=a[t-1];return null!=r&&t>=u.length?i=n.entries():(i=[],n.each(function(n,r){i.push({key:r,values:e(n,t)})})),null!=o?i.sort(function(n,e){return o(n.key,e.key)}):i}var t,r,i,u=[],a=[];return i={object:function(e){return n(e,0,ye,ve)},map:function(e){return n(e,0,me,we)},entries:function(t){return e(n(t,0,me,we),0)},key:function(n){return u.push(n),i},sortKeys:function(n){return a[u.length-1]=n,i},sortValues:function(n){return t=n,i},rollup:function(n){return r=n,i}}}function ye(){return{}}function ve(n,e,t){n[e]=t}function me(){return be()}function we(n,e,t){n.set(e,t)}function Me(n){function e(e){var u=e+"",a=t.get(u);if(!a){if(i!==Pr)return i;t.set(u,a=r.push(e))}return n[(a-1)%n.length]}var t=be(),r=[],i=Pr;return n=null==n?[]:Or.call(n),e.domain=function(n){if(!arguments.length)return r.slice();r=[],t=be();for(var i,u,a=-1,o=n.length;++a<o;)t.has(u=(i=n[a])+"")||t.set(u,r.push(i));return e},e.range=function(t){return arguments.length?(n=Or.call(t),e):n.slice()},e.unknown=function(n){return arguments.length?(i=n,e):i},e.copy=function(){return Me().domain(r).range(n).unknown(i)},e}function _e(n,e,t){n.prototype=e.prototype=t,t.constructor=n}function Te(n,e){var t=Object.create(n.prototype);for(var r in e)t[r]=e[r];return t}function xe(){}function Ce(n){var e;return n=(n+"").trim().toLowerCase(),(e=$r.exec(n))?(e=parseInt(e[1],16),new Ne(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1)):(e=Ir.exec(n))?ke(parseInt(e[1],16)):(e=Xr.exec(n))?new Ne(e[1],e[2],e[3],1):(e=Rr.exec(n))?new Ne(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Zr.exec(n))?Se(e[1],e[2],e[3],e[4]):(e=Wr.exec(n))?Se(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Br.exec(n))?De(e[1],e[2]/100,e[3]/100,1):(e=Jr.exec(n))?De(e[1],e[2]/100,e[3]/100,e[4]):Vr.hasOwnProperty(n)?ke(Vr[n]):"transparent"===n?new Ne(NaN,NaN,NaN,0):null}function ke(n){return new Ne(n>>16&255,n>>8&255,255&n,1)}function Se(n,e,t,r){return r<=0&&(n=e=t=NaN),new Ne(n,e,t,r)}function Ue(n){return n instanceof xe||(n=Ce(n)),n?(n=n.rgb(),new Ne(n.r,n.g,n.b,n.opacity)):new Ne}function Ae(n,e,t,r){return 1===arguments.length?Ue(n):new Ne(n,e,t,null==r?1:r)}function Ne(n,e,t,r){this.r=+n,this.g=+e,this.b=+t,this.opacity=+r}function De(n,e,t,r){return r<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new Fe(n,e,t,r)}function Ee(n){if(n instanceof Fe)return new Fe(n.h,n.s,n.l,n.opacity);if(n instanceof xe||(n=Ce(n)),!n)return new Fe;if(n instanceof Fe)return n;n=n.rgb();var e=n.r/255,t=n.g/255,r=n.b/255,i=Math.min(e,t,r),u=Math.max(e,t,r),a=NaN,o=u-i,c=(u+i)/2;return o?(a=e===u?(t-r)/o+6*(t<r):t===u?(r-e)/o+2:(e-t)/o+4,o/=c<.5?u+i:2-u-i,a*=60):o=c>0&&c<1?0:a,new Fe(a,o,c,n.opacity)}function Le(n,e,t,r){return 1===arguments.length?Ee(n):new Fe(n,e,t,null==r?1:r)}function Fe(n,e,t,r){this.h=+n,this.s=+e,this.l=+t,this.opacity=+r}function He(n,e,t){return 255*(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)}function Ye(n){if(n instanceof Oe)return new Oe(n.l,n.a,n.b,n.opacity);if(n instanceof Re){var e=n.h*Gr;return new Oe(n.l,Math.cos(e)*n.c,Math.sin(e)*n.c,n.opacity)}n instanceof Ne||(n=Ue(n));var t=$e(n.r),r=$e(n.g),i=$e(n.b),u=Pe((.4124564*t+.3575761*r+.1804375*i)/ni),a=Pe((.2126729*t+.7151522*r+.072175*i)/ei),o=Pe((.0193339*t+.119192*r+.9503041*i)/ti);return new Oe(116*a-16,500*(u-a),200*(a-o),n.opacity)}function je(n,e,t,r){return 1===arguments.length?Ye(n):new Oe(n,e,t,null==r?1:r)}function Oe(n,e,t,r){this.l=+n,this.a=+e,this.b=+t,this.opacity=+r}function Pe(n){return n>ai?Math.pow(n,1/3):n/ui+ri}function qe(n){return n>ii?n*n*n:ui*(n-ri)}function ze(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function $e(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Ie(n){if(n instanceof Re)return new Re(n.h,n.c,n.l,n.opacity);n instanceof Oe||(n=Ye(n));var e=Math.atan2(n.b,n.a)*Kr;return new Re(e<0?e+360:e,Math.sqrt(n.a*n.a+n.b*n.b),n.l,n.opacity)}function Xe(n,e,t,r){return 1===arguments.length?Ie(n):new Re(n,e,t,null==r?1:r)}function Re(n,e,t,r){this.h=+n,this.c=+e,this.l=+t,this.opacity=+r}function Ze(n){if(n instanceof Be)return new Be(n.h,n.s,n.l,n.opacity);n instanceof Ne||(n=Ue(n));var e=n.r/255,t=n.g/255,r=n.b/255,i=(gi*r+hi*e-di*t)/(gi+hi-di),u=r-i,a=(li*(t-i)-fi*u)/si,o=Math.sqrt(a*a+u*u)/(li*i*(1-i)),c=o?Math.atan2(a,u)*Kr-120:NaN;return new Be(c<0?c+360:c,o,i,n.opacity)}function We(n,e,t,r){return 1===arguments.length?Ze(n):new Be(n,e,t,null==r?1:r)}function Be(n,e,t,r){this.h=+n,this.s=+e,this.l=+t,this.opacity=+r}function Je(n){return function(){return n}}function Ve(n,e){return function(t){return n+t*e}}function Ge(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(r){return Math.pow(n+r*e,t)}}function Ke(n,e){var t=e-n;return t?Ve(n,t>180||t<-180?t-360*Math.round(t/360):t):Je(isNaN(n)?e:n)}function Qe(n){return 1===(n=+n)?nt:function(e,t){return t-e?Ge(e,t,n):Je(isNaN(e)?t:e)}}function nt(n,e){var t=e-n;return t?Ve(n,t):Je(isNaN(n)?e:n)}function et(n,e){return n=+n,e-=n,function(t){return n+e*t}}function tt(n){return function e(t){function r(e,r){var i=n((e=We(e)).h,(r=We(r)).h),u=nt(e.s,r.s),a=nt(e.l,r.l),o=nt(e.opacity,r.opacity);return function(n){return e.h=i(n),e.s=u(n),e.l=a(Math.pow(n,t)),e.opacity=o(n),e+""}}return t=+t,r.gamma=e,r}(1)}function rt(n,e,t,r){function i(e){return n(e=new Date(+e)),e}return i.floor=i,i.ceil=function(t){return n(t=new Date(t-1)),e(t,1),n(t),t},i.round=function(n){var e=i(n),t=i.ceil(n);return n-e<t-n?e:t},i.offset=function(n,t){return e(n=new Date(+n),null==t?1:Math.floor(t)),n},i.range=function(t,r,u){var a=[];if(t=i.ceil(t),u=null==u?1:Math.floor(u),!(t<r&&u>0))return a;do a.push(new Date(+t));while(e(t,u),n(t),t<r);return a},i.filter=function(t){return rt(function(e){for(;n(e),!t(e);)e.setTime(e-1)},function(n,r){for(;--r>=0;)for(;e(n,1),!t(n););})},t&&(i.count=function(e,r){return pi.setTime(+e),yi.setTime(+r),n(pi),n(yi),Math.floor(t(pi,yi))},i.every=function(n){return n=Math.floor(n),isFinite(n)&&n>0?n>1?i.filter(r?function(e){return r(e)%n===0}:function(e){return i.count(0,e)%n===0}):i:null}),i}function it(n){return rt(function(e){e.setDate(e.getDate()-(e.getDay()+7-n)%7),e.setHours(0,0,0,0)},function(n,e){n.setDate(n.getDate()+7*e)},function(n,e){return(e-n-(e.getTimezoneOffset()-n.getTimezoneOffset())*wi)/Ti})}function ut(n){return rt(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-n)%7),e.setUTCHours(0,0,0,0)},function(n,e){n.setUTCDate(n.getUTCDate()+7*e)},function(n,e){return(e-n)/Ti})}function at(n){if(0<=n.y&&n.y<100){var e=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return e.setFullYear(n.y),e}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function ot(n){if(0<=n.y&&n.y<100){var e=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function ct(n){return{y:n,m:0,d:1,H:0,M:0,S:0,L:0}}function ft(n){function e(n,e){return function(t){var r,i,u,a=[],o=-1,c=0,f=n.length;for(t instanceof Date||(t=new Date(+t));++o<f;)37===n.charCodeAt(o)&&(a.push(n.slice(c,o)),null!=(i=ji[r=n.charAt(++o)])?r=n.charAt(++o):i="e"===r?" ":"0",(u=e[r])&&(r=u(t,i)),a.push(r),c=o+1);return a.push(n.slice(c,o)),a.join("")}}function t(n,e){return function(t){var i=ct(1900),u=r(i,n,t+="",0);if(u!=t.length)return null;if("p"in i&&(i.H=i.H%12+12*i.p),"W"in i||"U"in i){"w"in i||(i.w="W"in i?1:0);var a="Z"in i?ot(ct(i.y)).getUTCDay():e(ct(i.y)).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,ot(i)):e(i)}}function r(n,e,t,r){for(var i,u,a=0,o=e.length,c=t.length;a<o;){if(r>=c)return-1;if(i=e.charCodeAt(a++),37===i){if(i=e.charAt(a++),u=$[i in ji?e.charAt(a++):i],!u||(r=u(n,t,r))<0)return-1}else if(i!=t.charCodeAt(r++))return-1}return r}function i(n,e,t){var r=N.exec(e.slice(t));return r?(n.p=D[r[0].toLowerCase()],t+r[0].length):-1}function u(n,e,t){var r=F.exec(e.slice(t));return r?(n.w=H[r[0].toLowerCase()],t+r[0].length):-1}function a(n,e,t){var r=E.exec(e.slice(t));return r?(n.w=L[r[0].toLowerCase()],t+r[0].length):-1}function o(n,e,t){var r=O.exec(e.slice(t));return r?(n.m=P[r[0].toLowerCase()],t+r[0].length):-1}function c(n,e,t){var r=Y.exec(e.slice(t));return r?(n.m=j[r[0].toLowerCase()],t+r[0].length):-1}function f(n,e,t){return r(n,_,e,t)}function s(n,e,t){return r(n,T,e,t)}function l(n,e,t){return r(n,x,e,t)}function h(n){return S[n.getDay()]}function d(n){return k[n.getDay()]}function g(n){return A[n.getMonth()]}function b(n){return U[n.getMonth()]}function p(n){return C[+(n.getHours()>=12)]}function y(n){return S[n.getUTCDay()]}function v(n){return k[n.getUTCDay()]}function m(n){return A[n.getUTCMonth()]}function w(n){return U[n.getUTCMonth()]}function M(n){return C[+(n.getUTCHours()>=12)]}var _=n.dateTime,T=n.date,x=n.time,C=n.periods,k=n.days,S=n.shortDays,U=n.months,A=n.shortMonths,N=ht(C),D=dt(C),E=ht(k),L=dt(k),F=ht(S),H=dt(S),Y=ht(U),j=dt(U),O=ht(A),P=dt(A),q={a:h,A:d,b:g,B:b,c:null,d:Ut,e:Ut,H:At,I:Nt,j:Dt,L:Et,m:Lt,M:Ft,p:p,S:Ht,U:Yt,w:jt,W:Ot,x:null,X:null,y:Pt,Y:qt,Z:zt,"%":tr},z={a:y,A:v,b:m,B:w,c:null,d:$t,e:$t,H:It,I:Xt,j:Rt,L:Zt,m:Wt,M:Bt,p:M,S:Jt,U:Vt,w:Gt,W:Kt,x:null,X:null,y:Qt,Y:nr,Z:er,"%":tr},$={a:u,A:a,b:o,B:c,c:f,d:Mt,e:Mt,H:Tt,I:Tt,j:_t,L:kt,m:wt,M:xt,p:i,S:Ct,U:bt,w:gt,W:pt,x:s,X:l,y:vt,Y:yt,Z:mt,"%":St};return q.x=e(T,q),q.X=e(x,q),q.c=e(_,q),z.x=e(T,z),z.X=e(x,z),z.c=e(_,z),{format:function(n){var t=e(n+="",q);return t.toString=function(){return n},t},parse:function(n){var e=t(n+="",at);return e.toString=function(){return n},e},utcFormat:function(n){var t=e(n+="",z);return t.toString=function(){return n},t},utcParse:function(n){var e=t(n,ot);return e.toString=function(){return n},e}}}function st(n,e,t){var r=n<0?"-":"",i=(r?-n:n)+"",u=i.length;return r+(u<t?new Array(t-u+1).join(e)+i:i)}function lt(n){return n.replace(qi,"\\$&")}function ht(n){return new RegExp("^(?:"+n.map(lt).join("|")+")","i")}function dt(n){for(var e={},t=-1,r=n.length;++t<r;)e[n[t].toLowerCase()]=t;return e}function gt(n,e,t){var r=Oi.exec(e.slice(t,t+1));return r?(n.w=+r[0],t+r[0].length):-1}function bt(n,e,t){var r=Oi.exec(e.slice(t));return r?(n.U=+r[0],t+r[0].length):-1}function pt(n,e,t){var r=Oi.exec(e.slice(t));return r?(n.W=+r[0],t+r[0].length):-1}function yt(n,e,t){var r=Oi.exec(e.slice(t,t+4));return r?(n.y=+r[0],t+r[0].length):-1}function vt(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.y=+r[0]+(+r[0]>68?1900:2e3),t+r[0].length):-1}function mt(n,e,t){var r=/^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(e.slice(t,t+6));return r?(n.Z=r[1]?0:-(r[2]+(r[3]||"00")),t+r[0].length):-1}function wt(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.m=r[0]-1,t+r[0].length):-1}function Mt(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.d=+r[0],t+r[0].length):-1}function _t(n,e,t){var r=Oi.exec(e.slice(t,t+3));return r?(n.m=0,n.d=+r[0],t+r[0].length):-1}function Tt(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.H=+r[0],t+r[0].length):-1}function xt(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.M=+r[0],t+r[0].length):-1}function Ct(n,e,t){var r=Oi.exec(e.slice(t,t+2));return r?(n.S=+r[0],t+r[0].length):-1}function kt(n,e,t){var r=Oi.exec(e.slice(t,t+3));return r?(n.L=+r[0],t+r[0].length):-1}function St(n,e,t){var r=Pi.exec(e.slice(t,t+1));return r?t+r[0].length:-1}function Ut(n,e){return st(n.getDate(),e,2)}function At(n,e){return st(n.getHours(),e,2)}function Nt(n,e){return st(n.getHours()%12||12,e,2)}function Dt(n,e){return st(1+xi.count(Si(n),n),e,3)}function Et(n,e){return st(n.getMilliseconds(),e,3)}function Lt(n,e){return st(n.getMonth()+1,e,2)}function Ft(n,e){return st(n.getMinutes(),e,2)}function Ht(n,e){return st(n.getSeconds(),e,2)}function Yt(n,e){return st(Ci.count(Si(n),n),e,2)}function jt(n){return n.getDay()}function Ot(n,e){return st(ki.count(Si(n),n),e,2)}function Pt(n,e){return st(n.getFullYear()%100,e,2)}function qt(n,e){return st(n.getFullYear()%1e4,e,4)}function zt(n){var e=n.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+st(e/60|0,"0",2)+st(e%60,"0",2)}function $t(n,e){return st(n.getUTCDate(),e,2)}function It(n,e){return st(n.getUTCHours(),e,2)}function Xt(n,e){return st(n.getUTCHours()%12||12,e,2)}function Rt(n,e){return st(1+Ui.count(Di(n),n),e,3)}function Zt(n,e){return st(n.getUTCMilliseconds(),e,3)}function Wt(n,e){return st(n.getUTCMonth()+1,e,2)}function Bt(n,e){return st(n.getUTCMinutes(),e,2)}function Jt(n,e){return st(n.getUTCSeconds(),e,2)}function Vt(n,e){return st(Ai.count(Di(n),n),e,2)}function Gt(n){return n.getUTCDay()}function Kt(n,e){return st(Ni.count(Di(n),n),e,2)}function Qt(n,e){return st(n.getUTCFullYear()%100,e,2)}function nr(n,e){return st(n.getUTCFullYear()%1e4,e,4)}function er(){return"+0000"}function tr(){return"%"}function rr(n){return Ei=ft(n),Li=Ei.format,Fi=Ei.parse,Hi=Ei.utcFormat,Yi=Ei.utcParse,Ei}function ir(n){return n.toISOString()}function ur(n){var e=new Date(n);return isNaN(e)?null:e}function ar(n){return n.match(/.{6}/g).map(function(n){return"#"+n})}function or(n){var e=n.length;return function(t){return n[Math.max(0,Math.min(e-1,Math.floor(t*e)))]}}function cr(){function n(){d.forEach(function(n){n.sourceLinks=[],n.targetLinks=[]}),g.forEach(function(n){var e=n.source,t=n.target;"number"==typeof e&&(e=n.source=d[n.source]),"number"==typeof t&&(t=n.target=d[n.target]),e.sourceLinks.push(n),t.targetLinks.push(n)})}function e(){d.forEach(function(n){n.value=Math.max(de(n.sourceLinks,c),de(n.targetLinks,c))})}function t(){for(var n,e=d,t=0;e.length;)n=[],e.forEach(function(e){e.x=t,e.dx=s,e.sourceLinks.forEach(function(e){n.indexOf(e.target)<0&&n.push(e.target)})}),e=n,++t;r(t),i((h[0]-s)/(t-1))}function r(n){d.forEach(function(e){e.sourceLinks.length||(e.x=n-1)})}function i(n){d.forEach(function(e){e.x*=n})}function u(n){function e(){var n=he(a,function(n){return(h[1]-(n.length-1)*l)/de(n,c)});a.forEach(function(e){e.forEach(function(e,t){e.y=t,e.dy=e.value*n})}),g.forEach(function(e){
e.dy=e.value*n})}function t(n){function e(n){return o(n.source)*n.value}a.forEach(function(t){t.forEach(function(t){if(t.targetLinks.length){var r=de(t.targetLinks,e)/de(t.targetLinks,c);t.y+=(r-o(t))*n}})})}function r(n){function e(n){return o(n.target)*n.value}a.slice().reverse().forEach(function(t){t.forEach(function(t){if(t.sourceLinks.length){var r=de(t.sourceLinks,e)/de(t.sourceLinks,c);t.y+=(r-o(t))*n}})})}function i(){a.forEach(function(n){var e,t,r,i=0,a=n.length;for(n.sort(u),r=0;r<a;++r)e=n[r],t=i-e.y,t>0&&(e.y+=t),i=e.y+e.dy+l;if(t=i-l-h[1],t>0)for(i=e.y-=t,r=a-2;r>=0;--r)e=n[r],t=e.y+e.dy+l-i,t>0&&(e.y-=t),i=e.y})}function u(n,e){return n.y-e.y}var a=pe().key(function(n){return n.x}).sortKeys(fe).entries(d).map(function(n){return n.values});e(),i();for(var f=1;n>0;--n)r(f*=.99),i(),t(f),i()}function a(){function n(n,e){return n.source.y-e.source.y}function e(n,e){return n.target.y-e.target.y}d.forEach(function(t){t.sourceLinks.sort(e),t.targetLinks.sort(n)}),d.forEach(function(n){var e=0,t=0;n.sourceLinks.forEach(function(n){n.sy=e,e+=n.dy}),n.targetLinks.forEach(function(n){n.ty=t,t+=n.dy})})}function o(n){return n.y+n.dy/2}function c(n){return n.value}var f={},s=24,l=8,h=[1,1],d=[],g=[];return f.nodeWidth=function(n){return arguments.length?(s=+n,f):s},f.nodePadding=function(n){return arguments.length?(l=+n,f):l},f.nodes=function(n){return arguments.length?(d=n,f):d},f.links=function(n){return arguments.length?(g=n,f):g},f.size=function(n){return arguments.length?(h=n,f):h},f.layout=function(r){return n(),e(),t(),u(r),a(),f},f.relayout=function(){return a(),f},f.link=function(){function n(n){var t=n.source.x+n.source.dx,r=n.target.x,i=et(t,r),u=i(e),a=i(1-e),o=n.source.y+n.sy+n.dy/2,c=n.target.y+n.ty+n.dy/2;return"M"+t+","+o+"C"+u+","+o+" "+a+","+c+" "+r+","+c}var e=.5;return n.curvature=function(t){return arguments.length?(e=+t,n):e},n},f}function fr(e,t){function r(n){var e,t=s.status;if(!t&&lr(s)||t>=200&&t<300||304===t){if(a)try{e=a.call(i,s)}catch(n){return void c.call("error",i,n)}else e=s;c.call("load",i,e)}else c.call("error",i,n)}var i,u,a,o,c=n("beforesend","progress","load","error"),f=be(),s=new XMLHttpRequest,l=null,h=null,d=0;if("undefined"==typeof XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(e)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=s.ontimeout=r:s.onreadystatechange=function(n){s.readyState>3&&r(n)},s.onprogress=function(n){c.call("progress",i,n)},i={header:function(n,e){return n=(n+"").toLowerCase(),arguments.length<2?f.get(n):(null==e?f.remove(n):f.set(n,e+""),i)},mimeType:function(n){return arguments.length?(u=null==n?null:n+"",i):u},responseType:function(n){return arguments.length?(o=n,i):o},timeout:function(n){return arguments.length?(d=+n,i):d},user:function(n){return arguments.length<1?l:(l=null==n?null:n+"",i)},password:function(n){return arguments.length<1?h:(h=null==n?null:n+"",i)},response:function(n){return a=n,i},get:function(n,e){return i.send("GET",n,e)},post:function(n,e){return i.send("POST",n,e)},send:function(n,t,r){return s.open(n,e,!0,l,h),null==u||f.has("accept")||f.set("accept",u+",*/*"),s.setRequestHeader&&f.each(function(n,e){s.setRequestHeader(e,n)}),null!=u&&s.overrideMimeType&&s.overrideMimeType(u),null!=o&&(s.responseType=o),d>0&&(s.timeout=d),null==r&&"function"==typeof t&&(r=t,t=null),null!=r&&1===r.length&&(r=sr(r)),null!=r&&i.on("error",r).on("load",function(n){r(null,n)}),c.call("beforesend",i,s),s.send(null==t?null:t),i},abort:function(){return s.abort(),i},on:function(){var n=c.on.apply(c,arguments);return n===c?i:n}},null!=t){if("function"!=typeof t)throw new Error("invalid callback: "+t);return i.get(t)}return i}function sr(n){return function(e,t){n(null==e?t:null)}}function lr(n){var e=n.responseType;return e&&"text"!==e?n.response:n.responseText}function hr(n,e){return function(t,r){var i=fr(t).mimeType(n).response(e);if(null!=r){if("function"!=typeof r)throw new Error("invalid callback: "+r);return i.get(r)}return i}}function dr(n){return new Function("d","return {"+n.map(function(n,e){return JSON.stringify(n)+": d["+e+"]"}).join(",")+"}")}function gr(n,e){var t=dr(n);return function(r,i){return e(t(r),i,n)}}function br(n){var e=Object.create(null),t=[];return n.forEach(function(n){for(var r in n)r in e||t.push(e[r]=r)}),t}function pr(n){function e(n,e){var r,i,u=t(n,function(n,t){return r?r(n,t-1):(i=n,void(r=e?gr(n,e):dr(n)))});return u.columns=i,u}function t(n,e){function t(){if(s>=f)return a;if(i)return i=!1,u;var e,t=s;if(34===n.charCodeAt(t)){for(var r=t;r++<f;)if(34===n.charCodeAt(r)){if(34!==n.charCodeAt(r+1))break;++r}return s=r+2,e=n.charCodeAt(r+1),13===e?(i=!0,10===n.charCodeAt(r+2)&&++s):10===e&&(i=!0),n.slice(t+1,r).replace(/""/g,'"')}for(;s<f;){var o=1;if(e=n.charCodeAt(s++),10===e)i=!0;else if(13===e)i=!0,10===n.charCodeAt(s)&&(++s,++o);else if(e!==c)continue;return n.slice(t,s-o)}return n.slice(t)}for(var r,i,u={},a={},o=[],f=n.length,s=0,l=0;(r=t())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=t();e&&null==(h=e(h,l++))||o.push(h)}return o}function r(e,t){return null==t&&(t=br(e)),[t.map(a).join(n)].concat(e.map(function(e){return t.map(function(n){return a(e[n])}).join(n)})).join("\n")}function i(n){return n.map(u).join("\n")}function u(e){return e.map(a).join(n)}function a(n){return null==n?"":o.test(n+="")?'"'+n.replace(/\"/g,'""')+'"':n}var o=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return{parse:e,parseRows:t,format:r,formatRows:i}}var yr={value:function(){}};e.prototype=n.prototype={constructor:e,on:function(n,e){var u,a=this._,o=t(n+"",a),c=-1,f=o.length;{if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++c<f;)if(u=(n=o[c]).type)a[u]=i(a[u],n.name,e);else if(null==e)for(u in a)a[u]=i(a[u],n.name,null);return this}for(;++c<f;)if((u=(n=o[c]).type)&&(u=r(a[u],n.name)))return u}},copy:function(){var n={},t=this._;for(var r in t)n[r]=t[r].slice();return new e(n)},call:function(n,e){if((t=arguments.length-2)>0)for(var t,r,i=new Array(t),u=0;u<t;++u)i[u]=arguments[u+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(r=this._[n],u=0,t=r.length;u<t;++u)r[u].value.apply(e,i)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var r=this._[n],i=0,u=r.length;i<u;++i)r[i].value.apply(e,t)}};var vr="http://www.w3.org/1999/xhtml",mr={svg:"http://www.w3.org/2000/svg",xhtml:vr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},wr=function(n){return function(){return this.matches(n)}};if("undefined"!=typeof document){var Mr=document.documentElement;if(!Mr.matches){var _r=Mr.webkitMatchesSelector||Mr.msMatchesSelector||Mr.mozMatchesSelector||Mr.oMatchesSelector;wr=function(n){return function(){return _r.call(this,n)}}}}var Tr=wr,xr={},Cr=null;if("undefined"!=typeof document){var kr=document.documentElement;"onmouseenter"in kr||(xr={mouseenter:"mouseover",mouseleave:"mouseout"})}U.prototype={constructor:U,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,e){return this._parent.insertBefore(n,e)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};var Sr="$";fn.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};var Ur=[null];On.prototype=Pn.prototype={constructor:On,select:M,selectAll:x,filter:C,data:E,enter:S,exit:L,merge:F,order:H,sort:Y,call:O,nodes:P,node:q,size:z,empty:$,each:I,attr:V,style:en,property:an,classed:bn,text:mn,html:Tn,raise:Cn,lower:Sn,append:Un,insert:Nn,remove:En,datum:Ln,on:g,dispatch:jn},Wn.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};var Ar,Nr={"":ee,"%":function(n,e){return(100*n).toFixed(e)},b:function(n){return Math.round(n).toString(2)},c:function(n){return n+""},d:function(n){return Math.round(n).toString(10)},e:function(n,e){return n.toExponential(e)},f:function(n,e){return n.toFixed(e)},g:function(n,e){return n.toPrecision(e)},o:function(n){return Math.round(n).toString(8)},p:function(n,e){return re(100*n,e)},r:re,s:te,X:function(n){return Math.round(n).toString(16).toUpperCase()},x:function(n){return Math.round(n).toString(16)}},Dr=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;ue.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var Er,Lr,Fr,Hr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];ce({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var Yr=(se(fe),"$");ge.prototype=be.prototype={constructor:ge,has:function(n){return Yr+n in this},get:function(n){return this[Yr+n]},set:function(n,e){return this[Yr+n]=e,this},remove:function(n){var e=Yr+n;return e in this&&delete this[e]},clear:function(){for(var n in this)n[0]===Yr&&delete this[n]},keys:function(){var n=[];for(var e in this)e[0]===Yr&&n.push(e.slice(1));return n},values:function(){var n=[];for(var e in this)e[0]===Yr&&n.push(this[e]);return n},entries:function(){var n=[];for(var e in this)e[0]===Yr&&n.push({key:e.slice(1),value:this[e]});return n},size:function(){var n=0;for(var e in this)e[0]===Yr&&++n;return n},empty:function(){for(var n in this)if(n[0]===Yr)return!1;return!0},each:function(n){for(var e in this)e[0]===Yr&&n(this[e],e.slice(1),this)}};var jr=(be.prototype,Array.prototype),Or=jr.slice,Pr={name:"implicit"},qr=.7,zr=1/qr,$r=/^#([0-9a-f]{3})$/,Ir=/^#([0-9a-f]{6})$/,Xr=/^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,Rr=/^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,Zr=/^rgba\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/,Wr=/^rgba\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/,Br=/^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,Jr=/^hsla\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/,Vr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};_e(xe,Ce,{displayable:function(){return this.rgb().displayable()},toString:function(){return this.rgb()+""}}),_e(Ne,Ae,Te(xe,{brighter:function(n){return n=null==n?zr:Math.pow(zr,n),new Ne(this.r*n,this.g*n,this.b*n,this.opacity)},darker:function(n){return n=null==n?qr:Math.pow(qr,n),new Ne(this.r*n,this.g*n,this.b*n,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},toString:function(){var n=this.opacity;return n=isNaN(n)?1:Math.max(0,Math.min(1,n)),(1===n?"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===n?")":", "+n+")")}})),_e(Fe,Le,Te(xe,{brighter:function(n){return n=null==n?zr:Math.pow(zr,n),new Fe(this.h,this.s,this.l*n,this.opacity)},darker:function(n){return n=null==n?qr:Math.pow(qr,n),new Fe(this.h,this.s,this.l*n,this.opacity)},rgb:function(){var n=this.h%360+360*(this.h<0),e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,r=t+(t<.5?t:1-t)*e,i=2*t-r;return new Ne(He(n>=240?n-240:n+120,i,r),He(n,i,r),He(n<120?n+240:n-120,i,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}}));var Gr=Math.PI/180,Kr=180/Math.PI,Qr=18,ni=.95047,ei=1,ti=1.08883,ri=4/29,ii=6/29,ui=3*ii*ii,ai=ii*ii*ii;_e(Oe,je,Te(xe,{brighter:function(n){return new Oe(this.l+Qr*(null==n?1:n),this.a,this.b,this.opacity)},darker:function(n){return new Oe(this.l-Qr*(null==n?1:n),this.a,this.b,this.opacity)},rgb:function(){var n=(this.l+16)/116,e=isNaN(this.a)?n:n+this.a/500,t=isNaN(this.b)?n:n-this.b/200;return n=ei*qe(n),e=ni*qe(e),t=ti*qe(t),new Ne(ze(3.2404542*e-1.5371385*n-.4985314*t),ze(-.969266*e+1.8760108*n+.041556*t),ze(.0556434*e-.2040259*n+1.0572252*t),this.opacity)}})),_e(Re,Xe,Te(xe,{brighter:function(n){return new Re(this.h,this.c,this.l+Qr*(null==n?1:n),this.opacity)},darker:function(n){return new Re(this.h,this.c,this.l-Qr*(null==n?1:n),this.opacity)},rgb:function(){return Ye(this).rgb()}}));var oi=-.14861,ci=1.78277,fi=-.29227,si=-.90649,li=1.97294,hi=li*si,di=li*ci,gi=ci*fi-si*oi;_e(Be,We,Te(xe,{brighter:function(n){return n=null==n?zr:Math.pow(zr,n),new Be(this.h,this.s,this.l*n,this.opacity)},darker:function(n){return n=null==n?qr:Math.pow(qr,n),new Be(this.h,this.s,this.l*n,this.opacity)},rgb:function(){var n=isNaN(this.h)?0:(this.h+120)*Gr,e=+this.l,t=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(n),i=Math.sin(n);return new Ne(255*(e+t*(oi*r+ci*i)),255*(e+t*(fi*r+si*i)),255*(e+t*(li*r)),this.opacity)}})),function n(e){function t(n,e){var t=r((n=Ae(n)).r,(e=Ae(e)).r),i=r(n.g,e.g),u=r(n.b,e.b),a=r(n.opacity,e.opacity);return function(e){return n.r=t(e),n.g=i(e),n.b=u(e),n.opacity=a(e),n+""}}var r=Qe(e);return t.gamma=n,t}(1),tt(Ke);var bi=tt(nt),pi=new Date,yi=new Date,vi=rt(function(){},function(n,e){n.setTime(+n+e)},function(n,e){return e-n});vi.every=function(n){return n=Math.floor(n),isFinite(n)&&n>0?n>1?rt(function(e){e.setTime(Math.floor(e/n)*n)},function(e,t){e.setTime(+e+t*n)},function(e,t){return(t-e)/n}):vi:null};var mi=1e3,wi=6e4,Mi=36e5,_i=864e5,Ti=6048e5,xi=(rt(function(n){n.setTime(Math.floor(n/mi)*mi)},function(n,e){n.setTime(+n+e*mi)},function(n,e){return(e-n)/mi},function(n){return n.getUTCSeconds()}),rt(function(n){n.setTime(Math.floor(n/wi)*wi)},function(n,e){n.setTime(+n+e*wi)},function(n,e){return(e-n)/wi},function(n){return n.getMinutes()}),rt(function(n){var e=n.getTimezoneOffset()*wi%Mi;e<0&&(e+=Mi),n.setTime(Math.floor((+n-e)/Mi)*Mi+e)},function(n,e){n.setTime(+n+e*Mi)},function(n,e){return(e-n)/Mi},function(n){return n.getHours()}),rt(function(n){n.setHours(0,0,0,0)},function(n,e){n.setDate(n.getDate()+e)},function(n,e){return(e-n-(e.getTimezoneOffset()-n.getTimezoneOffset())*wi)/_i},function(n){return n.getDate()-1})),Ci=it(0),ki=it(1),Si=(rt(function(n){n.setDate(1),n.setHours(0,0,0,0)},function(n,e){n.setMonth(n.getMonth()+e)},function(n,e){return e.getMonth()-n.getMonth()+12*(e.getFullYear()-n.getFullYear())},function(n){return n.getMonth()}),rt(function(n){n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e)},function(n,e){return e.getFullYear()-n.getFullYear()},function(n){return n.getFullYear()}));Si.every=function(n){return isFinite(n=Math.floor(n))&&n>0?rt(function(e){e.setFullYear(Math.floor(e.getFullYear()/n)*n),e.setMonth(0,1),e.setHours(0,0,0,0)},function(e,t){e.setFullYear(e.getFullYear()+t*n)}):null};var Ui=(rt(function(n){n.setUTCSeconds(0,0)},function(n,e){n.setTime(+n+e*wi)},function(n,e){return(e-n)/wi},function(n){return n.getUTCMinutes()}),rt(function(n){n.setUTCMinutes(0,0,0)},function(n,e){n.setTime(+n+e*Mi)},function(n,e){return(e-n)/Mi},function(n){return n.getUTCHours()}),rt(function(n){n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCDate(n.getUTCDate()+e)},function(n,e){return(e-n)/_i},function(n){return n.getUTCDate()-1})),Ai=ut(0),Ni=ut(1),Di=(rt(function(n){n.setUTCDate(1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCMonth(n.getUTCMonth()+e)},function(n,e){return e.getUTCMonth()-n.getUTCMonth()+12*(e.getUTCFullYear()-n.getUTCFullYear())},function(n){return n.getUTCMonth()}),rt(function(n){n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e)},function(n,e){return e.getUTCFullYear()-n.getUTCFullYear()},function(n){return n.getUTCFullYear()}));Di.every=function(n){return isFinite(n=Math.floor(n))&&n>0?rt(function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/n)*n),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t*n)}):null};var Ei,Li,Fi,Hi,Yi,ji={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,Pi=/^%/,qi=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;rr({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"]});var zi="%Y-%m-%dT%H:%M:%S.%LZ";Date.prototype.toISOString?ir:Hi(zi),+new Date("2000-01-01T00:00:00.000Z")?ur:Yi(zi);ar("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),ar("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6"),ar("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9");var $i=ar("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5");bi(We(300,.5,0),We(-240,.5,1));bi(We(-100,.75,.35),We(80,1.5,.8)),bi(We(260,.75,.35),We(80,1.5,.8)),We();or(ar("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var Ii=(or(ar("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),or(ar("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),or(ar("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")),hr("application/json",function(n){return JSON.parse(n.responseText)})),Xi=(pr(","),pr("\t"),{format:Lr,scaleOrdinal:Me,schemeCategory20:$i,drag:Gn,select:qn,sankey:cr,json:Ii,rgb:Ae});return Xi});
{
"nodes": [{
"name": "Agricultural 'waste'"
}, {
"name": "Bio-conversion"
}, {
"name": "Liquid"
}, {
"name": "Losses"
}, {
"name": "Solid"
}, {
"name": "Gas"
}, {
"name": "Biofuel imports"
}, {
"name": "Biomass imports"
}, {
"name": "Coal imports"
}, {
"name": "Coal"
}, {
"name": "Coal reserves"
}, {
"name": "District heating"
}, {
"name": "Industry"
}, {
"name": "Heating and cooling - commercial"
}, {
"name": "Heating and cooling - homes"
}, {
"name": "Electricity grid"
}, {
"name": "Over generation / exports"
}, {
"name": "H2 conversion"
}, {
"name": "Road transport"
}, {
"name": "Agriculture"
}, {
"name": "Rail transport"
}, {
"name": "Lighting & appliances - commercial"
}, {
"name": "Lighting & appliances - homes"
}, {
"name": "Gas imports"
}, {
"name": "Ngas"
}, {
"name": "Gas reserves"
}, {
"name": "Thermal generation"
}, {
"name": "Geothermal"
}, {
"name": "H2"
}, {
"name": "Hydro"
}, {
"name": "International shipping"
}, {
"name": "Domestic aviation"
}, {
"name": "International aviation"
}, {
"name": "National navigation"
}, {
"name": "Marine algae"
}, {
"name": "Nuclear"
}, {
"name": "Oil imports"
}, {
"name": "Oil"
}, {
"name": "Oil reserves"
}, {
"name": "Other waste"
}, {
"name": "Pumped heat"
}, {
"name": "Solar PV"
}, {
"name": "Solar Thermal"
}, {
"name": "Solar"
}, {
"name": "Tidal"
}, {
"name": "UK land based bioenergy"
}, {
"name": "Wave"
}, {
"name": "Wind"
}],
"links": [{
"source": 0,
"target": 1,
"value": 124.729
}, {
"source": 1,
"target": 2,
"value": 0.597
}, {
"source": 1,
"target": 3,
"value": 26.862
}, {
"source": 1,
"target": 4,
"value": 280.322
}, {
"source": 1,
"target": 5,
"value": 81.144
}, {
"source": 6,
"target": 2,
"value": 35
}, {
"source": 7,
"target": 4,
"value": 35
}, {
"source": 8,
"target": 9,
"value": 11.606
}, {
"source": 10,
"target": 9,
"value": 63.965
}, {
"source": 9,
"target": 4,
"value": 75.571
}, {
"source": 11,
"target": 12,
"value": 10.639
}, {
"source": 11,
"target": 13,
"value": 22.505
}, {
"source": 11,
"target": 14,
"value": 46.184
}, {
"source": 15,
"target": 16,
"value": 104.453
}, {
"source": 15,
"target": 14,
"value": 113.726
}, {
"source": 15,
"target": 17,
"value": 27.14
}, {
"source": 15,
"target": 12,
"value": 342.165
}, {
"source": 15,
"target": 18,
"value": 37.797
}, {
"source": 15,
"target": 19,
"value": 4.412
}, {
"source": 15,
"target": 13,
"value": 40.858
}, {
"source": 15,
"target": 3,
"value": 56.691
}, {
"source": 15,
"target": 20,
"value": 7.863
}, {
"source": 15,
"target": 21,
"value": 90.008
}, {
"source": 15,
"target": 22,
"value": 93.494
}, {
"source": 23,
"target": 24,
"value": 40.719
}, {
"source": 25,
"target": 24,
"value": 82.233
}, {
"source": 5,
"target": 13,
"value": 0.129
}, {
"source": 5,
"target": 3,
"value": 1.401
}, {
"source": 5,
"target": 26,
"value": 151.891
}, {
"source": 5,
"target": 19,
"value": 2.096
}, {
"source": 5,
"target": 12,
"value": 48.58
}, {
"source": 27,
"target": 15,
"value": 7.013
}, {
"source": 17,
"target": 28,
"value": 20.897
}, {
"source": 17,
"target": 3,
"value": 6.242
}, {
"source": 28,
"target": 18,
"value": 20.897
}, {
"source": 29,
"target": 15,
"value": 6.995
}, {
"source": 2,
"target": 12,
"value": 121.066
}, {
"source": 2,
"target": 30,
"value": 128.69
}, {
"source": 2,
"target": 18,
"value": 135.835
}, {
"source": 2,
"target": 31,
"value": 14.458
}, {
"source": 2,
"target": 32,
"value": 206.267
}, {
"source": 2,
"target": 19,
"value": 3.64
}, {
"source": 2,
"target": 33,
"value": 33.218
}, {
"source": 2,
"target": 20,
"value": 4.413
}, {
"source": 34,
"target": 1,
"value": 4.375
}, {
"source": 24,
"target": 5,
"value": 122.952
}, {
"source": 35,
"target": 26,
"value": 839.978
}, {
"source": 36,
"target": 37,
"value": 504.287
}, {
"source": 38,
"target": 37,
"value": 107.703
}, {
"source": 37,
"target": 2,
"value": 611.99
}, {
"source": 39,
"target": 4,
"value": 56.587
}, {
"source": 39,
"target": 1,
"value": 77.81
}, {
"source": 40,
"target": 14,
"value": 193.026
}, {
"source": 40,
"target": 13,
"value": 70.672
}, {
"source": 41,
"target": 15,
"value": 59.901
}, {
"source": 42,
"target": 14,
"value": 19.263
}, {
"source": 43,
"target": 42,
"value": 19.263
}, {
"source": 43,
"target": 41,
"value": 59.901
}, {
"source": 4,
"target": 19,
"value": 0.882
}, {
"source": 4,
"target": 26,
"value": 400.12
}, {
"source": 4,
"target": 12,
"value": 46.477
}, {
"source": 26,
"target": 15,
"value": 525.531
}, {
"source": 26,
"target": 3,
"value": 787.129
}, {
"source": 26,
"target": 11,
"value": 79.329
}, {
"source": 44,
"target": 15,
"value": 9.452
}, {
"source": 45,
"target": 1,
"value": 182.01
}, {
"source": 46,
"target": 15,
"value": 19.013
}, {
"source": 47,
"target": 15,
"value": 289.366
}]
}
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Sankey Diagram</title>
<style>
#chart {
height: 500px;
}
.node rect {
cursor: move;
fill-opacity: .9;
shape-rendering: crispEdges;
}
.node text {
pointer-events: none;
text-shadow: 0 1px 0 #fff;
}
.link {
fill: none;
stroke: #000;
stroke-opacity: .2;
}
.link:hover {
stroke-opacity: .5;
}
</style>
<body>
<div id="chart"></div>
<script src="d3.min.js"></script>
<script>
var margin = {
top: 1,
right: 1,
bottom: 6,
left: 1
},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var formatNumber = d3.format(",.0f"),
format = function(d) {
return formatNumber(d) + " TWh";
},
color = d3.scaleOrdinal(d3.schemeCategory20);
var svg = d3.select("#chart").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var sankey = d3.sankey()
.nodeWidth(15)
.nodePadding(10)
.size([width, height]);
var path = sankey.link();
d3.json("energy.json", function(energy) {
sankey
.nodes(energy.nodes)
.links(energy.links)
.layout(32);
var link = svg.append("g").selectAll(".link")
.data(energy.links)
.enter().append("path")
.attr("class", "link")
.attr("d", path)
.style("stroke-width", function(d) {
return Math.max(1, d.dy);
})
.sort(function(a, b) {
return b.dy - a.dy;
});
link.append("title")
.text(function(d) {
return d.source.name + " → " + d.target.name + "\n" + format(d.value);
});
var node = svg.append("g").selectAll(".node")
.data(energy.nodes)
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
})
.call(d3.drag()
.subject(function(d) {
return d;
})
.on("start", function() {
this.parentNode.appendChild(this);
})
.on("drag", dragmove));
node.append("rect")
.attr("height", function(d) {
return d.dy;
})
.attr("width", sankey.nodeWidth())
.style("fill", function(d) {
return d.color = color(d.name.replace(/ .*/, ""));
})
.style("stroke", function(d) {
return d3.rgb(d.color).darker(2);
})
.append("title")
.text(function(d) {
return d.name + "\n" + format(d.value);
});
node.append("text")
.attr("x", -6)
.attr("y", function(d) {
return d.dy / 2;
})
.attr("dy", ".35em")
.attr("text-anchor", "end")
.attr("transform", null)
.text(function(d) {
return d.name;
})
.filter(function(d) {
return d.x < width / 2;
})
.attr("x", 6 + sankey.nodeWidth())
.attr("text-anchor", "start");
function dragmove(d) {
d3.select(this).attr("transform", "translate(" + d.x + "," + (d.y = Math.max(0, Math.min(height - d.dy, d3.event.y))) + ")");
sankey.relayout();
link.attr("d", path);
}
});
</script>
{
"private": true,
"scripts": {
"build": "rollup -c | uglifyjs -c -m > d3.min.js"
},
"dependencies": {
"d3-array": "^1.0.1",
"d3-color": "^1.0.1",
"d3-drag": "^1.0.1",
"d3-format": "^1.0.2",
"d3-request": "^1.0.2",
"d3-sankey": "^0.4.1",
"d3-scale": "^1.0.3",
"d3-selection": "^1.0.2",
"rollup": "^0.34.13",
"rollup-plugin-node-resolve": "^2.0.0",
"uglify-js": "^2.6.1"
}
}
import nodeResolve from "rollup-plugin-node-resolve";
export default {
entry: "d3.js",
plugins: [nodeResolve({jsnext: true})],
moduleId: "d3",
moduleName: "d3",
format: "umd"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment