auspice
Version:
Web app for visualizing pathogen evolution
2 lines • 13.9 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{470:function(t,e,n){var r=n(471);"string"==typeof r&&(r=[[t.i,r,""]]);n(56)(r,{});r.locals&&(t.exports=r.locals)},471:function(t,e,n){(t.exports=n(55)(!1)).push([t.i,'\n/* Variables - keep in sync with globalStyles.js*/\n:root {\n --darkGrey: #333;\n --medGrey: #888;\n}\n\n#d3entropy .overlay {\n fill: none;\n pointer-events: all;\n}\n\n#d3entropy .brush {\n stroke: none;\n}\n\n#d3entropy .niceText {\n font-family: "Lato";\n font-size: 14px;\n font-style: italic;\n color: var(--medGrey);\n}\n\n.brush .selection {\n cursor: grab;\n cursor: -moz-grab;\n cursor: -webkit-grab;\n}\n',""])},472:function(t,e,n){"use strict";var r=Array.prototype.slice,o=function(t){return t},i=1,a=2,s=3,c=4,l=1e-6;function u(t){return"translate("+(t+.5)+",0)"}function p(t){return"translate(0,"+(t+.5)+")"}function f(){return!this.__axis}function y(t,e){var n=[],y=null,d=null,h=6,m=6,v=3,g=t===i||t===c?-1:1,b=t===c||t===a?"x":"y",x=t===i||t===s?u:p;function O(r){var u=null==y?e.ticks?e.ticks.apply(e,n):e.domain():y,p=null==d?e.tickFormat?e.tickFormat.apply(e,n):o:d,O=Math.max(h,0)+v,j=e.range(),w=+j[0]+.5,k=+j[j.length-1]+.5,S=(e.bandwidth?function(t){var e=Math.max(0,t.bandwidth()-1)/2;return t.round()&&(e=Math.round(e)),function(n){return+t(n)+e}}:function(t){return function(e){return+t(e)}})(e.copy()),_=r.selection?r.selection():r,A=_.selectAll(".domain").data([null]),P=_.selectAll(".tick").data(u,e).order(),q=P.exit(),G=P.enter().append("g").attr("class","tick"),z=P.select("line"),E=P.select("text");A=A.merge(A.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),P=P.merge(G),z=z.merge(G.append("line").attr("stroke","currentColor").attr(b+"2",g*h)),E=E.merge(G.append("text").attr("fill","currentColor").attr(b,g*O).attr("dy",t===i?"0em":t===s?"0.71em":"0.32em")),r!==_&&(A=A.transition(r),P=P.transition(r),z=z.transition(r),E=E.transition(r),q=q.transition(r).attr("opacity",l).attr("transform",function(t){return isFinite(t=S(t))?x(t):this.getAttribute("transform")}),G.attr("opacity",l).attr("transform",function(t){var e=this.parentNode.__axis;return x(e&&isFinite(e=e(t))?e:S(t))})),q.remove(),A.attr("d",t===c||t==a?m?"M"+g*m+","+w+"H0.5V"+k+"H"+g*m:"M0.5,"+w+"V"+k:m?"M"+w+","+g*m+"V0.5H"+k+"V"+g*m:"M"+w+",0.5H"+k),P.attr("opacity",1).attr("transform",function(t){return x(S(t))}),z.attr(b+"2",g*h),E.attr(b,g*O).text(p),_.filter(f).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===a?"start":t===c?"end":"middle"),_.each(function(){this.__axis=S})}return O.scale=function(t){return arguments.length?(e=t,O):e},O.ticks=function(){return n=r.call(arguments),O},O.tickArguments=function(t){return arguments.length?(n=null==t?[]:r.call(t),O):n.slice()},O.tickValues=function(t){return arguments.length?(y=null==t?null:r.call(t),O):y&&y.slice()},O.tickFormat=function(t){return arguments.length?(d=t,O):d},O.tickSize=function(t){return arguments.length?(h=m=+t,O):h},O.tickSizeInner=function(t){return arguments.length?(h=+t,O):h},O.tickSizeOuter=function(t){return arguments.length?(m=+t,O):m},O.tickPadding=function(t){return arguments.length?(v=+t,O):v},O}function d(t){return y(s,t)}function h(t){return y(c,t)}n.d(e,"a",function(){return d}),n.d(e,"b",function(){return h})},653:function(t,e,n){"use strict";n.r(e);var r=n(3),o=n.n(r),i=n(440),a=(n(444),n(48)),s=n(447),c=n(22),l=n(472),u=n(7),p=n(501),f=n(47),y=n(441),d=n(145),h=n(69),m=n(21);function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var g=.85,b=function(t,e){if(e[t])return e[t].legendTitle;if(Object(m.isColorByGenotype)(t)){var n=Object(m.decodeColorByGenotype)(t);return n.aa?"Genotype at ".concat(n.gene," pos ").concat(n.positions.join(", ")):"Genotype at Nuc. ".concat(n.positions.join(", "))}return Object(d.prettyString)(t)},x=function(t,e){return{y:Object(c.a)().domain([0,e]).range([t.height-t.spaceBottom,t.spaceTop]),numTicksY:5}},O=function(t,e,n){!function(t){t.selectAll(".y.axis").remove()}(t);var r=Object(f.a)(".0%");t.append("g").attr("class","y axis").attr("transform","translate(".concat(e.spaceLeft,",0)")).style("font-family",y.b).style("font-size","12px").call(Object(l.b)(n.y).ticks(n.numTicksY).tickFormat(r))},j=function(t,e,n){if(n){!function(t){t.selectAll(".projection-pivot").remove(),t.selectAll(".projection-text").remove()}(t),t.append("g").attr("class","projection-pivot").append("line").attr("x1",e.x(parseFloat(n))).attr("x2",e.x(parseFloat(n))).attr("y1",e.y(1)).attr("y2",e.y(0)).style("visibility","visible").style("stroke","rgba(55,55,55,0.9)").style("stroke-width","2").style("stroke-dasharray","4 4");var r=.5*(e.x(parseFloat(n))+e.x.range()[1]);t.append("g").attr("class","projection-text").append("text").attr("x",r).attr("y",e.y(1)-3).style("pointer-events","none").style("fill","#555").style("font-family",y.b).style("font-size",12).style("alignment-baseline","bottom").style("text-anchor","middle").text("Projection")}};function w(){Object(i.f)(this).attr("opacity",1)}function k(){Object(i.f)(this).attr("opacity",g),Object(i.f)("#freqinfo").style("visibility","hidden"),Object(i.f)("#vline").style("visibility","hidden")}var S,_=function(t){var e=t.matrix,n=t.pivots,r=t.colorScale,o=function(t,e){for(var n=e.legendValues.filter(function(t){return void 0!==t}).reverse().map(function(t){return t.toString()}),r=n.length-1;r>=0;--r)-1===t.indexOf(n[r])&&n.splice(r,1);return t.length>n.length&&t.forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),n}(Object.keys(e),r),i=function(t,e,n){for(var r=[],o=0;o<t.length;o++){for(var i=[],a=0;a<e;a++)if(0===o)i.push([0,n[t[o]][a]]);else{var s=r[o-1][a][1];i.push([s,n[t[o]][a]+s])}r.push(i)}return r}(o,n.length,e),a=function(t){return t[t.length-1].reduce(function(t,e){return Math.max(t,e[1])},0)}(i);return{categories:o,series:i,maxY:a}},A=function(t,e,n,r){var o,a=n.categories,s=n.series,c=r.colorBy,l=r.colorScale,f=r.colorOptions,m=r.pivots,x=r.projection_pivot;(o=t).selectAll("path").remove(),o.selectAll("line").remove(),o.selectAll("text").remove();var O=function(t,e){return function(n,r){return t[r]===h.unassigned_label?"rgb(190, 190, 190)":Object(u.f)(e.scale(t[r])).toString()}}(a,l),j=function(t,e){return e.continuous?t.map(function(t){return t===h.unassigned_label?h.unassigned_label:"".concat(e.legendBounds[t][0].toFixed(2)," - ").concat(e.legendBounds[t][1].toFixed(2))}):t.slice()}(a,l),S=Object(p.a)().x(function(t,n){return e.x(m[n])}).y0(function(t){return e.y(t[0])}).y1(function(t){return e.y(t[1])});t.selectAll(".stream").data(s).enter().append("path").attr("d",S).attr("fill",O).attr("opacity",g).on("mouseover",w).on("mouseout",k).on("mousemove",function(t,n){var r=v(Object(i.d)(this),1)[0],o=e.x.invert(r),a=m.reduce(function(t,e,n,r){return Math.abs(e-o)<Math.abs(r[t]-o)?n:t},0),s=Math.round(100*(t[a][1]-t[a][0]))+"%",l=e.x(m[a]),u=e.y(t[a][1]),p=e.y(t[a][0]);Object(i.f)("#vline").style("visibility","visible").attr("x1",l).attr("x2",l).attr("y1",u).attr("y2",p);var h=l>.5*e.x.range()[1]?"":"".concat(l+25,"px"),g=l>.5*e.x.range()[1]?"".concat(e.x.range()[1]-l+25,"px"):"",O=u>.5*e.y(0)?"".concat(e.y(0)-50,"px"):"".concat(u+25,"px"),w="Frequency";x&&m[a]>x&&(w="Projected frequency"),Object(i.f)("#freqinfo").style("left",h).style("right",g).style("top",O).style("padding-left","10px").style("padding-right","10px").style("padding-top","0px").style("padding-bottom","0px").style("visibility","visible").style("background-color","rgba(55,55,55,0.9)").style("color","white").style("font-family",y.b).style("font-size",18).style("line-height",1).style("font-weight",300).html("<p>".concat(b(c,f),": ").concat(Object(d.prettyString)(j[n]),"</p>\n <p>Time point: ").concat(m[a],"</p>\n <p>").concat(w,": ").concat(s,"</p>"))}),t.append("line").attr("id","vline").style("visibility","hidden").style("pointer-events","none").style("stroke","rgba(55,55,55,0.9)").style("stroke-width",4),function(t,e,n,r,o){var i=function(t,e,n,r){return t.map(function(t){for(var o=.15*n.y.domain()[1],i=0;i<t.length-r;i++){var a=i+r;if(t[i][1]-t[i][0]>o&&t[a][1]-t[a][0]>o)return[n.x(e[i+1]),(n.y((t[i][1]+t[i][0])/2)+n.y((t[a][1]+t[a][0])/2))/2]}return[void 0,void 0]})}(e,n,o,3);t.selectAll(".streamLabels").data(r).enter().append("text").attr("x",function(t,e){return i[e][0]}).attr("y",function(t,e){return i[e][1]}).style("pointer-events","none").style("fill","white").style("font-family",y.b).style("font-size",14).style("alignment-baseline","middle").text(function(t,e){return i[e][0]?Object(d.prettyString)(t):""})}(t,s,m,j,e)};n(470);function P(t){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function q(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function G(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?q(n,!0).forEach(function(e){z(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function z(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function F(t,e){return!e||"object"!==P(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function R(t){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function M(t,e){return(M=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var T=Object(a.b)(function(t){return{data:t.frequencies.data,pivots:t.frequencies.pivots,ticks:t.frequencies.ticks,matrix:t.frequencies.matrix,projection_pivot:t.frequencies.projection_pivot,version:t.frequencies.version,browserDimensions:t.browserDimensions.browserDimensions,colorBy:t.controls.colorBy,colorScale:t.controls.colorScale,colorOptions:t.metadata.colorOptions}})(S=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=F(this,R(e).call(this,t))).state={maxY:0},n}var n,r,a;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&M(t,e)}(e,o.a.Component),n=e,(r=[{key:"calcChartGeom",value:function(t,e){return{width:t,height:e,spaceLeft:40,spaceRight:10,spaceBottom:20,spaceTop:10}}},{key:"recomputeRedrawAll",value:function(t,e){var n=this.calcChartGeom(e.width,e.height),r=_(G({},e));t.maxY=r.maxY,t.categories=r.categories;var o=function(t,e,n){return{x:Object(c.a)().domain([e[0],e[e.length-1]]).range([t.spaceLeft,t.width-t.spaceRight]),numTicksX:n.length}}(n,e.pivots,e.ticks),i=x(n,r.maxY);t.scales=G({},o,{},i),function(t,e,n){!function(t){t.selectAll(".x.axis").remove()}(t),t.append("g").attr("class","x axis").attr("transform","translate(0,".concat(e.height-e.spaceBottom,")")).style("font-family",y.b).style("font-size","12px").call(Object(l.a)(n.x).ticks(n.numTicksX,".1f"))}(t.svg,n,o),O(t.svg,n,i),A(t.svgStreamGroup,t.scales,r,G({},e)),j(t.svg,t.scales,e.projection_pivot)}},{key:"recomputeRedrawPartial",value:function(t,e,n){var r,o,i=_(G({},n)),a=t.maxY!==i.maxY,s=(r=t.categories,o=i.categories,!(r.length===o.length&&!r.filter(function(t,e){return t!==o[e]}).length));if(!a&&!s)return!1;var c,l=this.calcChartGeom(n.width,n.height);if(a){var u=x(l,i.maxY);O(t.svg,l,u),c=G({},t.scales,{},u)}else c=G({},t.scales);return A(t.svgStreamGroup,c,i,G({},n)),a&&j(t.svg,c,n.projection_pivot),G({},t,{scales:c,maxY:i.maxY,categories:i.categories})}},{key:"componentDidMount",value:function(){var t=Object(i.f)(this.domRef),e=t.append("g"),n={svg:t,svgStreamGroup:e};this.props.matrix&&this.recomputeRedrawAll(n,this.props),this.setState(n)}},{key:"componentWillReceiveProps",value:function(t){if(this.props.version===t.version);else if(!this.props.loaded&&t.loaded){var e=G({},this.state);this.recomputeRedrawAll(e,t),this.setState(e)}else{var n=this.recomputeRedrawPartial(this.state,this.props,t);n&&this.setState(n)}}},{key:"componentDidUpdate",value:function(t){if(t.width!==this.props.width||t.height!==this.props.height){var e=G({},this.state);this.recomputeRedrawAll(e,this.props),this.setState(e)}}},{key:"render",value:function(){var t=this;return o.a.createElement(s.a,{title:"Frequencies (coloured by ".concat(b(this.props.colorBy,this.props.colorOptions),")")},o.a.createElement("div",{id:"freqinfo",style:{zIndex:20,position:"absolute",borderRadius:"5px",padding:"10px",backgroundColor:"hsla(0,0%,100%,.9)",pointerEvents:"none",visibility:"hidden",fontSize:"14px"}}),o.a.createElement("svg",{id:"d3frequenciesSVG",width:this.props.width,height:this.props.height,style:{pointerEvents:"auto",overflow:"visible"}},o.a.createElement("g",{ref:function(e){t.domRef=e},id:"d3frequencies"})))}}])&&E(n.prototype,r),a&&E(n,a),e}())||S;e.default=T}}]);
//# sourceMappingURL=auspice.chunk.6.bundle.js.map