From c09650ba02ff8c0d4e403258f7729f049924ecd1 Mon Sep 17 00:00:00 2001 From: Jorden Kreps Date: Fri, 3 Feb 2017 07:50:51 -0700 Subject: [PATCH] ENH: Reduce flicker on mouseover (#60) --- q2_taxa/assets/barplot/dst/bundle.js | 2 +- q2_taxa/assets/barplot/src/bar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/q2_taxa/assets/barplot/dst/bundle.js b/q2_taxa/assets/barplot/dst/bundle.js index d515b00..1aed919 100644 --- a/q2_taxa/assets/barplot/dst/bundle.js +++ b/q2_taxa/assets/barplot/dst/bundle.js @@ -1 +1 @@ -webpackJsonp([0],[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var a=n(1),o=r(a);(0,o.default)(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=d[e].data,n=(0,o.select)("body .container-fluid"),r=n.append("div").attr("class","viz row"),a=r.append("div").attr("class","col-lg-12"),l=a.append("div").attr("class","controls row"),u=l.append("div").attr("class","col-lg-12"),p=a.append("div").attr("class","plot row"),f=p.append("div").attr("class","col-md-12"),m=f.append("svg"),v=m.append("g");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("text").attr("id","y-label").attr("text-anchor","middle").style("font","12px sans-serif").text("Relative Frequency"),v.append("text").attr("id","x-label").attr("text-anchor","middle").style("font","12px sans-serif").text("Sample");var h=i.availableColorSchemes[0].name,y=(0,c.setupData)(d[e],m),g=y.sortedKeysReverse,x=y.levels,b=(0,c.sort)(t,[g[0]],["Ascending"],[!1],y);(0,s.default)(m,h,b,y);var k=u.append("div").attr("class","row");(0,i.addDownloadLinks)(k,m),(0,i.addTaxaPicker)(k,x,d[e].name),(0,i.addColorPicker)(k,m,t,y),(0,i.addSortByPicker)(k,m,t,y)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(3),s=r(l),i=n(7),c=n(11)},,function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n,r){var a=n.sortMap,s=n.sortedSampleIDs,c=10*s.length,p=600,f={top:20,left:60,right:50,bottom:50},m=200,v=r.keys,h=e.select("g");e.property("colorScheme",t);var y=(0,o.scaleBand)().padding(.1).domain(s).range([0,c]),g=(0,o.scaleLinear)().domain([0,1]).range([p,0]).nice(),x=u.availableColorSchemes.find(function(e){return e.name===t}),b=void 0;if("s"===x.type)b=(0,o.scaleSequential)(x.scheme).domain([0,v.length-1]);else if("o"===x.type){for(var k=[],A=[],P=0;Pl&&(l=e),"rotate(-90)"}),t.select("#x-label").attr("transform","translate("+n/2+","+(r+l+a)+")"),l}function r(e,t,n,r){e.select(".y.axis").call(r),t.select("#y-label").attr("transform","translate(-"+a+","+n/2+")rotate(-90)")}Object.defineProperty(t,"__esModule",{value:!0}),t.setupXAxis=n,t.setupYAxis=r;var a=t.labelOffset=30},function(e,t,n){"use strict";function r(e,t){e.transition().duration(l.transitionDur).style("fill",function(e){return t(e.index)})}function a(e,t,n,a,l,s){e.selectAll("#tooltip").remove();var i=e.append("g").style("display","none").attr("id","tooltip");i.append("rect").attr("height",50).attr("fill","white");var c=i.append("text").style("text-anchor","middle").attr("font-size","12px").attr("font-weight","bold");c.append("tspan").attr("id","ttxlabel").attr("dy","1.2em"),c.append("tspan").attr("id","taxalabel").attr("dy","1.2em"),c.append("tspan").attr("id","abunlabel").attr("dy","1.2em");var d=e.selectAll(".layer").data(l.layers);d.exit().remove();var u=d.enter().append("g").attr("class","layer"),p=d.merge(u).call(r,a).attr("visibility",null).property("taxa",function(e){return e.key}),f=p.selectAll("rect").data(function(e){return e});f.exit().remove();var m=f.enter().append("rect");f.merge(m).attr("x",function(e){return t(e.data[l.first])}).attr("y",function(e){return n(e[1])}).attr("height",function(e){return n(e[0])-n(e[1])}).attr("width",t.bandwidth()).on("mouseover",function(){i.style("display",null)}).on("mouseout",function(){i.style("display","none")}).on("mousemove",function(e){var t=i.select("text"),n=(0,o.select)(this.parentNode).property("taxa"),r=t.select("#ttxlabel"),a=t.select("#taxalabel"),c=t.select("#abunlabel");r.text(function(){return s[e.data[l.first]]}),a.text(function(){return n}),c.text(function(){return(100*(e[1]-e[0])).toFixed(3)+"%"});var d=t.node().getBBox().width,u=d/2+5;r.attr("x",u),a.attr("x",u),c.attr("x",u),i.select("rect").attr("width",d+10);var p=(0,o.mouse)(this)[0],f=(0,o.mouse)(this)[1]-25;i.attr("transform","translate("+p+","+f+")")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(1)},function(e,t,n){"use strict";function r(e,t,n){e.transition().duration(l.transitionDur).style("fill",function(e){return t(n.indexOf(e))})}function a(e,t,n,a,l){var s=e.property("stackOrder");t.selectAll(".legend").remove();var i=t.selectAll(".legend").data(s),c=i.enter().append("g").attr("class","legend").attr("id",function(e){return"id"+e}).style("font","10px sans-serif"),d=i.merge(c).attr("transform",function(e,t){return"translate(10,"+20*(n.length-t-1)+")"});c.append("rect").attr("width",18).attr("height",18),d.selectAll("rect").attr("x",a).call(r,l,s).on("mouseover",function(){(0,o.select)(this).style("cursor","pointer")}).on("click",function(e){var t=(0,o.select)("#id"+e),r=t.select("rect"),a=r.classed("selected");r.classed("selected",!a).style("stroke",function(){return a?null:"black"}).style("stroke-width",function(){return a?null:2});var l=(0,o.selectAll)(".legend .selected").nodes().map(function(e){return n[(0,o.select)(e).datum()]});(0,o.selectAll)(".layer").attr("visibility",function(e){return 0===l.length?null:l.indexOf(e.key.trim())>-1?null:"hidden"})}),c.append("text").attr("y",9).attr("dy",".35em").attr("text-anchor","start"),d=d.selectAll("text").attr("x",a+24).text(function(e){return n[e]});var u=0;return d.each(function(){var e=this.getComputedTextLength();e>u&&(u=e)}),u}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e,t,n,r){var a=e.selectAll(".xCtrl").nodes().map(function(e){return e.options[e.selectedIndex].value}),o=e.selectAll(".xOrder").nodes().map(function(e){return e.options[e.selectedIndex].value}),l=e.selectAll(".xLabel").nodes().map(function(e){return"hidden"!==e.type&&e.checked});return(0,b.sort)(n,a,o,l,r)}function l(e,t,n,r){var a=o(e,t,n,r);(0,x.default)(t,t.property("colorScheme"),a,r)}function s(e,t,n,r){var a=e.append("div").attr("class","row"),o=a.append("div").attr("class","col-lg-4"),s=a.append("div").attr("class","col-lg-4"),i=a.append("div").attr("class","col-lg-4"),c=o.append("select").attr("class","xCtrl form-control").on("change",function(){i.select("label").remove();var a=(0,f.select)(this).node(),o=a.options[a.selectedIndex].value,s=r.metaData.indexOf(o)>-1;i.append("label").text(function(){return s?"Relabel X? ":""}).append("input").attr("class","xLabel").attr("type",function(){return s?"checkbox":"hidden"}).property("checked",!0).on("change",function(){l(e,t,n,r)}),l(e,t,n,r)}),d=["Ascending","Descending"];return s.append("select").attr("class","xOrder form-control").on("change",function(){l(e,t,n,r)}).selectAll("option").data(d).enter().append("option").attr("value",function(e){return e}).text(function(e){return e}),e.selectAll(".row").size()>1&&i.append("a").on("click",function(){a.remove(),l(e,t,n,r)}).append("span").attr("class","glyphicon glyphicon-minus-sign text-danger").attr("style","cursor: pointer; cursor: hand;"),c}function i(e,t,n,r){var a=[{label:"Sample Metadata",keys:t},{label:"Taxonomic Abundance",keys:n}],o=e.selectAll("optgroup").data(a);o.exit().remove();var l=o.enter().append("optgroup"),s=o.merge(l).attr("label",function(e){return e.label}),i=s.selectAll("option").data(function(e){return e.keys});i.exit().remove();var c=i.enter().append("option");return i.merge(c).attr("value",function(e){return e}).property("selected",function(e){return e===r}).text(function(e){return e})}function c(e,t,n){var r=e.append("div").attr("class","col-lg-2 form-group taxaPicker");return r.append("label").text("Taxonomic Level"),r.append("select").attr("class","form-control").on("change",function(){var e=(0,f.select)(".container-fluid");e.select(".viz.row").remove(),(0,y.default)(this.selectedIndex)}).selectAll("option").data(t).enter().append("option").attr("value",function(e){return e}).text(function(e){return e}).property("selected",function(e){return e===n}),r}function d(e,t,n,r){var a=e.append("div").attr("class","col-lg-2 form-group colorPicker");a.append("label").text("Color Palette"),a.append("a").attr("style","padding-left: 5px;").attr("href","https://github.com/d3/d3-scale-chromatic#api-reference").attr("title","Click here for more information on the color schemes.").attr("target","_blank").attr("rel","noopener noreferrer").append("span").attr("class","glyphicon glyphicon-info-sign");var l=a.append("select").attr("class","form-control").on("change",function(){var a=this.options[this.selectedIndex].value,l=o(e,t,n,r);(0,x.default)(t,a,l,r)}),s=k.filter(function(e){return"o"===e.type}),i=k.filter(function(e){return"s"===e.type}),c=[{label:"Discrete",keys:s},{label:"Continuous",keys:i}],d=l.selectAll("optgroup").data(c);d.exit().remove();var u=d.enter().append("optgroup"),p=d.merge(u).attr("label",function(e){return e.label}),f=p.selectAll("option").data(function(e){return e.keys});f.exit().remove();var m=f.enter().append("option");return f.merge(m).attr("value",function(e){return e.name}).text(function(e){return e.name}),a}function u(e,t,n,r){var a=r.metaData,o=r.sortedKeysReverse,l=e.append("div").attr("class","col-lg-6 form-group sortByPicker");l.append("label").text("Sort Samples By"),l.append("a").on("click",function(){var e=l.selectAll(".xCtrl");if(e.size()!==a.length+o.length+1){var c=s(l,t,n,r);i(c,a,o,o[0])}}).append("span").attr("class","glyphicon glyphicon-plus-sign").attr("style","padding-left: 5px; cursor: pointer; cursor: hand;");var c=s(l,t,n,r);return i(c,a,o,o[0]),l}function p(e,t){var n=e.append("div").attr("class","col-lg-2 form-group");n.append("label").html(" "),n.append("button").text("Download SVG").attr("class","btn btn-default form-control").on("click",function(){var e=new XMLSerializer,n=e.serializeToString(t.node());n='\r\n'+n;var r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n),a=document.createElement("a");a.setAttribute("href",r),a.setAttribute("download","taxaplot.svg"),document.body.appendChild(a),a.click(),document.body.removeChild(a)})}Object.defineProperty(t,"__esModule",{value:!0}),t.availableColorSchemes=void 0,t.addTaxaPicker=c,t.addColorPicker=d,t.addSortByPicker=u,t.addDownloadLinks=p;var f=n(2),m=n(8),v=a(m),h=n(1),y=r(h),g=n(3),x=r(g),b=n(11),k=t.availableColorSchemes=[{name:"schemeAccent",scheme:v.schemeAccent,type:"o"},{name:"schemeDark2",scheme:v.schemeDark2,type:"o"},{name:"schemePaired",scheme:v.schemePaired,type:"o"},{name:"schemePastel1",scheme:v.schemePastel1,type:"o"},{name:"schemePastel2",scheme:v.schemePastel2,type:"o"},{name:"schemeSet1",scheme:v.schemeSet1,type:"o"},{name:"schemeSet2",scheme:v.schemeSet2,type:"o"},{name:"schemeSet3",scheme:v.schemeSet3,type:"o"},{name:"PRGn",scheme:v.interpolatePRGn,type:"s"},{name:"BrBG",scheme:v.interpolateBrBG,type:"s"},{name:"PiYG",scheme:v.interpolatePiYG,type:"s"},{name:"PuOr",scheme:v.interpolatePuOr,type:"s"},{name:"RdBu",scheme:v.interpolateRdBu,type:"s"},{name:"RdGy",scheme:v.interpolateRdGy,type:"s"},{name:"RdYlBu",scheme:v.interpolateRdYlBu,type:"s"},{name:"RdYlGn",scheme:v.interpolateRdYlGn,type:"s"},{name:"Spectral",scheme:v.interpolateSpectral,type:"s"}]},,,,function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n){var r=e[n],a=t[n];return r===a?(0,y.ascending)(e.position,t.position):(0,x.default)({direction:"asc"})(r,a)}function o(e,t,n){return(0,x.default)({direction:"asc"})(e[n],t[n])}function l(e,t,n){var r=e[n],a=t[n];return r===a?(0,y.descending)(e.position,t.position):(0,x.default)({direction:"desc"})(r,a)}function s(e,t,n){return(0,x.default)({direction:"desc"})(e[n],t[n])}function i(e,t,n){var r=e[n]/e.total,a=t[n]/t.total;return{aRel:r,bRel:a}}function c(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return a===o?(0,y.ascending)(e.position,t.position):(0,y.ascending)(a,o)}function u(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return(0,y.ascending)(a,o)}function p(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return a===o?(0,y.descending)(e.position,t.position):(0,y.descending)(a,o)}function f(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return(0,y.descending)(a,o)}function m(e,t){for(var n=0;n-1,g=void 0;v&&"Ascending"===h?g=y?a:c:v&&"Descending"===h?g=y?l:p:v||"Ascending"!==h?v||"Descending"!==h||(g=y?s:f):g=y?o:u,m=function(t,n){return g(t,n,e)},d=d.thenBy(m)});var v={},h=e.sort(d).map(function(e){var n=e[i.first],a=[];return t.forEach(function(t,n){r[n]&&a.push(e[t])}),v[n]=0===a.length?n:a.join("; "),n});return{sortedSampleIDs:h,sortMap:v}}function h(e,t){var n=e.data,r=e.taxaKeys,a=JSON.parse(JSON.stringify(n.columns)),o=void 0,l=void 0,s=a.filter(function(e){return r.indexOf(e)<0}),i=a.splice(0,1)[0];t.property("firstTaxa",i);var c=(0,y.stack)().keys(r).order(function(e){var n=(0,y.stackOrderAscending)(e);return o=new Array(n.length),n.forEach(function(e,t){o[t]=r[e]}),l=o.slice().reverse(),t.property("stackOrder",n),n}).offset(y.stackOffsetExpand),u=c(n);m(n,r);var p=d.map(function(e){return e.name});return{keys:r,columns:a,metaData:s,sortedKeys:o,sortedKeysReverse:l,first:i,layers:u,levels:p}}Object.defineProperty(t,"__esModule",{value:!0}),t.sort=v,t.setupData=h;var y=n(2),g=n(12),x=r(g),b=n(13),k=r(b)}]); \ No newline at end of file +webpackJsonp([0],[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var a=n(1),o=r(a);(0,o.default)(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e){var t=d[e].data,n=(0,o.select)("body .container-fluid"),r=n.append("div").attr("class","viz row"),a=r.append("div").attr("class","col-lg-12"),l=a.append("div").attr("class","controls row"),u=l.append("div").attr("class","col-lg-12"),p=a.append("div").attr("class","plot row"),f=p.append("div").attr("class","col-md-12"),m=f.append("svg"),v=m.append("g");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("text").attr("id","y-label").attr("text-anchor","middle").style("font","12px sans-serif").text("Relative Frequency"),v.append("text").attr("id","x-label").attr("text-anchor","middle").style("font","12px sans-serif").text("Sample");var h=i.availableColorSchemes[0].name,y=(0,c.setupData)(d[e],m),g=y.sortedKeysReverse,x=y.levels,b=(0,c.sort)(t,[g[0]],["Ascending"],[!1],y);(0,s.default)(m,h,b,y);var k=u.append("div").attr("class","row");(0,i.addDownloadLinks)(k,m),(0,i.addTaxaPicker)(k,x,d[e].name),(0,i.addColorPicker)(k,m,t,y),(0,i.addSortByPicker)(k,m,t,y)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(3),s=r(l),i=n(7),c=n(11)},,function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n,r){var a=n.sortMap,s=n.sortedSampleIDs,c=10*s.length,p=600,f={top:20,left:60,right:50,bottom:50},m=200,v=r.keys,h=e.select("g");e.property("colorScheme",t);var y=(0,o.scaleBand)().padding(.1).domain(s).range([0,c]),g=(0,o.scaleLinear)().domain([0,1]).range([p,0]).nice(),x=u.availableColorSchemes.find(function(e){return e.name===t}),b=void 0;if("s"===x.type)b=(0,o.scaleSequential)(x.scheme).domain([0,v.length-1]);else if("o"===x.type){for(var k=[],A=[],P=0;Pl&&(l=e),"rotate(-90)"}),t.select("#x-label").attr("transform","translate("+n/2+","+(r+l+a)+")"),l}function r(e,t,n,r){e.select(".y.axis").call(r),t.select("#y-label").attr("transform","translate(-"+a+","+n/2+")rotate(-90)")}Object.defineProperty(t,"__esModule",{value:!0}),t.setupXAxis=n,t.setupYAxis=r;var a=t.labelOffset=30},function(e,t,n){"use strict";function r(e,t){e.transition().duration(l.transitionDur).style("fill",function(e){return t(e.index)})}function a(e,t,n,a,l,s){e.selectAll("#tooltip").remove();var i=e.append("g").style("display","none").attr("id","tooltip");i.append("rect").attr("height",50).attr("fill","white");var c=i.append("text").style("text-anchor","middle").attr("font-size","12px").attr("font-weight","bold");c.append("tspan").attr("id","ttxlabel").attr("dy","1.2em"),c.append("tspan").attr("id","taxalabel").attr("dy","1.2em"),c.append("tspan").attr("id","abunlabel").attr("dy","1.2em");var d=e.selectAll(".layer").data(l.layers);d.exit().remove();var u=d.enter().append("g").attr("class","layer"),p=d.merge(u).call(r,a).attr("visibility",null).property("taxa",function(e){return e.key}),f=p.selectAll("rect").data(function(e){return e});f.exit().remove();var m=f.enter().append("rect");f.merge(m).attr("x",function(e){return t(e.data[l.first])}).attr("y",function(e){return n(e[1])}).attr("height",function(e){return n(e[0])-n(e[1])}).attr("width",t.bandwidth()).on("mouseover",function(){setTimeout(function(){return i.style("display",null)},500)}).on("mouseout",function(){i.style("display","none")}).on("mousemove",function(e){var t=i.select("text"),n=(0,o.select)(this.parentNode).property("taxa"),r=t.select("#ttxlabel"),a=t.select("#taxalabel"),c=t.select("#abunlabel");r.text(function(){return s[e.data[l.first]]}),a.text(function(){return n}),c.text(function(){return(100*(e[1]-e[0])).toFixed(3)+"%"});var d=t.node().getBBox().width,u=d/2+5;r.attr("x",u),a.attr("x",u),c.attr("x",u),i.select("rect").attr("width",d+10);var p=(0,o.mouse)(this)[0],f=(0,o.mouse)(this)[1]-25;i.attr("transform","translate("+p+","+f+")")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(1)},function(e,t,n){"use strict";function r(e,t,n){e.transition().duration(l.transitionDur).style("fill",function(e){return t(n.indexOf(e))})}function a(e,t,n,a,l){var s=e.property("stackOrder");t.selectAll(".legend").remove();var i=t.selectAll(".legend").data(s),c=i.enter().append("g").attr("class","legend").attr("id",function(e){return"id"+e}).style("font","10px sans-serif"),d=i.merge(c).attr("transform",function(e,t){return"translate(10,"+20*(n.length-t-1)+")"});c.append("rect").attr("width",18).attr("height",18),d.selectAll("rect").attr("x",a).call(r,l,s).on("mouseover",function(){(0,o.select)(this).style("cursor","pointer")}).on("click",function(e){var t=(0,o.select)("#id"+e),r=t.select("rect"),a=r.classed("selected");r.classed("selected",!a).style("stroke",function(){return a?null:"black"}).style("stroke-width",function(){return a?null:2});var l=(0,o.selectAll)(".legend .selected").nodes().map(function(e){return n[(0,o.select)(e).datum()]});(0,o.selectAll)(".layer").attr("visibility",function(e){return 0===l.length?null:l.indexOf(e.key.trim())>-1?null:"hidden"})}),c.append("text").attr("y",9).attr("dy",".35em").attr("text-anchor","start"),d=d.selectAll("text").attr("x",a+24).text(function(e){return n[e]});var u=0;return d.each(function(){var e=this.getComputedTextLength();e>u&&(u=e)}),u}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var o=n(2),l=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e,t,n,r){var a=e.selectAll(".xCtrl").nodes().map(function(e){return e.options[e.selectedIndex].value}),o=e.selectAll(".xOrder").nodes().map(function(e){return e.options[e.selectedIndex].value}),l=e.selectAll(".xLabel").nodes().map(function(e){return"hidden"!==e.type&&e.checked});return(0,b.sort)(n,a,o,l,r)}function l(e,t,n,r){var a=o(e,t,n,r);(0,x.default)(t,t.property("colorScheme"),a,r)}function s(e,t,n,r){var a=e.append("div").attr("class","row"),o=a.append("div").attr("class","col-lg-4"),s=a.append("div").attr("class","col-lg-4"),i=a.append("div").attr("class","col-lg-4"),c=o.append("select").attr("class","xCtrl form-control").on("change",function(){i.select("label").remove();var a=(0,f.select)(this).node(),o=a.options[a.selectedIndex].value,s=r.metaData.indexOf(o)>-1;i.append("label").text(function(){return s?"Relabel X? ":""}).append("input").attr("class","xLabel").attr("type",function(){return s?"checkbox":"hidden"}).property("checked",!0).on("change",function(){l(e,t,n,r)}),l(e,t,n,r)}),d=["Ascending","Descending"];return s.append("select").attr("class","xOrder form-control").on("change",function(){l(e,t,n,r)}).selectAll("option").data(d).enter().append("option").attr("value",function(e){return e}).text(function(e){return e}),e.selectAll(".row").size()>1&&i.append("a").on("click",function(){a.remove(),l(e,t,n,r)}).append("span").attr("class","glyphicon glyphicon-minus-sign text-danger").attr("style","cursor: pointer; cursor: hand;"),c}function i(e,t,n,r){var a=[{label:"Sample Metadata",keys:t},{label:"Taxonomic Abundance",keys:n}],o=e.selectAll("optgroup").data(a);o.exit().remove();var l=o.enter().append("optgroup"),s=o.merge(l).attr("label",function(e){return e.label}),i=s.selectAll("option").data(function(e){return e.keys});i.exit().remove();var c=i.enter().append("option");return i.merge(c).attr("value",function(e){return e}).property("selected",function(e){return e===r}).text(function(e){return e})}function c(e,t,n){var r=e.append("div").attr("class","col-lg-2 form-group taxaPicker");return r.append("label").text("Taxonomic Level"),r.append("select").attr("class","form-control").on("change",function(){var e=(0,f.select)(".container-fluid");e.select(".viz.row").remove(),(0,y.default)(this.selectedIndex)}).selectAll("option").data(t).enter().append("option").attr("value",function(e){return e}).text(function(e){return e}).property("selected",function(e){return e===n}),r}function d(e,t,n,r){var a=e.append("div").attr("class","col-lg-2 form-group colorPicker");a.append("label").text("Color Palette"),a.append("a").attr("style","padding-left: 5px;").attr("href","https://github.com/d3/d3-scale-chromatic#api-reference").attr("title","Click here for more information on the color schemes.").attr("target","_blank").attr("rel","noopener noreferrer").append("span").attr("class","glyphicon glyphicon-info-sign");var l=a.append("select").attr("class","form-control").on("change",function(){var a=this.options[this.selectedIndex].value,l=o(e,t,n,r);(0,x.default)(t,a,l,r)}),s=k.filter(function(e){return"o"===e.type}),i=k.filter(function(e){return"s"===e.type}),c=[{label:"Discrete",keys:s},{label:"Continuous",keys:i}],d=l.selectAll("optgroup").data(c);d.exit().remove();var u=d.enter().append("optgroup"),p=d.merge(u).attr("label",function(e){return e.label}),f=p.selectAll("option").data(function(e){return e.keys});f.exit().remove();var m=f.enter().append("option");return f.merge(m).attr("value",function(e){return e.name}).text(function(e){return e.name}),a}function u(e,t,n,r){var a=r.metaData,o=r.sortedKeysReverse,l=e.append("div").attr("class","col-lg-6 form-group sortByPicker");l.append("label").text("Sort Samples By"),l.append("a").on("click",function(){var e=l.selectAll(".xCtrl");if(e.size()!==a.length+o.length+1){var c=s(l,t,n,r);i(c,a,o,o[0])}}).append("span").attr("class","glyphicon glyphicon-plus-sign").attr("style","padding-left: 5px; cursor: pointer; cursor: hand;");var c=s(l,t,n,r);return i(c,a,o,o[0]),l}function p(e,t){var n=e.append("div").attr("class","col-lg-2 form-group");n.append("label").html(" "),n.append("button").text("Download SVG").attr("class","btn btn-default form-control").on("click",function(){var e=new XMLSerializer,n=e.serializeToString(t.node());n='\r\n'+n;var r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n),a=document.createElement("a");a.setAttribute("href",r),a.setAttribute("download","taxaplot.svg"),document.body.appendChild(a),a.click(),document.body.removeChild(a)})}Object.defineProperty(t,"__esModule",{value:!0}),t.availableColorSchemes=void 0,t.addTaxaPicker=c,t.addColorPicker=d,t.addSortByPicker=u,t.addDownloadLinks=p;var f=n(2),m=n(8),v=a(m),h=n(1),y=r(h),g=n(3),x=r(g),b=n(11),k=t.availableColorSchemes=[{name:"schemeAccent",scheme:v.schemeAccent,type:"o"},{name:"schemeDark2",scheme:v.schemeDark2,type:"o"},{name:"schemePaired",scheme:v.schemePaired,type:"o"},{name:"schemePastel1",scheme:v.schemePastel1,type:"o"},{name:"schemePastel2",scheme:v.schemePastel2,type:"o"},{name:"schemeSet1",scheme:v.schemeSet1,type:"o"},{name:"schemeSet2",scheme:v.schemeSet2,type:"o"},{name:"schemeSet3",scheme:v.schemeSet3,type:"o"},{name:"PRGn",scheme:v.interpolatePRGn,type:"s"},{name:"BrBG",scheme:v.interpolateBrBG,type:"s"},{name:"PiYG",scheme:v.interpolatePiYG,type:"s"},{name:"PuOr",scheme:v.interpolatePuOr,type:"s"},{name:"RdBu",scheme:v.interpolateRdBu,type:"s"},{name:"RdGy",scheme:v.interpolateRdGy,type:"s"},{name:"RdYlBu",scheme:v.interpolateRdYlBu,type:"s"},{name:"RdYlGn",scheme:v.interpolateRdYlGn,type:"s"},{name:"Spectral",scheme:v.interpolateSpectral,type:"s"}]},,,,function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n){var r=e[n],a=t[n];return r===a?(0,y.ascending)(e.position,t.position):(0,x.default)({direction:"asc"})(r,a)}function o(e,t,n){return(0,x.default)({direction:"asc"})(e[n],t[n])}function l(e,t,n){var r=e[n],a=t[n];return r===a?(0,y.descending)(e.position,t.position):(0,x.default)({direction:"desc"})(r,a)}function s(e,t,n){return(0,x.default)({direction:"desc"})(e[n],t[n])}function i(e,t,n){var r=e[n]/e.total,a=t[n]/t.total;return{aRel:r,bRel:a}}function c(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return a===o?(0,y.ascending)(e.position,t.position):(0,y.ascending)(a,o)}function u(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return(0,y.ascending)(a,o)}function p(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return a===o?(0,y.descending)(e.position,t.position):(0,y.descending)(a,o)}function f(e,t,n){var r=i(e,t,n),a=r.aRel,o=r.bRel;return(0,y.descending)(a,o)}function m(e,t){for(var n=0;n-1,g=void 0;v&&"Ascending"===h?g=y?a:c:v&&"Descending"===h?g=y?l:p:v||"Ascending"!==h?v||"Descending"!==h||(g=y?s:f):g=y?o:u,m=function(t,n){return g(t,n,e)},d=d.thenBy(m)});var v={},h=e.sort(d).map(function(e){var n=e[i.first],a=[];return t.forEach(function(t,n){r[n]&&a.push(e[t])}),v[n]=0===a.length?n:a.join("; "),n});return{sortedSampleIDs:h,sortMap:v}}function h(e,t){var n=e.data,r=e.taxaKeys,a=JSON.parse(JSON.stringify(n.columns)),o=void 0,l=void 0,s=a.filter(function(e){return r.indexOf(e)<0}),i=a.splice(0,1)[0];t.property("firstTaxa",i);var c=(0,y.stack)().keys(r).order(function(e){var n=(0,y.stackOrderAscending)(e);return o=new Array(n.length),n.forEach(function(e,t){o[t]=r[e]}),l=o.slice().reverse(),t.property("stackOrder",n),n}).offset(y.stackOffsetExpand),u=c(n);m(n,r);var p=d.map(function(e){return e.name});return{keys:r,columns:a,metaData:s,sortedKeys:o,sortedKeysReverse:l,first:i,layers:u,levels:p}}Object.defineProperty(t,"__esModule",{value:!0}),t.sort=v,t.setupData=h;var y=n(2),g=n(12),x=r(g),b=n(13),k=r(b)}]); \ No newline at end of file diff --git a/q2_taxa/assets/barplot/src/bar.js b/q2_taxa/assets/barplot/src/bar.js index 2a6644f..8eae93f 100644 --- a/q2_taxa/assets/barplot/src/bar.js +++ b/q2_taxa/assets/barplot/src/bar.js @@ -47,7 +47,7 @@ export default function plotBars(chart, x, y, z, dataMeta, sortMap) { .attr('y', d => y(d[1])) .attr('height', d => y(d[0]) - y(d[1])) .attr('width', x.bandwidth()) - .on('mouseover', () => { tooltip.style('display', null); }) + .on('mouseover', () => { setTimeout(() => tooltip.style('display', null), 500); }) .on('mouseout', () => { tooltip.style('display', 'none'); }) .on('mousemove', function mouseMove(d) { const text = tooltip.select('text');