UNPKG

11.8 kBJavaScriptView Raw
1(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{TKye:function(t,e,n){"use strict";n.r(e);var r=n("q1tI"),o=n.n(r),i=n("9kay"),a=n("/TIM"),c=(n("sQjb"),n("/MKj")),s=n("KmX0"),l=n("VIqg"),u=n("RhHs"),p=n("SC+/"),f=n("8d86"),y=n("rWgG"),h=n("WjpJ"),v=n.n(h),d=n("vec1"),b=n("Rf7/"),m=n("Y6X2"),g=n("PAHG"),x=n("IzZ+");function j(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,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var O=function(t,e){if(e&&e[t])return e[t].title;if(Object(m.d)(t)){var n=Object(m.a)(t);return n.aa?"Genotype at ".concat(n.gene," pos ").concat(n.positions.join(", ")):"Genotype at Nuc. ".concat(n.positions.join(", "))}return t},w=function(t,e){return{y:Object(l.a)().domain([0,e]).range([t.height-t.spaceBottom,t.spaceTop]),numTicksY:5}},k=function(t,e,n){!function(t){t.selectAll(".y.axis").remove()}(t);var r=Object(y.a)(".0%");t.append("g").attr("class","y axis").attr("transform","translate(".concat(e.spaceLeft,",0)")).style("font-family",d.b).style("font-size","12px").call(Object(u.b)(n.y).ticks(n.numTicksY).tickFormat(r))},S=function(t,e,n,r){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 o=.5*(e.x(parseFloat(n))+e.x.range()[1]);t.append("g").attr("class","projection-text").append("text").attr("x",o).attr("y",e.y(1)-3).style("pointer-events","none").style("fill","#555").style("font-family",d.b).style("font-size",12).style("alignment-baseline","bottom").style("text-anchor","middle").text(r("Projection"))}};function P(){Object(a.f)(this).attr("opacity",1)}function R(){Object(a.f)(this).attr("opacity",.85),Object(a.f)("#freqinfo").style("visibility","hidden"),Object(a.f)("#vline").style("visibility","hidden")}var A,q=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 c=r[o-1][a][1];i.push([c,n[t[o]][a]+c])}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}},G=function(t,e,n,r){var o,i=n.categories,c=n.series,s=r.colorBy,l=r.colorScale,u=r.colorOptions,y=r.pivots,h=r.projection_pivot,v=r.t;(o=t).selectAll("path").remove(),o.selectAll("line").remove(),o.selectAll("text").remove();var m=function(t,e){return function(n,r){return t[r]===b.c?"rgb(190, 190, 190)":Object(p.f)(e.scale(t[r])).toString()}}(i,l),x=function(t,e){return e.continuous?t.map((function(t){return t===b.c?b.c:"".concat(e.legendBounds[t][0].toFixed(2)," - ").concat(e.legendBounds[t][1].toFixed(2))})):t.slice()}(i,l),w=Object(f.b)().x((function(t,n){return e.x(y[n])})).y0((function(t){return e.y(t[0])})).y1((function(t){return e.y(t[1])}));t.selectAll(".stream").data(c).enter().append("path").attr("d",w).attr("fill",m).attr("opacity",.85).on("mouseover",P).on("mouseout",R).on("mousemove",(function(t,n){var r=j(Object(a.d)(this),1)[0],o=e.x.invert(r),i=y.reduce((function(t,e,n,r){return Math.abs(e-o)<Math.abs(r[t]-o)?n:t}),0),c=Math.round(100*(t[i][1]-t[i][0]))+"%",l=e.x(y[i]),p=e.y(t[i][1]),f=e.y(t[i][0]);Object(a.f)("#vline").style("visibility","visible").attr("x1",l).attr("x2",l).attr("y1",p).attr("y2",f);var b=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"):"",w=p>.5*e.y(0)?"".concat(e.y(0)-50,"px"):"".concat(p+25,"px"),k=v("Frequency");h&&y[i]>h&&(k=v("Projected frequency")),Object(a.f)("#freqinfo").style("left",b).style("right",m).style("top",w).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",d.b).style("font-size",18).style("line-height",1).style("font-weight",300).html("<p>".concat(O(s,u),": ").concat(x[n],"</p>\n <p>").concat(v("Time point"),": ").concat(Object(g.d)(y[i]),"</p>\n <p>").concat(k,": ").concat(c,"</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",d.b).style("font-size",14).style("alignment-baseline","middle").text((function(t,e){return i[e][0]?t:""}))}(t,c,y,x,e)};n("mvt5");function E(t){return(E="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 Y(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 _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Y(n,!0).forEach((function(e){T(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function T(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D(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 z(t,e){return(z=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function B(t,e){return!e||"object"!==E(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)}var C=Object(c.b)((function(t){return{data:t.frequencies.data,pivots:t.frequencies.pivots,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}}))(A=function(t){!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&&z(t,e)}(c,t);var e,n,r,i=function(t){function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}return function(){var n,r=F(t);if(e()){var o=F(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return B(this,n)}}(c);function c(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(e=i.call(this,t)).state={maxY:0},e}return e=c,(n=[{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=q(_({},e));t.maxY=r.maxY,t.categories=r.categories;var o=function(t,e){return{x:Object(l.a)().domain([e[0],e[e.length-1]]).range([t.spaceLeft,t.width-t.spaceRight])}}(n,e.pivots),i=w(n,r.maxY);t.scales=_(_({},o),i),function(t,e,n){var r=n.x.domain(),o=n.x.range(),i=Object(x.b)(r[1]-r[0],o[1]-o[0]).majorStep;!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",d.b).style("font-size","12px").call(Object(u.a)(n.x).tickValues(v()(r[0],r[1],i)).tickFormat((function(t){return Object(x.c)(i,t)})))}(t.svg,n,o),k(t.svg,n,i),G(t.svgStreamGroup,t.scales,r,_({},e)),S(t.svg,t.scales,e.projection_pivot,e.t)}},{key:"recomputeRedrawPartial",value:function(t,e,n){var r,o,i=q(_({},n)),a=t.maxY!==i.maxY,c=(r=t.categories,o=i.categories,!(r.length===o.length&&!r.filter((function(t,e){return t!==o[e]})).length));if(!a&&!c)return!1;var s,l=this.calcChartGeom(n.width,n.height);if(a){var u=w(l,i.maxY);k(t.svg,l,u),s=_(_({},t.scales),u)}else s=_({},t.scales);return G(t.svgStreamGroup,s,i,_({},n)),a&&S(t.svg,s,n.projection_pivot,n.t),_(_({},t),{},{scales:s,maxY:i.maxY,categories:i.categories})}},{key:"componentDidMount",value:function(){var t=Object(a.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=_({},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=_({},this.state);this.recomputeRedrawAll(e,this.props),this.setState(e)}}},{key:"render",value:function(){var t=this,e=this.props.t;return o.a.createElement(s.a,{title:"".concat(e("Frequencies")," (").concat(e("colored by")," ").concat(O(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"})))}}])&&D(e.prototype,n),r&&D(e,r),c}(o.a.Component))||A,M=Object(i.c)()(C);e.default=M},mvt5:function(t,e,n){var r=n("rph2");"string"==typeof r&&(r=[[t.i,r,""]]);n("ZuTH")(r,{});r.locals&&(t.exports=r.locals)},rph2:function(t,e,n){(t.exports=n("JPst")(!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',""])}}]);
\No newline at end of file