-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
executable file
·1 lines (1 loc) · 10.5 KB
/
Copy pathbundle.js
File metadata and controls
executable file
·1 lines (1 loc) · 10.5 KB
1
!function(t){function e(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function a(){var t=p.node().offsetWidth;y!==t&&(y=t,l.default.resize(),d.default.resize())}var i=n(1),o=r(i),u=n(3),c=r(u),s=n(4),l=r(s),f=n(5),d=r(f),p=d3.select("body"),y=0;!function(){p.classed("is-mobile",c.default.any()),window.addEventListener("resize",(0,o.default)(a,150)),l.default.init(),d.default.init()}()},function(t,e,n){(function(e){function n(t,e,n){function a(e){var n=v,r=g;return v=g=void 0,A=e,m=t.apply(r,n)}function i(t){return A=t,b=setTimeout(l,e),T?a(t):m}function c(t){var n=t-w,r=t-A,a=e-n;return D?_(a,h-r):a}function s(t){var n=t-w,r=t-A;return void 0===w||n>=e||n<0||D&&r>=h}function l(){var t=x();if(s(t))return f(t);b=setTimeout(l,c(t))}function f(t){return b=void 0,j&&v?a(t):(v=g=void 0,m)}function d(){void 0!==b&&clearTimeout(b),A=0,v=w=g=b=void 0}function p(){return void 0===b?m:f(x())}function y(){var t=x(),n=s(t);if(v=arguments,g=this,w=t,n){if(void 0===b)return i(w);if(D)return b=setTimeout(l,e),a(w)}return void 0===b&&(b=setTimeout(l,e)),m}var v,g,h,m,b,w,A=0,T=!1,D=!1,j=!0;if("function"!=typeof t)throw new TypeError(u);return e=o(e)||0,r(n)&&(T=!!n.leading,D="maxWait"in n,h=D?k(o(n.maxWait)||0,e):h,j="trailing"in n?!!n.trailing:j),y.cancel=d,y.flush=p,y}function r(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function a(t){return!!t&&"object"==typeof t}function i(t){return"symbol"==typeof t||a(t)&&b.call(t)==s}function o(t){if("number"==typeof t)return t;if(i(t))return c;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(l,"");var n=d.test(t);return n||p.test(t)?y(t.slice(2),n?2:8):f.test(t)?c:+t}var u="Expected a function",c=NaN,s="[object Symbol]",l=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,p=/^0o[0-7]+$/i,y=parseInt,v="object"==typeof e&&e&&e.Object===Object&&e,g="object"==typeof self&&self&&self.Object===Object&&self,h=v||g||Function("return this")(),m=Object.prototype,b=m.toString,k=Math.max,_=Math.min,x=function(){return h.Date.now()};t.exports=n}).call(e,n(2))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={android:function(){return navigator.userAgent.match(/Android/i)},blackberry:function(){return navigator.userAgent.match(/BlackBerry/i)},ios:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},opera:function(){return navigator.userAgent.match(/Opera Mini/i)},windows:function(){return navigator.userAgent.match(/IEMobile/i)},any:function(){return r.android()||r.blackberry()||r.ios()||r.opera()||r.windows()}};e.default=r},function(t,e,n){"use strict";function r(){g=d3.nest().key(function(t){return t.state}).sortKeys(d3.ascending).key(function(t){return t.day}).entries(v),b=d3.nest().key(function(t){return t.day}).entries(m)}function a(){y.append("select").selectAll("option").data(g).enter().append("option").attr("value",function(t){return t.key}).text(function(t){return t.key}).property("selected",function(t){return t.key==x});y.on("change",function(){x=d3.select(this).select("select").property("value"),h=g.filter(function(t){return t.key==x}),o()})}function i(){var t=d.selectAll(".graphic-day").data(b).enter().append("div.graphic-day");t.append("p.day-name").text(function(t){return"Thursday"==t.key?"Thanksgiving":t.key}),t.append("ul.day-list").selectAll(".day-list--item").data(function(t){return t.values}).enter().append("li.day-list--item").text(function(t){return t.gconcept_best}),h=g.filter(function(t){return t.key==x}),k=p.selectAll(".graphic-day").data(h[0].values).enter().append("div.graphic-day"),k.append("p.day-name").text(function(t){return"Thursday"==t.key?"Thanksgiving":t.key}),_=k.selectAll(".day-list").data(function(t){return[t]}).enter().append("ul.day-list"),o()}function o(){k.data(h[0].values),_.data(function(t){return[t]});var t=_.selectAll(".day-list--item").data(function(t){return t.values}),e=t.enter().append("li.day-list--item");t.exit().remove(),e.merge(t).text(function(t){return t.gconcept_best})}function u(){}function c(t){return t.map(function(t,e){return l({},t,{rank:+t.rank})})}function s(){return new Promise(function(t){d3.loadData("assets/data/states.csv","assets/data/national.csv",function(t,e){v=c(e[0]),m=c(e[1]),r(),a(),i()})})}Object.defineProperty(e,"__esModule",{value:!0});var l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f=d3.select("section#search"),d=f.selectAll("figure.fig__national"),p=f.selectAll("figure.fig__state"),y=f.selectAll(".stateGraphic__ui"),v=null,g=null,h=null,m=null,b=null,k=null,_=null,x="New York";e.default={init:s,resize:u}},function(t,e,n){"use strict";function r(t){return t.map(function(t){return k({},t,{Day:+t.Day,Hour:+t.Hour,scaled:+t.scaled})})}function a(t){d3.loadData("assets/data/traffic.csv","assets/data/bestWorstTraffic.csv",function(e,n){_={traffic:r(n[0]),bestWorstTraffic:n[1]},t()})}function i(t,e){return"translate("+t+", "+e+")"}function o(){x=_.traffic,w=_.bestWorstTraffic,A=d3.nest().key(function(t){return t.Metro}).sortKeys(d3.ascending).rollup(function(t){return{day:d3.nest().key(function(t){return t.Day}).entries(t)}}).entries(x),T=d3.nest().key(function(t){return t.Metro}).sortKeys(d3.ascending).rollup(function(t){return{when:d3.nest().key(function(t){return t.When}).entries(t)}}).entries(w)}function u(){q.attr("data-text",function(){return"When to Avoid "+D+" Traffic During the Thanksgiving Holiday"}).attr("href",function(){return"https://twitter.com/intent/tweet?text=When%20"+D+"%20Traffic%20is%20Worse%20Than%20Normal%20During%20the%20Thanksgiving%20Holiday%20pic.twitter.com%2F"+C+"&via=GoogleTrends&url=https://googletrends.github.io/mappingthanksgiving/"}).attr("data-img",function(){return C});R.select(".metroGraphic__ui").append("div").attr("class","ui__item ui__item--dropdown dropdown__metro"),R.select(".dayGraphic__ui").append("div").attr("class","ui__item ui__item--dropdown dropdown__day")}function c(){var t=R.select(".dropdown__metro"),e=t.append("select"),n=R.select(".dropdown__day"),r=n.append("select");e.selectAll("option").data(A).enter().append("option").attr("value",function(t){return t.key}).property("selected",function(t){return t.key==D}).text(function(t){return t.key}),e.on("change",function(){D=this.value,l(D)}),R.select("#daytime__checkbox").on("change",function(){l(D)});var a=d3.map(V,function(t){return t.number});console.log({mappedDays:a,nestedTraffic:A}),r.data(A).selectAll("option").data(function(t){return t.value.day}).enter().append("option").attr("value",function(t){return+t.key}).property("selected",function(t){return t.key==j}).text(function(t){return a.get(+t.key).day}),r.on("change",function(){j=+this.value,l(j)})}function s(t,e){var n=T.filter(function(t){return t.key===D}),r=n[0].value.when[t].values,a=d3.select("#daytime__checkbox").property("checked");return"b"===e?r.filter(function(t){return 1==a?"TRUE"==t.Daylight:"FALSE"==t.Daylight}):r.filter(function(t){return"w"==t.Rank})}function l(t){var e=(T.filter(function(t){return t.key===D}),A.filter(function(t){return t.key===D})),n=e[0].value.day.filter(function(t){return+t.key===j});O=n;var r=s(0,"b"),a=(R.select("#bestBefore").data(r).text(function(t){return t.Day+" "+t.Hour}),s(0,"w")),i=(R.select("#worstBefore").data(a).text(function(t){return t.Day+" "+t.Hour}),s(1,"b")),o=(R.select("#bestAfter").data(i).text(function(t){return t.Day+" "+t.Hour}),s(1,"w"));R.select("#worstAfter").data(o).text(function(t){return t.Day+" "+t.Hour}),R.select("#selectedMetro").text(D);p(),g()}function f(){var t=Y.append("g").attr("class","g-plot"),e=t.append("g").attr("class","g-axis");e.append("g").attr("class","axis axis--x");t.append("g").attr("class","g-sparkline"),t.append("g").attr("class","g-labels"),t.append("g").attr("class","g-axisLabels")}function d(){var t=Y.append("defs"),e=t.append("linearGradient").attr("id","svgGradient").attr("x1","0%").attr("x2","0%").attr("y1","0%").attr("y2","100%");e.append("stop").attr("class","start").attr("offset","0%").attr("stop-color",W).attr("stop-opacity",1),e.append("stop").attr("class","end").attr("offset","100%").attr("stop-color",H).attr("stop-opacity",1)}function p(){z=U.node().offsetWidth,F=window.innerHeight,M=z<600,E=M?10:11,P=8*E,$=2.5*E,N={top:E,left:M?50:100,bottom:2*E,right:M?50:100},G=z,B=P+(N.bottom+N.top)}function y(){var t=G-N.left-N.right;N.top,N.bottom;L.range([P,0]).domain([0,100]),S.range([0,t]).domain([0,23])}function v(){var t=U.selectAll(".g-axis"),e=[0,6,12,18,23],n=d3.axisBottom(S).tickValues(e).tickSize(B-2.5*E).tickFormat(function(t){return{0:"midnight",6:"6 AM",12:"noon",18:"6 PM",23:"11 PM"}[t]});t.select(".axis--x").call(n)}function g(){Y.attr("width",G).attr("height",B);var t=Y.select(".g-plot");t.attr("transform",i(N.left,N.top)),K.x(function(t){return S(t.Hour)}).y(function(t){return L(t.scaled)});var e=t.select(".g-sparkline"),n=e.selectAll(".sparkline__traffic").data(O),r=n.enter().append("path").attr("class","sparkline__traffic").attr("stroke","url(#svgGradient)");n.exit().remove(),r.merge(n).transition().duration(500).attr("d",function(t){return K(t.values)})}function h(){p(),y(),v(),g()}function m(){o(),u(),c(),l(D),f(),d(),h()}function b(){a(m)}Object.defineProperty(e,"__esModule",{value:!0});var k=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_={},x=null,w=null,A=null,T=null,D="New York",j=4,O=null,M=null,P=null,W="#F15822",H="#DDDDDD",z=0,F=0,G=0,B=0,E=12,S=d3.scaleLinear(),L=d3.scaleLinear(),N=null,$=null,K=d3.line(),I=d3.select("body"),R=I.select("#traffic"),U=R.select(".graphic__chart"),Y=U.select("svg"),q=R.select(".graphic__traffic").select(".tweet__button"),C="qCUdkzzPfT",V=[{number:1,day:"Tuesday"},{number:2,day:"Wednesday"},{number:3,day:"Thanksgiving"},{number:4,day:"Black Friday"},{number:5,day:"Saturday"},{number:6,day:"Sunday"},{number:7,day:"Monday"}];e.default={init:b,resize:h}}]);