UNPKG

13.9 kBJavaScriptView Raw
1(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{510:function(t,e,n){var r=n(511);"string"==typeof r&&(r=[[t.i,r,""]]);n(42)(r,{});r.locals&&(t.exports=r.locals)},511:function(t,e,n){(t.exports=n(41)(!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", "Helvetica Neue", "Helvetica", "sans-serif";\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',""])},512: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 f(t){return"translate(0,"+(t+.5)+")"}function p(t){return function(e){return+t(e)}}function y(t){var e=Math.max(0,t.bandwidth()-1)/2;return t.round()&&(e=Math.round(e)),function(n){return+t(n)+e}}function d(){return!this.__axis}function h(t,e){var n=[],h=null,v=null,m=6,g=6,b=3,x=t===i||t===c?-1:1,w=t===c||t===a?"x":"y",O=t===i||t===s?u:f;function j(r){var u=null==h?e.ticks?e.ticks.apply(e,n):e.domain():h,f=null==v?e.tickFormat?e.tickFormat.apply(e,n):o:v,j=Math.max(m,0)+b,k=e.range(),S=+k[0]+.5,_=+k[k.length-1]+.5,A=(e.bandwidth?y:p)(e.copy()),P=r.selection?r.selection():r,q=P.selectAll(".domain").data([null]),G=P.selectAll(".tick").data(u,e).order(),z=G.exit(),E=G.enter().append("g").attr("class","tick"),F=G.select("line"),R=G.select("text");q=q.merge(q.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),G=G.merge(E),F=F.merge(E.append("line").attr("stroke","currentColor").attr(w+"2",x*m)),R=R.merge(E.append("text").attr("fill","currentColor").attr(w,x*j).attr("dy",t===i?"0em":t===s?"0.71em":"0.32em")),r!==P&&(q=q.transition(r),G=G.transition(r),F=F.transition(r),R=R.transition(r),z=z.transition(r).attr("opacity",l).attr("transform",(function(t){return isFinite(t=A(t))?O(t):this.getAttribute("transform")})),E.attr("opacity",l).attr("transform",(function(t){var e=this.parentNode.__axis;return O(e&&isFinite(e=e(t))?e:A(t))}))),z.remove(),q.attr("d",t===c||t==a?g?"M"+x*g+","+S+"H0.5V"+_+"H"+x*g:"M0.5,"+S+"V"+_:g?"M"+S+","+x*g+"V0.5H"+_+"V"+x*g:"M"+S+",0.5H"+_),G.attr("opacity",1).attr("transform",(function(t){return O(A(t))})),F.attr(w+"2",x*m),R.attr(w,x*j).text(f),P.filter(d).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===a?"start":t===c?"end":"middle"),P.each((function(){this.__axis=A}))}return j.scale=function(t){return arguments.length?(e=t,j):e},j.ticks=function(){return n=r.call(arguments),j},j.tickArguments=function(t){return arguments.length?(n=null==t?[]:r.call(t),j):n.slice()},j.tickValues=function(t){return arguments.length?(h=null==t?null:r.call(t),j):h&&h.slice()},j.tickFormat=function(t){return arguments.length?(v=t,j):v},j.tickSize=function(t){return arguments.length?(m=g=+t,j):m},j.tickSizeInner=function(t){return arguments.length?(m=+t,j):m},j.tickSizeOuter=function(t){return arguments.length?(g=+t,j):g},j.tickPadding=function(t){return arguments.length?(b=+t,j):b},j}function v(t){return h(s,t)}function m(t){return h(c,t)}n.d(e,"a",(function(){return v})),n.d(e,"b",(function(){return m}))},693:function(t,e,n){"use strict";n.r(e);var r=n(3),o=n.n(r),i=n(479),a=(n(483),n(40)),s=n(485),c=n(27),l=n(512),u=n(5),f=n(541),p=n(51),y=n(480),d=n(70),h=n(22);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 m=.85,g=function(t,e){if(e&&e[t])return e[t].title;if(Object(h.isColorByGenotype)(t)){var n=Object(h.decodeColorByGenotype)(t);return n.aa?"Genotype at ".concat(n.gene," pos ").concat(n.positions.join(", ")):"Genotype at Nuc. ".concat(n.positions.join(", "))}return t},b=function(t,e){return{y:Object(c.a)().domain([0,e]).range([t.height-t.spaceBottom,t.spaceTop]),numTicksY:5}},x=function(t,e,n){!function(t){t.selectAll(".y.axis").remove()}(t);var r=Object(p.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))},w=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 O(){Object(i.f)(this).attr("opacity",1)}function j(){Object(i.f)(this).attr("opacity",m),Object(i.f)("#freqinfo").style("visibility","hidden"),Object(i.f)("#vline").style("visibility","hidden")}var k,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}},_=function(t,e,n,r){var o,a=n.categories,s=n.series,c=r.colorBy,l=r.colorScale,p=r.colorOptions,h=r.pivots,b=r.projection_pivot;(o=t).selectAll("path").remove(),o.selectAll("line").remove(),o.selectAll("text").remove();var x=function(t,e){return function(n,r){return t[r]===d.unassigned_label?"rgb(190, 190, 190)":Object(u.f)(e.scale(t[r])).toString()}}(a,l),w=function(t,e){return e.continuous?t.map((function(t){return t===d.unassigned_label?d.unassigned_label:"".concat(e.legendBounds[t][0].toFixed(2)," - ").concat(e.legendBounds[t][1].toFixed(2))})):t.slice()}(a,l),k=Object(f.b)().x((function(t,n){return e.x(h[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",k).attr("fill",x).attr("opacity",m).on("mouseover",O).on("mouseout",j).on("mousemove",(function(t,n){var r=v(Object(i.d)(this),1)[0],o=e.x.invert(r),a=h.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(h[a]),u=e.y(t[a][1]),f=e.y(t[a][0]);Object(i.f)("#vline").style("visibility","visible").attr("x1",l).attr("x2",l).attr("y1",u).attr("y2",f);var d=l>.5*e.x.range()[1]?"":"".concat(l+25,"px"),m=l>.5*e.x.range()[1]?"".concat(e.x.range()[1]-l+25,"px"):"",x=u>.5*e.y(0)?"".concat(e.y(0)-50,"px"):"".concat(u+25,"px"),O="Frequency";b&&h[a]>b&&(O="Projected frequency"),Object(i.f)("#freqinfo").style("left",d).style("right",m).style("top",x).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(g(c,p),": ").concat(w[n],"</p>\n <p>Time point: ").concat(h[a],"</p>\n <p>").concat(O,": ").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]?t:""}))}(t,s,h,w,e)};n(510);function A(t){return(A="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 P(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 q(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?P(n,!0).forEach((function(e){G(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function G(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function z(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 E(t,e){return!e||"object"!==A(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 F(t){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function R(t,e){return(R=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var M=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.colorings}}))(k=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=E(this,F(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&&R(t,e)}(e,t),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=S(q({},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=b(n,r.maxY);t.scales=q({},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),x(t.svg,n,i),_(t.svgStreamGroup,t.scales,r,q({},e)),w(t.svg,t.scales,e.projection_pivot)}},{key:"recomputeRedrawPartial",value:function(t,e,n){var r,o,i=S(q({},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=b(l,i.maxY);x(t.svg,l,u),c=q({},t.scales,{},u)}else c=q({},t.scales);return _(t.svgStreamGroup,c,i,q({},n)),a&&w(t.svg,c,n.projection_pivot),q({},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=q({},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=q({},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(g(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"})))}}])&&z(n.prototype,r),a&&z(n,a),e}(o.a.Component))||k;e.default=M}}]);
2//# sourceMappingURL=auspice.chunk.6.bundle.js.map
\No newline at end of file