commit/galaxy-central: jgoecks: Pack scripts and add compiled template.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/f3b183e756f9/ changeset: f3b183e756f9 user: jgoecks date: 2012-10-04 18:35:16 summary: Pack scripts and add compiled template. affected #: 3 files diff -r 89c27f6b20f8f261a8e45e33abcc2ed9c1509a71 -r f3b183e756f9b209ef0904718ed547e04c74ab7a static/scripts/packed/templates/compiled/template-visualization-scatterplotControlForm.js --- /dev/null +++ b/static/scripts/packed/templates/compiled/template-visualization-scatterplotControlForm.js @@ -0,0 +1,1 @@ +(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-visualization-scatterplotControlForm"]=b(function(g,n,f,m,l){f=f||g.helpers;var j="",d,i,h="function",k=this.escapeExpression,o=this;function e(t,s){var q="",r,p;q+='\n <option value="';p=f.index;if(p){r=p.call(t,{hash:{}})}else{r=t.index;r=typeof r===h?r():r}q+=k(r)+'">';p=f.name;if(p){r=p.call(t,{hash:{}})}else{r=t.name;r=typeof r===h?r():r}q+=k(r)+"</option>\n ";return q}function c(t,s){var q="",r,p;q+='\n <option value="';p=f.index;if(p){r=p.call(t,{hash:{}})}else{r=t.index;r=typeof r===h?r():r}q+=k(r)+'">';p=f.name;if(p){r=p.call(t,{hash:{}})}else{r=t.name;r=typeof r===h?r():r}q+=k(r)+"</option>\n ";return q}j+='\n<div id="loading-indicator" style="display: none;">\n <img class="loading-img" src="';i=f.loadingIndicatorImagePath;if(i){d=i.call(n,{hash:{}})}else{d=n.loadingIndicatorImagePath;d=typeof d===h?d():d}j+=k(d)+'" />\n <span class="loading-message"></span>\n</div>\n\n';j+='\n<div id="chart-settings">\n\n ';j+='\n <div id="x-column-input">\n <label for="">Data column for X: </label>\n <select name="x-column">\n ';d=n.availableColumns;d=f.each.call(n,d,{hash:{},inverse:o.noop,fn:o.program(1,e,l)});if(d||d===0){j+=d}j+='\n </select>\n </div>\n <div id="y-column-input">\n <label for="">Data column for Y: </label>\n <select name="y-column">\n ';d=n.availableColumns;d=f.each.call(n,d,{hash:{},inverse:o.noop,fn:o.program(3,c,l)});if(d||d===0){j+=d}j+='\n </select>\n </div>\n \n <input id="render-button" type="button" value="Draw" />\n <div class="clear"></div>\n</div>';return j})})(); \ No newline at end of file diff -r 89c27f6b20f8f261a8e45e33abcc2ed9c1509a71 -r f3b183e756f9b209ef0904718ed547e04c74ab7a static/scripts/packed/viz/phyloviz.js --- a/static/scripts/packed/viz/phyloviz.js +++ b/static/scripts/packed/viz/phyloviz.js @@ -1,1 +1,1 @@ -var UserMenuBase=Backbone.View.extend({className:"UserMenuBase",isAcceptableValue:function(e,c,a){var b=this,f=e.val(),g=e.attr("displayLabel")||e.attr("id").replace("phyloViz","");function d(h){return !isNaN(parseFloat(h))&&isFinite(h)}if(!d(f)){alert(g+" is not a number!");return false}if(f>a){alert(g+" is too large.");return false}else{if(f<c){alert(g+" is too small.");return false}}return true},hasIllegalJsonCharacters:function(a){if(a.val().search(/"|'|\\/)!==-1){alert("Named fields cannot contain these illegal characters: double quote(\"), single guote('), or back slash(\\). ");return true}return false}});function PhyloTreeLayout(){var j=this,e=d3.layout.hierarchy().sort(null).value(null),i=360,d="Linear",h=18,f=200,g=0,c=0.5,a=50;j.leafHeight=function(k){if(typeof k==="undefined"){return h}else{h=k;return j}};j.layoutMode=function(k){if(typeof k==="undefined"){return d}else{d=k;return j}};j.layoutAngle=function(k){if(typeof k==="undefined"){return i}if(isNaN(k)||k<0||k>360){return j}else{i=k;return j}};j.separation=function(k){if(typeof k==="undefined"){return f}else{f=k;return j}};j.links=function(k){return d3.layout.tree().links(k)};j.nodes=function(n,l){var m=e.call(j,n,l),k=[],p=0,o=0;m.forEach(function(q){var r=q.data;r.depth=q.depth;p=r.depth>p?r.depth:p;k.push(r)});k.forEach(function(q){if(!q.children){o+=1;q.depth=p}});h=d==="Circular"?i/o:h;g=0;b(k[0],p,h,null);return k};function b(o,q,n,m){var l=o.children,k=0;var p=o.dist||c;p=p>1?1:p;o.dist=p;if(m!==null){o.y0=m.y0+p*f}else{o.y0=a}if(!l){o.x0=g++*n}else{l.forEach(function(r){r.parent=o;k+=b(r,q,n,o)});o.x0=k/l.length}o.x=o.x0;o.y=o.y0;return o.x0}return j}var PhyloTree=Visualization.extend({defaults:{layout:"Linear",separation:250,leafHeight:18,type:"phyloviz",title:"Title",scaleFactor:1,translate:[0,0],fontSize:12,selectedNode:null,nodeAttrChangedTime:0},root:{},toggle:function(a){if(typeof a==="undefined"){return}if(a.children){a._children=a.children;a.children=null}else{a.children=a._children;a._children=null}},toggleAll:function(a){if(a.children&&a.children.length!==0){a.children.forEach(this.toggleAll);toggle(a)}},getData:function(){return this.root},save:function(){var a=this.root;b(a);this.set("root",a);function b(d){delete d.parent;if(d._selected){delete d._selected}d.children?d.children.forEach(b):0;d._children?d._children.forEach(b):0}var c=jQuery.extend(true,{},this.attributes);c.selectedNode=null;show_message("Saving to Galaxy","progress");return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(c)},success:function(d){var e=d.url.split("id=")[1].split("&")[0],f="/phyloviz/visualization?id="+e;window.history.pushState({},"",f+window.location.hash);hide_modal()}})}});var PhylovizLayoutBase=Backbone.View.extend({defaults:{nodeRadius:4.5},stdInit:function(b){var a=this;a.model.on("change:separation change:leafHeight change:fontSize change:nodeAttrChangedTime",a.updateAndRender,a);a.vis=b.vis;a.i=0;a.maxDepth=-1;a.width=b.width;a.height=b.height},updateAndRender:function(c){var b=d3.select(".vis"),a=this;c=c||a.model.root;a.renderNodes(c);a.renderLinks(c);a.addTooltips()},renderLinks:function(a){var j=this;var b=j.diagonal;var c=j.duration;var e=j.layoutMode;var g=j.vis.selectAll("g.completeLink").data(j.tree.links(j.nodes),function(k){return k.target.id});var i=function(k){k.pos0=k.source.y0+" "+k.source.x0;k.pos1=k.source.y0+" "+k.target.x0;k.pos2=k.target.y0+" "+k.target.x0};var h=g.enter().insert("svg:g","g.node").attr("class","completeLink");h.append("svg:path").attr("class","link").attr("d",function(k){i(k);return"M "+k.pos0+" L "+k.pos1});var f=g.transition().duration(500);f.select("path.link").attr("d",function(k){i(k);return"M "+k.pos0+" L "+k.pos1+" L "+k.pos2});var d=g.exit().remove()},selectNode:function(b){var a=this;d3.selectAll("g.node").classed("selectedHighlight",function(c){if(b.id===c.id){if(b._selected){delete b._selected;return false}else{b._selected=true;return true}}return false});a.model.set("selectedNode",b);$("#phyloVizSelectedNodeName").val(b.name);$("#phyloVizSelectedNodeDist").val(b.dist);$("#phyloVizSelectedNodeAnnotation").val(b.annotation||"")},addTooltips:function(){$(".bs-tooltip").remove();$(".node").attr("data-original-title",function(){var b=this.__data__,a=b.annotation||"None";return b?(b.name?b.name+"<br/>":"")+"Dist: "+b.dist+" <br/>Annotation: "+a:""}).tooltip({placement:"top",trigger:"hover"})}});var PhylovizLinearView=PhylovizLayoutBase.extend({initialize:function(b){var a=this;a.margins=b.margins;a.layoutMode="Linear";a.stdInit(b);a.layout();a.updateAndRender(a.model.root)},layout:function(){var a=this;a.tree=new PhyloTreeLayout().layoutMode("Linear");a.diagonal=d3.svg.diagonal().projection(function(b){return[b.y,b.x]})},renderNodes:function(a){var h=this,i=h.model.get("fontSize")+"px";h.tree.separation(h.model.get("separation")).leafHeight(h.model.get("leafHeight"));var d=500,b=h.tree.separation(h.model.get("separation")).nodes(h.model.root);var c=h.vis.selectAll("g.node").data(b,function(j){return j.name+j.id||(j.id=++h.i)});h.nodes=b;h.duration=d;var e=c.enter().append("svg:g").attr("class","node").on("dblclick",function(){d3.event.stopPropagation()}).on("click",function(j){if(d3.event.altKey){h.selectNode(j)}else{if(j.children&&j.children.length===0){return}h.model.toggle(j);h.updateAndRender(j)}});e.attr("transform",function(j){return"translate("+a.y0+","+a.x0+")"});e.append("svg:circle").attr("r",0.000001).style("fill",function(j){return j._children?"lightsteelblue":"#fff"});e.append("svg:text").attr("class","nodeLabel").attr("x",function(j){return j.children||j._children?-10:10}).attr("dy",".35em").attr("text-anchor",function(j){return j.children||j._children?"end":"start"}).style("fill-opacity",0.000001);var f=c.transition().duration(d);f.attr("transform",function(j){return"translate("+j.y+","+j.x+")"});f.select("circle").attr("r",h.defaults.nodeRadius).style("fill",function(j){return j._children?"lightsteelblue":"#fff"});f.select("text").style("fill-opacity",1).style("font-size",i).text(function(j){return j.name});var g=c.exit().transition().duration(d).remove();g.select("circle").attr("r",0.000001);g.select("text").style("fill-opacity",0.000001);b.forEach(function(j){j.x0=j.x;j.y0=j.y})}});var PhylovizView=Backbone.View.extend({className:"phyloviz",initialize:function(b){var a=this;a.MIN_SCALE=0.05;a.MAX_SCALE=5;a.MAX_DISPLACEMENT=500;a.margins=[10,60,10,80];a.width=$("#PhyloViz").width();a.height=$("#PhyloViz").height();a.radius=a.width;a.data=b.data;$(window).resize(function(){a.width=$("#PhyloViz").width();a.height=$("#PhyloViz").height();a.render()});a.phyloTree=new PhyloTree(b.config);a.phyloTree.root=a.data;a.zoomFunc=d3.behavior.zoom().scaleExtent([a.MIN_SCALE,a.MAX_SCALE]);a.zoomFunc.translate(a.phyloTree.get("translate"));a.zoomFunc.scale(a.phyloTree.get("scaleFactor"));a.navMenu=new HeaderButtons(a);a.settingsMenu=new SettingsMenu({phyloTree:a.phyloTree});a.nodeSelectionView=new NodeSelectionView({phyloTree:a.phyloTree});a.search=new PhyloVizSearch();setTimeout(function(){a.zoomAndPan()},1000)},render:function(){var b=this;$("#PhyloViz").empty();b.mainSVG=d3.select("#PhyloViz").append("svg:svg").attr("width",b.width).attr("height",b.height).attr("pointer-events","all").call(b.zoomFunc.on("zoom",function(){b.zoomAndPan()}));b.boundingRect=b.mainSVG.append("svg:rect").attr("class","boundingRect").attr("width",b.width).attr("height",b.height).attr("stroke","black").attr("fill","white");b.vis=b.mainSVG.append("svg:g").attr("class","vis");b.layoutOptions={model:b.phyloTree,width:b.width,height:b.height,vis:b.vis,margins:b.margins};$("#title").text("Phylogenetic Tree from "+b.phyloTree.get("title")+":");var a=new PhylovizLinearView(b.layoutOptions)},zoomAndPan:function(a){if(typeof a!=="undefined"){var g=a.zoom,c=a.translate}var j=this,e=j.zoomFunc.scale(),i=j.zoomFunc.translate(),f="",h="";switch(g){case"reset":e=1;i=[0,0];break;case"+":e*=1.1;break;case"-":e*=0.9;break;default:if(typeof g==="number"){e=g}else{if(d3.event!==null){e=d3.event.scale}}}if(e<j.MIN_SCALE||e>j.MAX_SCALE){return}j.zoomFunc.scale(e);f="translate("+j.margins[3]+","+j.margins[0]+") scale("+e+")";if(d3.event!==null){h="translate("+d3.event.translate+")"}else{if(typeof c!=="undefined"){var d=c.split(",")[0];var b=c.split(",")[1];if(!isNaN(d)&&!isNaN(b)){i=[i[0]+parseFloat(d),i[1]+parseFloat(b)]}}j.zoomFunc.translate(i);h="translate("+i+")"}j.phyloTree.set("scaleFactor",e);j.phyloTree.set("translate",i);j.vis.attr("transform",h+f)},reloadViz:function(){var b=this,d=$("#phylovizNexSelector :selected").val(),a=b.phyloTree.get("dataset_id"),c="phyloviz/getJsonData?dataset_id="+a+"&treeIndex="+String(d);$.getJSON(c,function(e){window.initPhyloViz(e.data,e.config)})}});var HeaderButtons=Backbone.View.extend({initialize:function(b){var a=this;a.phylovizView=b;$("#panelHeaderRightBtns").empty();$("#phyloVizNavBtns").empty();$("#phylovizNexSelector").off();a.initNavBtns();a.initRightHeaderBtns();$("#phylovizNexSelector").off().on("change",function(){a.phylovizView.reloadViz()})},initRightHeaderBtns:function(){var a=this;rightMenu=create_icon_buttons_menu([{icon_class:"gear",title:"PhyloViz Settings",on_click:function(){$("#SettingsMenu").show();a.settingsMenu.updateUI()}},{icon_class:"disk",title:"Save visualization",on_click:function(){var b=$("#phylovizNexSelector option:selected").text();if(b){a.phylovizView.phyloTree.set("title",b)}a.phylovizView.phyloTree.save()}},{icon_class:"chevron-expand",title:"Search / Edit Nodes",on_click:function(){$("#nodeSelectionView").show()}},{icon_class:"information",title:"Phyloviz Help",on_click:function(){window.open("http://wiki.g2.bx.psu.edu/Learn/Visualization/PhylogeneticTree")}}],{tooltip_config:{placement:"bottom"}});$("#panelHeaderRightBtns").append(rightMenu.$el)},initNavBtns:function(){var a=this,b=create_icon_buttons_menu([{icon_class:"zoom-in",title:"Zoom in",on_click:function(){a.phylovizView.zoomAndPan({zoom:"+"})}},{icon_class:"zoom-out",title:"Zoom out",on_click:function(){a.phylovizView.zoomAndPan({zoom:"-"})}},{icon_class:"arrow-circle",title:"Reset Zoom/Pan",on_click:function(){a.phylovizView.zoomAndPan({zoom:"reset"})}}],{tooltip_config:{placement:"bottom"}});$("#phyloVizNavBtns").append(b.$el)}});var SettingsMenu=UserMenuBase.extend({className:"Settings",initialize:function(b){var a=this;a.phyloTree=b.phyloTree;a.el=$("#SettingsMenu");a.inputs={separation:$("#phyloVizTreeSeparation"),leafHeight:$("#phyloVizTreeLeafHeight"),fontSize:$("#phyloVizTreeFontSize")};$("#settingsCloseBtn").off().on("click",function(){a.el.hide()});$("#phylovizResetSettingsBtn").off().on("click",function(){a.resetToDefaults()});$("#phylovizApplySettingsBtn").off().on("click",function(){a.apply()})},apply:function(){var a=this;if(!a.isAcceptableValue(a.inputs.separation,50,2500)||!a.isAcceptableValue(a.inputs.leafHeight,5,30)||!a.isAcceptableValue(a.inputs.fontSize,5,20)){return}$.each(a.inputs,function(b,c){a.phyloTree.set(b,c.val())})},updateUI:function(){var a=this;$.each(a.inputs,function(b,c){c.val(a.phyloTree.get(b))})},resetToDefaults:function(){$(".bs-tooltip").remove();var a=this;$.each(a.phyloTree.defaults,function(b,c){a.phyloTree.set(b,c)});a.updateUI()},render:function(){}});var NodeSelectionView=UserMenuBase.extend({className:"Settings",initialize:function(b){var a=this;a.el=$("#nodeSelectionView");a.phyloTree=b.phyloTree;a.UI={enableEdit:$("#phylovizEditNodesCheck"),saveChanges:$("#phylovizNodeSaveChanges"),cancelChanges:$("#phylovizNodeCancelChanges"),name:$("#phyloVizSelectedNodeName"),dist:$("#phyloVizSelectedNodeDist"),annotation:$("#phyloVizSelectedNodeAnnotation")};a.valuesOfConcern={name:null,dist:null,annotation:null};$("#nodeSelCloseBtn").off().on("click",function(){a.el.hide()});a.UI.saveChanges.off().on("click",function(){a.updateNodes()});a.UI.cancelChanges.off().on("click",function(){a.cancelChanges()});(function(c){c.fn.enable=function(d){return c(this).each(function(){if(d){c(this).removeAttr("disabled")}else{c(this).attr("disabled","disabled")}})}})(jQuery);a.UI.enableEdit.off().on("click",function(){a.toggleUI()})},toggleUI:function(){var a=this,b=a.UI.enableEdit.is(":checked");!b?a.cancelChanges():"";$.each(a.valuesOfConcern,function(c,d){a.UI[c].enable(b)});if(b){a.UI.saveChanges.show();a.UI.cancelChanges.show()}else{a.UI.saveChanges.hide();a.UI.cancelChanges.hide()}},cancelChanges:function(){var a=this,b=a.phyloTree.get("selectedNode");if(b){$.each(a.valuesOfConcern,function(c,d){a.UI[c].val(b[c])})}},updateNodes:function(){var a=this,b=a.phyloTree.get("selectedNode");if(b){if(!a.isAcceptableValue(a.UI.dist,0,1)||a.hasIllegalJsonCharacters(a.UI.name)||a.hasIllegalJsonCharacters(a.UI.annotation)){return}$.each(a.valuesOfConcern,function(c,d){(b[c])=a.UI[c].val()});a.phyloTree.set("nodeAttrChangedTime",new Date())}else{alert("No node selected")}}});var PhyloVizSearch=UserMenuBase.extend({initialize:function(){var a=this;$("#phyloVizSearchBtn").on("click",function(){var c=$("#phyloVizSearchTerm"),d=$("#phyloVizSearchCondition").val().split("-"),b=d[0],e=d[1];a.hasIllegalJsonCharacters(c);if(b==="dist"){a.isAcceptableValue(c,0,1)}a.searchTree(b,e,c.val())})},searchTree:function(a,c,b){d3.selectAll("g.node").classed("searchHighlight",function(f){var e=f[a];if(typeof e!=="undefined"&&e!==null){if(a==="dist"){switch(c){case"greaterEqual":return e>=+b;case"lesserEqual":return e<=+b;default:return}}else{if(a==="name"||a==="annotation"){return e.toLowerCase().indexOf(b.toLowerCase())!==-1}}}})}}); \ No newline at end of file +define(["libs/d3","viz/visualization"],function(l,f){var k=Backbone.View.extend({className:"UserMenuBase",isAcceptableValue:function(q,o,m){var n=this,r=q.val(),s=q.attr("displayLabel")||q.attr("id").replace("phyloViz","");function p(t){return !isNaN(parseFloat(t))&&isFinite(t)}if(!p(r)){alert(s+" is not a number!");return false}if(r>m){alert(s+" is too large.");return false}else{if(r<o){alert(s+" is too small.");return false}}return true},hasIllegalJsonCharacters:function(m){if(m.val().search(/"|'|\\/)!==-1){alert("Named fields cannot contain these illegal characters: double quote(\"), single guote('), or back slash(\\). ");return true}return false}});function g(){var v=this,q=l.layout.hierarchy().sort(null).value(null),u=360,p="Linear",t=18,r=200,s=0,o=0.5,m=50;v.leafHeight=function(w){if(typeof w==="undefined"){return t}else{t=w;return v}};v.layoutMode=function(w){if(typeof w==="undefined"){return p}else{p=w;return v}};v.layoutAngle=function(w){if(typeof w==="undefined"){return u}if(isNaN(w)||w<0||w>360){return v}else{u=w;return v}};v.separation=function(w){if(typeof w==="undefined"){return r}else{r=w;return v}};v.links=function(w){return l.layout.tree().links(w)};v.nodes=function(z,x){var y=q.call(v,z,x),w=[],B=0,A=0;y.forEach(function(C){var D=C.data;D.depth=C.depth;B=D.depth>B?D.depth:B;w.push(D)});w.forEach(function(C){if(!C.children){A+=1;C.depth=B}});t=p==="Circular"?u/A:t;s=0;n(w[0],B,t,null);return w};function n(A,C,z,y){var x=A.children,w=0;var B=A.dist||o;B=B>1?1:B;A.dist=B;if(y!==null){A.y0=y.y0+B*r}else{A.y0=m}if(!x){A.x0=s++*z}else{x.forEach(function(D){D.parent=A;w+=n(D,C,z,A)});A.x0=w/x.length}A.x=A.x0;A.y=A.y0;return A.x0}return v}var b=f.Visualization.extend({defaults:{layout:"Linear",separation:250,leafHeight:18,type:"phyloviz",title:"Title",scaleFactor:1,translate:[0,0],fontSize:12,selectedNode:null,nodeAttrChangedTime:0},root:{},toggle:function(m){if(typeof m==="undefined"){return}if(m.children){m._children=m.children;m.children=null}else{m.children=m._children;m._children=null}},toggleAll:function(m){if(m.children&&m.children.length!==0){m.children.forEach(this.toggleAll);toggle(m)}},getData:function(){return this.root},save:function(){var m=this.root;n(m);this.set("root",m);function n(p){delete p.parent;if(p._selected){delete p._selected}if(p.children){p.children.forEach(n)}if(p._children){p._children.forEach(n)}}var o=jQuery.extend(true,{},this.attributes);o.selectedNode=null;show_message("Saving to Galaxy","progress");return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(o)},success:function(p){var q=p.url.split("id=")[1].split("&")[0],r="/phyloviz/visualization?id="+q;window.history.pushState({},"",r+window.location.hash);hide_modal()}})}});var d=Backbone.View.extend({defaults:{nodeRadius:4.5},stdInit:function(n){var m=this;m.model.on("change:separation change:leafHeight change:fontSize change:nodeAttrChangedTime",m.updateAndRender,m);m.vis=n.vis;m.i=0;m.maxDepth=-1;m.width=n.width;m.height=n.height},updateAndRender:function(o){var n=l.select(".vis"),m=this;o=o||m.model.root;m.renderNodes(o);m.renderLinks(o);m.addTooltips()},renderLinks:function(m){var v=this;var n=v.diagonal;var o=v.duration;var q=v.layoutMode;var s=v.vis.selectAll("g.completeLink").data(v.tree.links(v.nodes),function(w){return w.target.id});var u=function(w){w.pos0=w.source.y0+" "+w.source.x0;w.pos1=w.source.y0+" "+w.target.x0;w.pos2=w.target.y0+" "+w.target.x0};var t=s.enter().insert("svg:g","g.node").attr("class","completeLink");t.append("svg:path").attr("class","link").attr("d",function(w){u(w);return"M "+w.pos0+" L "+w.pos1});var r=s.transition().duration(500);r.select("path.link").attr("d",function(w){u(w);return"M "+w.pos0+" L "+w.pos1+" L "+w.pos2});var p=s.exit().remove()},selectNode:function(n){var m=this;l.selectAll("g.node").classed("selectedHighlight",function(o){if(n.id===o.id){if(n._selected){delete n._selected;return false}else{n._selected=true;return true}}return false});m.model.set("selectedNode",n);$("#phyloVizSelectedNodeName").val(n.name);$("#phyloVizSelectedNodeDist").val(n.dist);$("#phyloVizSelectedNodeAnnotation").val(n.annotation||"")},addTooltips:function(){$(".bs-tooltip").remove();$(".node").attr("data-original-title",function(){var n=this.__data__,m=n.annotation||"None";return n?(n.name?n.name+"<br/>":"")+"Dist: "+n.dist+" <br/>Annotation: "+m:""}).tooltip({placement:"top",trigger:"hover"})}});var a=d.extend({initialize:function(n){var m=this;m.margins=n.margins;m.layoutMode="Linear";m.stdInit(n);m.layout();m.updateAndRender(m.model.root)},layout:function(){var m=this;m.tree=new g().layoutMode("Linear");m.diagonal=l.svg.diagonal().projection(function(n){return[n.y,n.x]})},renderNodes:function(m){var t=this,u=t.model.get("fontSize")+"px";t.tree.separation(t.model.get("separation")).leafHeight(t.model.get("leafHeight"));var p=500,n=t.tree.separation(t.model.get("separation")).nodes(t.model.root);var o=t.vis.selectAll("g.node").data(n,function(v){return v.name+v.id||(v.id=++t.i)});t.nodes=n;t.duration=p;var q=o.enter().append("svg:g").attr("class","node").on("dblclick",function(){l.event.stopPropagation()}).on("click",function(v){if(l.event.altKey){t.selectNode(v)}else{if(v.children&&v.children.length===0){return}t.model.toggle(v);t.updateAndRender(v)}});q.attr("transform",function(v){return"translate("+m.y0+","+m.x0+")"});q.append("svg:circle").attr("r",0.000001).style("fill",function(v){return v._children?"lightsteelblue":"#fff"});q.append("svg:text").attr("class","nodeLabel").attr("x",function(v){return v.children||v._children?-10:10}).attr("dy",".35em").attr("text-anchor",function(v){return v.children||v._children?"end":"start"}).style("fill-opacity",0.000001);var r=o.transition().duration(p);r.attr("transform",function(v){return"translate("+v.y+","+v.x+")"});r.select("circle").attr("r",t.defaults.nodeRadius).style("fill",function(v){return v._children?"lightsteelblue":"#fff"});r.select("text").style("fill-opacity",1).style("font-size",u).text(function(v){return v.name});var s=o.exit().transition().duration(p).remove();s.select("circle").attr("r",0.000001);s.select("text").style("fill-opacity",0.000001);n.forEach(function(v){v.x0=v.x;v.y0=v.y})}});var i=Backbone.View.extend({className:"phyloviz",initialize:function(n){var m=this;m.MIN_SCALE=0.05;m.MAX_SCALE=5;m.MAX_DISPLACEMENT=500;m.margins=[10,60,10,80];m.width=$("#PhyloViz").width();m.height=$("#PhyloViz").height();m.radius=m.width;m.data=n.data;$(window).resize(function(){m.width=$("#PhyloViz").width();m.height=$("#PhyloViz").height();m.render()});m.phyloTree=new b(n.config);m.phyloTree.root=m.data;m.zoomFunc=l.behavior.zoom().scaleExtent([m.MIN_SCALE,m.MAX_SCALE]);m.zoomFunc.translate(m.phyloTree.get("translate"));m.zoomFunc.scale(m.phyloTree.get("scaleFactor"));m.navMenu=new c(m);m.settingsMenu=new h({phyloTree:m.phyloTree});m.nodeSelectionView=new e({phyloTree:m.phyloTree});m.search=new j();setTimeout(function(){m.zoomAndPan()},1000)},render:function(){var n=this;$("#PhyloViz").empty();n.mainSVG=l.select("#PhyloViz").append("svg:svg").attr("width",n.width).attr("height",n.height).attr("pointer-events","all").call(n.zoomFunc.on("zoom",function(){n.zoomAndPan()}));n.boundingRect=n.mainSVG.append("svg:rect").attr("class","boundingRect").attr("width",n.width).attr("height",n.height).attr("stroke","black").attr("fill","white");n.vis=n.mainSVG.append("svg:g").attr("class","vis");n.layoutOptions={model:n.phyloTree,width:n.width,height:n.height,vis:n.vis,margins:n.margins};$("#title").text("Phylogenetic Tree from "+n.phyloTree.get("title")+":");var m=new a(n.layoutOptions)},zoomAndPan:function(m){var s,o;if(typeof m!=="undefined"){s=m.zoom;o=m.translate}var v=this,q=v.zoomFunc.scale(),u=v.zoomFunc.translate(),r="",t="";switch(s){case"reset":q=1;u=[0,0];break;case"+":q*=1.1;break;case"-":q*=0.9;break;default:if(typeof s==="number"){q=s}else{if(l.event!==null){q=l.event.scale}}}if(q<v.MIN_SCALE||q>v.MAX_SCALE){return}v.zoomFunc.scale(q);r="translate("+v.margins[3]+","+v.margins[0]+") scale("+q+")";if(l.event!==null){t="translate("+l.event.translate+")"}else{if(typeof o!=="undefined"){var p=o.split(",")[0];var n=o.split(",")[1];if(!isNaN(p)&&!isNaN(n)){u=[u[0]+parseFloat(p),u[1]+parseFloat(n)]}}v.zoomFunc.translate(u);t="translate("+u+")"}v.phyloTree.set("scaleFactor",q);v.phyloTree.set("translate",u);v.vis.attr("transform",t+r)},reloadViz:function(){var n=this,p=$("#phylovizNexSelector :selected").val(),m=n.phyloTree.get("dataset_id"),o="phyloviz/getJsonData?dataset_id="+m+"&treeIndex="+String(p);$.getJSON(o,function(q){window.initPhyloViz(q.data,q.config)})}});var c=Backbone.View.extend({initialize:function(n){var m=this;m.phylovizView=n;$("#panelHeaderRightBtns").empty();$("#phyloVizNavBtns").empty();$("#phylovizNexSelector").off();m.initNavBtns();m.initRightHeaderBtns();$("#phylovizNexSelector").off().on("change",function(){m.phylovizView.reloadViz()})},initRightHeaderBtns:function(){var m=this;rightMenu=create_icon_buttons_menu([{icon_class:"gear",title:"PhyloViz Settings",on_click:function(){$("#SettingsMenu").show();m.settingsMenu.updateUI()}},{icon_class:"disk",title:"Save visualization",on_click:function(){var n=$("#phylovizNexSelector option:selected").text();if(n){m.phylovizView.phyloTree.set("title",n)}m.phylovizView.phyloTree.save()}},{icon_class:"chevron-expand",title:"Search / Edit Nodes",on_click:function(){$("#nodeSelectionView").show()}},{icon_class:"information",title:"Phyloviz Help",on_click:function(){window.open("http://wiki.g2.bx.psu.edu/Learn/Visualization/PhylogeneticTree")}}],{tooltip_config:{placement:"bottom"}});$("#panelHeaderRightBtns").append(rightMenu.$el)},initNavBtns:function(){var m=this,n=create_icon_buttons_menu([{icon_class:"zoom-in",title:"Zoom in",on_click:function(){m.phylovizView.zoomAndPan({zoom:"+"})}},{icon_class:"zoom-out",title:"Zoom out",on_click:function(){m.phylovizView.zoomAndPan({zoom:"-"})}},{icon_class:"arrow-circle",title:"Reset Zoom/Pan",on_click:function(){m.phylovizView.zoomAndPan({zoom:"reset"})}}],{tooltip_config:{placement:"bottom"}});$("#phyloVizNavBtns").append(n.$el)}});var h=k.extend({className:"Settings",initialize:function(n){var m=this;m.phyloTree=n.phyloTree;m.el=$("#SettingsMenu");m.inputs={separation:$("#phyloVizTreeSeparation"),leafHeight:$("#phyloVizTreeLeafHeight"),fontSize:$("#phyloVizTreeFontSize")};$("#settingsCloseBtn").off().on("click",function(){m.el.hide()});$("#phylovizResetSettingsBtn").off().on("click",function(){m.resetToDefaults()});$("#phylovizApplySettingsBtn").off().on("click",function(){m.apply()})},apply:function(){var m=this;if(!m.isAcceptableValue(m.inputs.separation,50,2500)||!m.isAcceptableValue(m.inputs.leafHeight,5,30)||!m.isAcceptableValue(m.inputs.fontSize,5,20)){return}$.each(m.inputs,function(n,o){m.phyloTree.set(n,o.val())})},updateUI:function(){var m=this;$.each(m.inputs,function(n,o){o.val(m.phyloTree.get(n))})},resetToDefaults:function(){$(".bs-tooltip").remove();var m=this;$.each(m.phyloTree.defaults,function(n,o){m.phyloTree.set(n,o)});m.updateUI()},render:function(){}});var e=k.extend({className:"Settings",initialize:function(n){var m=this;m.el=$("#nodeSelectionView");m.phyloTree=n.phyloTree;m.UI={enableEdit:$("#phylovizEditNodesCheck"),saveChanges:$("#phylovizNodeSaveChanges"),cancelChanges:$("#phylovizNodeCancelChanges"),name:$("#phyloVizSelectedNodeName"),dist:$("#phyloVizSelectedNodeDist"),annotation:$("#phyloVizSelectedNodeAnnotation")};m.valuesOfConcern={name:null,dist:null,annotation:null};$("#nodeSelCloseBtn").off().on("click",function(){m.el.hide()});m.UI.saveChanges.off().on("click",function(){m.updateNodes()});m.UI.cancelChanges.off().on("click",function(){m.cancelChanges()});(function(o){o.fn.enable=function(p){return o(this).each(function(){if(p){o(this).removeAttr("disabled")}else{o(this).attr("disabled","disabled")}})}})(jQuery);m.UI.enableEdit.off().on("click",function(){m.toggleUI()})},toggleUI:function(){var m=this,n=m.UI.enableEdit.is(":checked");if(!n){m.cancelChanges()}$.each(m.valuesOfConcern,function(o,p){m.UI[o].enable(n)});if(n){m.UI.saveChanges.show();m.UI.cancelChanges.show()}else{m.UI.saveChanges.hide();m.UI.cancelChanges.hide()}},cancelChanges:function(){var m=this,n=m.phyloTree.get("selectedNode");if(n){$.each(m.valuesOfConcern,function(o,p){m.UI[o].val(n[o])})}},updateNodes:function(){var m=this,n=m.phyloTree.get("selectedNode");if(n){if(!m.isAcceptableValue(m.UI.dist,0,1)||m.hasIllegalJsonCharacters(m.UI.name)||m.hasIllegalJsonCharacters(m.UI.annotation)){return}$.each(m.valuesOfConcern,function(o,p){(n[o])=m.UI[o].val()});m.phyloTree.set("nodeAttrChangedTime",new Date())}else{alert("No node selected")}}});var j=k.extend({initialize:function(){var m=this;$("#phyloVizSearchBtn").on("click",function(){var o=$("#phyloVizSearchTerm"),p=$("#phyloVizSearchCondition").val().split("-"),n=p[0],q=p[1];m.hasIllegalJsonCharacters(o);if(n==="dist"){m.isAcceptableValue(o,0,1)}m.searchTree(n,q,o.val())})},searchTree:function(m,o,n){l.selectAll("g.node").classed("searchHighlight",function(q){var p=q[m];if(typeof p!=="undefined"&&p!==null){if(m==="dist"){switch(o){case"greaterEqual":return p>=+n;case"lesserEqual":return p<=+n;default:return}}else{if(m==="name"||m==="annotation"){return p.toLowerCase().indexOf(n.toLowerCase())!==-1}}}})}});return{PhylovizView:i}}); \ No newline at end of file diff -r 89c27f6b20f8f261a8e45e33abcc2ed9c1509a71 -r f3b183e756f9b209ef0904718ed547e04c74ab7a static/scripts/packed/viz/scatterplot.js --- a/static/scripts/packed/viz/scatterplot.js +++ b/static/scripts/packed/viz/scatterplot.js @@ -1,1 +1,1 @@ -define(["../libs/underscore","../libs/d3","../mvc/base-mvc"],function(){function b(f){var i=this,d=10,h=7,g=10,e=8,c=5;this.log=function(){if(this.debugging&&console&&console.debug){var j=Array.prototype.slice.call(arguments);j.unshift(this.toString());console.debug.apply(null,j)}};this.log("new TwoVarScatterplot:",f);this.defaults={id:"TwoVarScatterplot",containerSelector:"body",maxDataPoints:30000,bubbleRadius:4,entryAnimDuration:500,xNumTicks:10,yNumTicks:10,xAxisLabelBumpY:40,yAxisLabelBumpX:-35,width:500,height:500,marginTop:50,marginRight:50,marginBottom:50,marginLeft:50,xMin:null,xMax:null,yMin:null,yMax:null,xLabel:"X",yLabel:"Y"};this.config=_.extend({},this.defaults,f);this.updateConfig=function(j){_.extend(this.config,j)};this.toString=function(){return this.config.id};this.translateStr=function(j,k){return"translate("+j+","+k+")"};this.rotateStr=function(k,j,l){return"rotate("+k+","+j+","+l+")"};this.svg=d3.select(this.config.containerSelector).append("svg:svg").attr("class","chart").style("display","none");this.content=this.svg.append("svg:g").attr("class","content");this.xAxis=this.content.append("g").attr("class","axis").attr("id","x-axis");this.xAxisLabel=this.xAxis.append("text").attr("class","axis-label").attr("id","x-axis-label");this.yAxis=this.content.append("g").attr("class","axis").attr("id","y-axis");this.yAxisLabel=this.yAxis.append("text").attr("class","axis-label").attr("id","y-axis-label");this.log("built svg:",d3.selectAll("svg"));this.adjustChartDimensions=function(m,k,j,l){m=m||0;k=k||0;j=j||0;l=l||0;this.svg.attr("width",this.config.width+(this.config.marginRight+k)+(this.config.marginLeft+l)).attr("height",this.config.height+(this.config.marginTop+m)+(this.config.marginBottom+j)).style("display","block");this.content=this.svg.select("g.content").attr("transform",this.translateStr(this.config.marginLeft+l,this.config.marginTop+m))};this.preprocessData=function(j){return(j.length>this.config.maxDataPoints)?(j.slice(0,this.config.maxDataPoints)):(j)};this.setUpDomains=function(j,l,k){this.log("setUpDomains");this.xMin=this.config.xMin||(k)?(k[0].min):(d3.min(j));this.xMax=this.config.xMax||(k)?(k[0].max):(d3.max(j));this.yMin=this.config.yMin||(k)?(k[1].min):(d3.min(l));this.yMax=this.config.yMax||(k)?(k[1].max):(d3.max(l))};this.setUpScales=function(){this.xScale=d3.scale.linear().domain([this.xMin,this.xMax]).range([0,this.config.width]),this.yScale=d3.scale.linear().domain([this.yMin,this.yMax]).range([this.config.height,0])};this.setUpXAxis=function(){this.xAxisFn=d3.svg.axis().scale(this.xScale).ticks(this.config.xNumTicks).orient("bottom");this.xAxis.attr("transform",this.translateStr(0,this.config.height)).call(this.xAxisFn);this.xLongestLabel=d3.max(_.map([this.xMin,this.xMax],function(j){return(String(j)).length}));if(this.xLongestLabel>=c){this.xAxis.selectAll("g").filter(":nth-child(odd)").style("display","none")}this.xAxisLabel.attr("x",this.config.width/2).attr("y",this.config.xAxisLabelBumpY).attr("text-anchor","middle").text(this.config.xLabel)};this.setUpYAxis=function(){this.yAxisFn=d3.svg.axis().scale(this.yScale).ticks(this.config.yNumTicks).orient("left");this.yAxis.call(this.yAxisFn);this.log("yAxis:",this.yAxis);var j=this.yAxis.selectAll("text").filter(function(n,m){return m!==0});this.yLongestLabel=d3.max(j[0].map(function(n,m){return(d3.select(n).text()).length}))||0;var k=d+(this.yLongestLabel*h)+e+g;this.config.yAxisLabelBumpX=-(k-g);if(this.config.marginLeft<k){var l=(k)-this.config.marginLeft;l=(l<0)?(0):(l);this.log("adjusting:",l);this.adjustChartDimensions(0,0,0,l)}this.yAxisLabel.attr("x",this.config.yAxisLabelBumpX).attr("y",this.config.height/2).attr("text-anchor","middle").attr("transform",this.rotateStr(-90,this.config.yAxisLabelBumpX,this.config.height/2)).text(this.config.yLabel)};this.renderGrid=function(){this.vGridLines=this.content.selectAll("line.v-grid-line").data(this.xScale.ticks(this.xAxisFn.ticks()[0]));this.vGridLines.enter().append("svg:line").classed("grid-line v-grid-line",true);this.vGridLines.attr("x1",this.xScale).attr("y1",0).attr("x2",this.xScale).attr("y2",this.config.height);this.vGridLines.exit().remove();this.hGridLines=this.content.selectAll("line.h-grid-line").data(this.yScale.ticks(this.yAxisFn.ticks()[0]));this.hGridLines.enter().append("svg:line").classed("grid-line h-grid-line",true);this.hGridLines.attr("x1",0).attr("y1",this.yScale).attr("x2",this.config.width).attr("y2",this.yScale);this.hGridLines.exit().remove()};this.glyphEnterState=function(j){};this.glyphFinalState=function(j){};this.glyphExitState=function(j){};this.renderDatapoints=function(j,m){var l=function(o,n){return i.xScale(j[n])};var k=function(o,n){return i.yScale(m[n])};this.datapoints=this.content.selectAll(".glyph").data(j);this.datapoints.enter().append("svg:circle").attr("class","glyph").attr("cx",l).attr("cy",0).attr("r",0);this.datapoints.transition().duration(this.config.entryAnimDuration).attr("cx",l).attr("cy",k).attr("r",this.config.bubbleRadius);this.datapoints.exit().transition().duration(this.config.entryAnimDuration).attr("cy",this.config.height).attr("r",0).style("fill-opacity",0).remove()};this.render=function(k,l){var j=k[0],m=k[1];this.log("renderScatterplot",j.length,m.length,this.config);j=this.preprocessData(j);m=this.preprocessData(m);this.setUpDomains(j,m,l);this.log("xMin, xMax, yMin, yMax:",this.xMin,this.xMax,this.yMin,this.yMax);this.setUpScales();this.adjustChartDimensions();this.setUpXAxis();this.setUpYAxis();this.renderGrid();this.renderDatapoints(j,m)}}var a=BaseView.extend(LoggableMixin).extend({tagName:"form",className:"scatterplot-settings-form",loadingIndicatorImagePath:(galaxy_paths.get("image_path")+"/loading_large_white_bg.gif"),events:{"click #render-button":"renderScatterplot"},initialize:function(c){if(!c||!c.dataset){throw ("ScatterplotView requires a dataset")}else{this.dataset=c.dataset}this.apiDatasetsURL=c.apiDatasetsURL;this.chartConfig=c.chartConfig||{};this.log("this.chartConfig:",this.chartConfig);this.plot=new b(this.chartConfig)},render:function(){var c=this,e="",d="";this.dataset.metadata_column_types=this.dataset.metadata_column_types.split(", ");_.each(this.dataset.metadata_column_types,function(h,g){if(h==="int"||h==="float"){var f="column "+g;if(c.dataset.metadata_column_names){f=c.dataset.metadata_column_names[g]}d+='<option value="'+g+'">'+f+"</option>"}});e+='<div id="loading-indicator" style="display: none;">';e+='<img class="loading-img" src='+this.loadingIndicatorImagePath+" />";e+='<span class="loading-message"></span>';e+="</div>";e+='<div id="x-column-input">';e+='<label for="">Data column for X: </label><select name="x-column">'+d+"</select>";e+="</div>";e+='<div id="y-column-input">';e+='<label for="">Data column for Y: </label><select name="y-column">'+d+"</select>";e+="</div>";e+='<input id="render-button" type="button" value="Draw" />';e+='<div class="clear"></div>';this.$el.append(e);this.$el.find("#render-button");return this},showLoadingIndicator:function(c){c=c||"";this.$el.find("div#loading-indicator").children(".loading-message").text(c);this.$el.find("div#loading-indicator").show("fast")},hideLoadingIndicator:function(){this.$el.find("div#loading-indicator").hide("fast")},renderScatterplot:function(){var d=this,e=this.apiDatasetsURL+"/"+this.dataset.id+"?data_type=raw_data&",i=this.$el.find('[name="x-column"]'),j=i.val(),g=i.children('[value="'+j+'"]').text(),h=this.$el.find('[name="y-column"]'),f=h.val(),c=h.children('[value="'+f+'"]').text();this.log(g,c);this.chartConfig.xLabel=g;this.chartConfig.yLabel=c;d.plot.updateConfig(this.chartConfig);e+=jQuery.param({columns:"["+[j,f]+"]"});this.log("url:",e);this.showLoadingIndicator("Fetching data...");jQuery.ajax({url:e,dataType:"json",success:function(k){d.showLoadingIndicator("Rendering...");d.endpoint=k.endpoint;d.plot.render(k.data,k.meta);d.hideLoadingIndicator()},error:function(m,k,l){d.hideLoadingIndicator();alert("ERROR:"+k+"\n"+l)}})}});return{ScatterplotView:a}}); \ No newline at end of file +define(["../libs/underscore","../libs/d3","../mvc/base-mvc","../templates/compiled/template-visualization-scatterplotControlForm"],function(){function a(f){var i=this,d=10,h=7,g=10,e=8,c=5;this.log=function(){if(this.debugging&&console&&console.debug){var j=Array.prototype.slice.call(arguments);j.unshift(this.toString());console.debug.apply(null,j)}};this.log("new TwoVarScatterplot:",f);this.defaults={id:"TwoVarScatterplot",containerSelector:"body",maxDataPoints:30000,bubbleRadius:4,entryAnimDuration:500,xNumTicks:10,yNumTicks:10,xAxisLabelBumpY:40,yAxisLabelBumpX:-35,width:500,height:500,marginTop:50,marginRight:50,marginBottom:50,marginLeft:50,xMin:null,xMax:null,yMin:null,yMax:null,xLabel:"X",yLabel:"Y"};this.config=_.extend({},this.defaults,f);this.updateConfig=function(j){_.extend(this.config,j)};this.toString=function(){return this.config.id};this.translateStr=function(j,k){return"translate("+j+","+k+")"};this.rotateStr=function(k,j,l){return"rotate("+k+","+j+","+l+")"};this.svg=d3.select(this.config.containerSelector).append("svg:svg").attr("class","chart").style("display","none");this.content=this.svg.append("svg:g").attr("class","content");this.xAxis=this.content.append("g").attr("class","axis").attr("id","x-axis");this.xAxisLabel=this.xAxis.append("text").attr("class","axis-label").attr("id","x-axis-label");this.yAxis=this.content.append("g").attr("class","axis").attr("id","y-axis");this.yAxisLabel=this.yAxis.append("text").attr("class","axis-label").attr("id","y-axis-label");this.log("built svg:",d3.selectAll("svg"));this.adjustChartDimensions=function(m,k,j,l){m=m||0;k=k||0;j=j||0;l=l||0;this.svg.attr("width",this.config.width+(this.config.marginRight+k)+(this.config.marginLeft+l)).attr("height",this.config.height+(this.config.marginTop+m)+(this.config.marginBottom+j)).style("display","block");this.content=this.svg.select("g.content").attr("transform",this.translateStr(this.config.marginLeft+l,this.config.marginTop+m))};this.preprocessData=function(j){return(j.length>this.config.maxDataPoints)?(j.slice(0,this.config.maxDataPoints)):(j)};this.setUpDomains=function(j,l,k){this.log("setUpDomains");this.xMin=this.config.xMin||(k)?(k[0].min):(d3.min(j));this.xMax=this.config.xMax||(k)?(k[0].max):(d3.max(j));this.yMin=this.config.yMin||(k)?(k[1].min):(d3.min(l));this.yMax=this.config.yMax||(k)?(k[1].max):(d3.max(l))};this.setUpScales=function(){this.xScale=d3.scale.linear().domain([this.xMin,this.xMax]).range([0,this.config.width]),this.yScale=d3.scale.linear().domain([this.yMin,this.yMax]).range([this.config.height,0])};this.setUpXAxis=function(){this.xAxisFn=d3.svg.axis().scale(this.xScale).ticks(this.config.xNumTicks).orient("bottom");this.xAxis.attr("transform",this.translateStr(0,this.config.height)).call(this.xAxisFn);this.xLongestLabel=d3.max(_.map([this.xMin,this.xMax],function(j){return(String(j)).length}));if(this.xLongestLabel>=c){this.xAxis.selectAll("g").filter(":nth-child(odd)").style("display","none")}this.xAxisLabel.attr("x",this.config.width/2).attr("y",this.config.xAxisLabelBumpY).attr("text-anchor","middle").text(this.config.xLabel)};this.setUpYAxis=function(){this.yAxisFn=d3.svg.axis().scale(this.yScale).ticks(this.config.yNumTicks).orient("left");this.yAxis.call(this.yAxisFn);this.log("yAxis:",this.yAxis);var j=this.yAxis.selectAll("text").filter(function(n,m){return m!==0});this.yLongestLabel=d3.max(j[0].map(function(n,m){return(d3.select(n).text()).length}))||0;var k=d+(this.yLongestLabel*h)+e+g;this.config.yAxisLabelBumpX=-(k-g);if(this.config.marginLeft<k){var l=(k)-this.config.marginLeft;l=(l<0)?(0):(l);this.log("adjusting:",l);this.adjustChartDimensions(0,0,0,l)}this.yAxisLabel.attr("x",this.config.yAxisLabelBumpX).attr("y",this.config.height/2).attr("text-anchor","middle").attr("transform",this.rotateStr(-90,this.config.yAxisLabelBumpX,this.config.height/2)).text(this.config.yLabel)};this.renderGrid=function(){this.vGridLines=this.content.selectAll("line.v-grid-line").data(this.xScale.ticks(this.xAxisFn.ticks()[0]));this.vGridLines.enter().append("svg:line").classed("grid-line v-grid-line",true);this.vGridLines.attr("x1",this.xScale).attr("y1",0).attr("x2",this.xScale).attr("y2",this.config.height);this.vGridLines.exit().remove();this.hGridLines=this.content.selectAll("line.h-grid-line").data(this.yScale.ticks(this.yAxisFn.ticks()[0]));this.hGridLines.enter().append("svg:line").classed("grid-line h-grid-line",true);this.hGridLines.attr("x1",0).attr("y1",this.yScale).attr("x2",this.config.width).attr("y2",this.yScale);this.hGridLines.exit().remove()};this.glyphEnterState=function(j){};this.glyphFinalState=function(j){};this.glyphExitState=function(j){};this.renderDatapoints=function(j,m){var l=function(o,n){return i.xScale(j[n])};var k=function(o,n){return i.yScale(m[n])};this.datapoints=this.content.selectAll(".glyph").data(j);this.datapoints.enter().append("svg:circle").attr("class","glyph").attr("cx",l).attr("cy",0).attr("r",0);this.datapoints.transition().duration(this.config.entryAnimDuration).attr("cx",l).attr("cy",k).attr("r",this.config.bubbleRadius);this.datapoints.exit().transition().duration(this.config.entryAnimDuration).attr("cy",this.config.height).attr("r",0).style("fill-opacity",0).remove()};this.render=function(k,l){var j=k[0],m=k[1];this.log("renderScatterplot",j.length,m.length,this.config);j=this.preprocessData(j);m=this.preprocessData(m);this.setUpDomains(j,m,l);this.log("xMin, xMax, yMin, yMax:",this.xMin,this.xMax,this.yMin,this.yMax);this.setUpScales();this.adjustChartDimensions();this.setUpXAxis();this.setUpYAxis();this.renderGrid();this.renderDatapoints(j,m)}}var b=BaseView.extend(LoggableMixin).extend({tagName:"form",className:"scatterplot-settings-form",loadingIndicatorImagePath:(galaxy_paths.get("image_path")+"/loading_large_white_bg.gif"),events:{"click #render-button":"renderScatterplot"},initialize:function(c){if(!c||!c.dataset){throw ("ScatterplotView requires a dataset")}else{this.dataset=c.dataset}this.apiDatasetsURL=c.apiDatasetsURL;this.chartConfig=c.chartConfig||{};this.log("this.chartConfig:",this.chartConfig);this.plot=new a(this.chartConfig)},render:function(){var c=this,d="";var e={loadingIndicatorImagePath:this.loadingIndicatorImagePath,config:this.chartConfig,availableColumns:[]};_.each(this.dataset.metadata_column_types.split(", "),function(h,g){if(h==="int"||h==="float"){var f="column "+g;if(c.dataset.metadata_column_names){f=c.dataset.metadata_column_names[g]}e.availableColumns.push({index:g,name:f})}});d=b.templates.form(e);this.$el.append(d);return this},showLoadingIndicator:function(c){c=c||"";this.$el.find("div#loading-indicator").children(".loading-message").text(c);this.$el.find("div#loading-indicator").show("fast")},hideLoadingIndicator:function(){this.$el.find("div#loading-indicator").hide("fast")},renderScatterplot:function(){var d=this,e=this.apiDatasetsURL+"/"+this.dataset.id+"?data_type=raw_data&",i=this.$el.find('[name="x-column"]'),j=i.val(),g=i.children('[value="'+j+'"]').text(),h=this.$el.find('[name="y-column"]'),f=h.val(),c=h.children('[value="'+f+'"]').text();this.log(g,c);this.chartConfig.xLabel=g;this.chartConfig.yLabel=c;d.plot.updateConfig(this.chartConfig);e+=jQuery.param({columns:"["+[j,f]+"]"});this.log("url:",e);this.showLoadingIndicator("Fetching data...");jQuery.ajax({url:e,dataType:"json",success:function(k){d.endpoint=k.endpoint;d.showLoadingIndicator("Rendering...");d.plot.render(k.data,k.meta);d.hideLoadingIndicator()},error:function(m,k,l){d.hideLoadingIndicator();alert("ERROR:"+k+"\n"+l)}})}});b.templates=CompiledTemplateLoader.getTemplates({"visualization-templates.html":{form:"template-visualization-scatterplotControlForm"}});return{TwoVarScatterplot:a,ScatterplotControlForm:b}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket