-
Notifications
You must be signed in to change notification settings - Fork 1
/
component---src-pages-stories-last-7-days-js-dabd975d866c39a07891.js
1 lines (1 loc) · 7.44 KB
/
component---src-pages-stories-last-7-days-js-dabd975d866c39a07891.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{ImBV:function(t,e,r){"use strict";r.r(e);var a=r("q1tI"),n=r.n(a),o=r("7t3Y"),i=r("7xaS"),s=r("9Koi"),c=r("ofer"),l=r("hob0"),u=r("osgK"),f=r.n(u);e.default=function(t){var e=t.data,r=(t.location,Object(s.a)().t),a=function(t){var e=t.node,r=Object.assign({},e);return Object.keys(r).forEach((function(t){isNaN(parseInt(r[t],0))||(r[t]=parseInt(r[t],0))})),r},u=e.last7days.edges.map(a).reverse(),d=e.last7days.edges.map(a).reverse().map((function(t,e){return e<7?{confirmed:0}:{confirmed:t.confirmed-u[e-7].confirmed}}));return n.a.createElement(i.a,{noPadding:!0},n.a.createElement(o.a,{title:"Charts"}),n.a.createElement(c.a,{variant:"h2"},r("charts.title")),n.a.createElement(l.a,{data:{xaxis:e.last7days.edges.map((function(t){return t.node.date})).reverse(),fields:["confirmed"],datasets:[{line:{legend:"過往十四日",color:"#bcff4c","stroke-dasharray":"5, 5"},data:e.last14days.edges.map((function(t){var e=t.node,r=Object.assign({},e);return Object.keys(r).forEach((function(t){isNaN(parseInt(r[t],0))||(r[t]=2*parseInt(r[t],0))})),r})).concat(f()(7,(function(t){return{confirmed:"0"}}))).reverse()},{line:{legend:"過往十四日",color:"#ffbc4c","stroke-dasharray":"5, 2"},data:d},{line:{legend:"過往十四日",color:"#ff574f"},data:e.last7days.edges.map(a).reverse()}]}}))}},hob0:function(t,e,r){"use strict";var a=r("q1tI"),n=r.n(a),o=r("VphZ"),i=r("w1NJ"),s=r.n(i),c=r("osgK"),l=r.n(c),u=function(t){return Math.max(2*t/3,300)};e.a=function(t){var e=Object(a.useState)({width:0,height:0}),r=e[0],i=e[1],c=Object(a.useRef)(null),f=function(t,e){if(0!==r.width){var a=20,n=10,i=50,f=35,d=r.width-f-n,p=u(r.width)-a-i,y=d<500?7:3,h=1.1*Math.max(s()(t.datasets.map((function(e){return s()(e.data.map((function(e){return s()(Object.keys(e).filter((function(e){return t.fields.indexOf(e)>=0})).map((function(t){return e[t]})))})))}))),s()(t.horizontalLines.map((function(t){return t.value})))),m=o.select(c.current).attr("width",d+f+n).attr("height",p+a+i);m.selectAll("g").remove();var g=m.append("g").attr("transform","translate("+f+", "+a+")"),v=o.scaleLinear().range([p,0]).domain([0,h]),x=o.scalePoint().range([0,d]).domain(l()(t.xaxis.length));g.append("g").call(o.axisLeft(v)),g.append("g").attr("transform","translate(0, "+p+")").call(o.axisBottom(x).tickValues(x.domain().filter((function(t,e){return e%y==0}))).tickFormat((function(e,r){return t.xaxis[r*y]}))).selectAll("text").attr("transform","rotate(-45)translate(0,0)").style("text-anchor","end").style("fill","#69a3b2"),g.append("g").style("color","lightgrey").style("stroke-opacity","0.7").call(o.axisLeft(v).tickSizeOuter(0).tickSizeInner(-d).tickFormat("")),t.horizontalLines.forEach((function(t,e){m.append("line").attr("x1",f).attr("y1",a+v(t.value)).attr("x2",f+d).attr("y2",a+v(t.value)).style("stroke",t.color).attr("stroke-dasharray",t["stroke-dasharray"]),m.append("text").attr("width",100).attr("x",f+d).attr("y",a+v(t.value)-4).style("text-anchor","end").attr("fill",t.color).text(t.legend)}));var b=o.line().x((function(t,e){return x(e)})).y((function(t){return v(t)}));if(t.datasets.forEach((function(e,r){return n=e.data.map((function(e){return Object.keys(e).filter((function(e){return t.fields.indexOf(e)===r})).map((function(t){return e[t]}))})),o=e.line,i=n.filter((function(t){return null!==t})),s=1500+2e3*Math.random(),m.append("path").attr("transform","translate("+f+", "+a+")").datum(i).attr("fill","none").attr("stroke",o.color).attr("stroke-width",1.5).attr("opacity",o.opactiy||1).attr("stroke-dashoffset",2*d).attr("stroke-dasharray",[2*d,2*d]).attr("d",b).transition().duration(s).attr("stroke-dashoffset",0).transition().duration(0).attr("stroke-dasharray",o["stroke-dasharray"]),void m.append("g").selectAll(".dot").data(i).enter().append("circle").attr("fill",o.color).attr("class","dot").attr("transform","translate("+f+", "+a+")").attr("cx",(function(t,e){return x(e)})).attr("cy",(function(t){return v(t)})).attr("r",2).attr("opacity",0).transition().delay(s-500).duration(2e3).attr("opacity",o.opactiy||1);var n,o,i,s})),t.showLegend){var k=m.selectAll(".legend").data(t.datasets).enter().append("g").attr("class","legend").attr("transform",(function(t,e){return"translate("+(f+20)+", "+(a+24*e)+")"}));k.append("rect").attr("width",14).attr("height",14).style("fill",(function(t,e){return t.line.color})),k.append("text").attr("x",16).attr("y",7).attr("dy",".35em").style("text-anchor","start").style("fill",(function(t,e){return t.line.color})).text((function(t){return t.line.legend}))}var w=m.append("g").attr("display","none").attr("class","tooltip");w.append("rect").attr("fill","#fff").attr("stroke","#000").attr("width",100).attr("height",50).attr("x",0).attr("y",0).attr("rx",4).attr("ry",4),w.append("text").attr("class","title").attr("width",100).attr("height",35).attr("dy",".35em").attr("font-size",14).attr("x",4).attr("y",12).text("date"),w.selectAll(".legend").data(t.datasets).enter().append("text").attr("class","figures").attr("width",100).attr("height",35).attr("dy",".35em").attr("font-size",12).style("text-anchor","start");var j=m.append("line"),O=m.append("rect").attr("width",d).attr("height",p).attr("x",f).attr("y",a).attr("opacity",0).on("mousemove",E).on("mouseout",(function(){w&&w.attr("display","none");j&&j.attr("stroke","none")})).on("mouseclick",E)}function E(){var e=x.step(),r=o.mouse(O.node());r[0]-=f,r[1]-=a;var n=Math.max(Math.round(r[0]/e),0);j.attr("stroke","black").attr("stroke-dasharray","5, 2").attr("x1",f+x(n)).attr("x2",f+x(n)).attr("y1",a+0).attr("y2",a+p);var i=f+x(n)+20;i=i>d-100?i-100-40:i,w.attr("display","block").attr("transform","translate("+i+", "+Math.min(p-100,a+r[1]-20)+")").selectAll(".figures").attr("x",4).attr("y",(function(t,e){return 35+16*e})).attr("fill",(function(t){return t.line.color})).text((function(e,r){return e.line.legend+": "+e.data[n][t.fields[r]]})),w.select(".title").text(t.xaxis[n])}};return Object(a.useEffect)((function(){f(t.data,t.labels)})),Object(a.useLayoutEffect)((function(){c.current&&i({width:c.current.clientWidth})}),[]),n.a.createElement(n.a.Fragment,null,n.a.createElement("svg",{ref:c,style:{height:u(r.width),width:"100%"}}))}},osgK:function(t,e){var r=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt;var s=Object.prototype.toString,c=Math.min;function l(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function u(t){return t?(t=function(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==s.call(t)}(t))return NaN;if(l(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=l(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(r,"");var c=n.test(t);return c||o.test(t)?i(t.slice(2),c?2:8):a.test(t)?NaN:+t}(t))===1/0||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function f(t){return t}t.exports=function(t,e){if((t=function(t){var e=u(t),r=e%1;return e==e?r?e-r:e:0}(t))<1||t>9007199254740991)return[];var r=4294967295,a=c(t,4294967295);t-=4294967295;for(var n=function(t,e){for(var r=-1,a=Array(t);++r<t;)a[r]=e(r);return a}(a,e="function"==typeof e?e:f);++r<t;)e(r);return n}},w1NJ:function(t,e){var r=Object.prototype.toString;function a(t,e){return t>e}function n(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==r.call(t)}function o(t){return t}t.exports=function(t){return t&&t.length?function(t,e,r){for(var a=-1,o=t.length;++a<o;){var i=t[a],s=e(i);if(null!=s&&(void 0===c?s==s&&!n(s):r(s,c)))var c=s,l=i}return l}(t,o,a):void 0}}}]);