-
Notifications
You must be signed in to change notification settings - Fork 3
/
biolitmap.js
34 lines (31 loc) · 26 KB
/
biolitmap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var articlesPerJournalChart,articlesPerYearChart,articlesPerTopicChart;let selectedYearsArray="2010,2011,2012,2013,2014",selectedJournalsArray="Oxford Bioinformatics,BMC Bioinformatics,Nucleic Acids Research,BMC Genomics,PLoS Computational Biology",selectedTopicsArray="'Computational Biology > Molecular genetics', 'Software > Tools', 'Computational Biology > Nucleic acids > DNA', 'Computational Biology > Nucleic acids > RNA', 'Computational Biology > Phylogeny', 'Computational Biology > Sequence analysis', 'Computational Biology > Molecular interactions, pathways and networks', 'Computational Biology > Structure analysis', 'Omics > Genomics > Functional genomics', 'Omics > Genomics > Pharmacogenomics', 'Proteomics', 'Omics > Genomics > Transcriptomics', 'Computational Biology > Sequence analysis > Mapping'";var API_KEY="9d3d3e19781c35ce76c075e4cfe9d5caa1604ce9",USER_NAME="carto-bsc",SQL_CLIENT=axios.create({method:"get",url:"https://"+USER_NAME+".carto.com/api/v2/sql?",params:{api_key:API_KEY}});function updatePerJournalPlot(){var d="SELECT source,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE year IN ("+selectedYearsArray+") AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY source";SQL_CLIENT.request({params:{q:d}}).then(function(f){if(f&&f.data){dataArray=[],labelsArray=[];for(var g=[],h=0;h<f.data.rows.length;h++)dataArray.push(f.data.rows[h].sum),labelsArray.push(f.data.rows[h].source),g.push(getJournalColor(f.data.rows[h].source));if(options={},data={datasets:[{data:dataArray,backgroundColor:g}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerJournalChart").css("z-index",3),articlesPerJournalChart){$("#articlesPerJournalChart").remove(),$("#histogram").append("<canvas id=\"articlesPerJournalChart\"><canvas>");var k=$("#articlesPerJournalChart");articlesPerJournalChart=new Chart(k,{type:"pie",data:data,options:{maintainAspectRatio:!0,legend:{position:"left"}},borderWidth:1})}else{var k=$("#articlesPerJournalChart");articlesPerJournalChart=new Chart(k,{type:"pie",data:data,options:{maintainAspectRatio:!0,legend:{position:"left"}},borderWidth:1})}}}).catch(function(){}),hidePlots()}function updatePerYearPlot(){var d="SELECT year,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE year IN ("+selectedYearsArray+") AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY year ORDER by year ASC";SQL_CLIENT.request({params:{q:d}}).then(function(f){if(f&&f.data){dataArray=[],labelsArray=[];for(var g=0;g<f.data.rows.length;g++)dataArray.push(f.data.rows[g].sum),labelsArray.push(f.data.rows[g].year);if(options={},data={datasets:[{data:dataArray,backgroundColor:"#feb236",hoverBackgroundColor:"#feb236"}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerYearChart").css("z-index",3),articlesPerYearChart){$("#articlesPerYearChart").remove(),$("#histogram").append("<canvas id=\"articlesPerYearChart\"><canvas>");var h=$("#articlesPerYearChart");articlesPerYearChart=new Chart(h,{type:"bar",data:data,options:{maintainAspectRatio:!0,legend:{display:!1}},borderWidth:1})}else{var h=$("#articlesPerYearChart");articlesPerYearChart=new Chart(h,{type:"bar",data:data,options:{maintainAspectRatio:!0,legend:{display:!1}},borderWidth:1})}}}).catch(function(){}),hidePlots()}function updatePerTopicPlot(){var d="SELECT edamcategory,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE year IN ("+selectedYearsArray+") AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY edamcategory ORDER by edamcategory ASC";SQL_CLIENT.request({params:{q:d}}).then(function(f){if(f&&f.data){dataArray=[],labelsArray=[];for(var g=[],h=0;h<f.data.rows.length;h++)dataArray.push(f.data.rows[h].sum),labelToPush=f.data.rows[h].edamcategory.split(">"),labelToPush=labelToPush[labelToPush.length-1],labelToPush.includes("Molecular interactions")&&(labelToPush="Mol. int., pathways and networks"),labelsArray.push(labelToPush.trim()),g.push(getTopicColor(labelToPush));if(options={},data={datasets:[{data:dataArray,backgroundColor:g,hoverBackgroundColor:g}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerTopicChart").css("z-index",3),articlesPerTopicChart){$("#articlesPerTopicChart").remove(),$("#histogram").append("<canvas id=\"articlesPerTopicChart\" width=\"100%\" height=\"80%\"><canvas>");var k=$("#articlesPerTopicChart");articlesPerTopicChart=new Chart(k,{type:"pie",data:data,options:{maintainAspectRatio:!0,legend:{position:"left"}},borderWidth:1})}else{var k=$("#articlesPerTopicChart");articlesPerTopicChart=new Chart(k,{type:"pie",data:data,options:{maintainAspectRatio:!0,legend:{position:"left"}},borderWidth:1})}}}).catch(function(){}),hidePlots()}function componentToHex(d){var f=d.toString(16);return 1==f.length?"0"+f:f}function getJournalColor(d){switch(d.trim()){case"BMC Genomics":return"#006E51";case"Oxford Bioinformatics":return"#D8AE47";case"Nucleic Acids Research":return"#034F84";case"BMC Bioinformatics":return"#955251";case"PLoS Computational Biology":return"#009B77";default:return"#000000";}}function getTopicColor(d){switch(d.trim()){case"DNA":return"#FE2712";case"RNA":return"#FC600A";case"Phylogeny":return"#FB9902";case"Sequence analysis":return"#FCCC1A";case"Mapping":return"#FEFE33";case"Structure analysis":return"#B2D732";case"Functional genomics":return"#66B032";case"Pharmacogenomics":return"#8601AF";case"Proteomics":return"#C21460";case"Mol. int., pathways and networks":return"#6C4F3D";case"Molecular genetics":return"#672E3B";case"Transcriptomics":return"#9C9A40";case"Tools":return"#F6D155";default:return"#000000";}}function getColorsArray(d){for(var f=["#fbb735","#e98931","#eb403b","#b32E37","#6c2a6a","#5c4399","#274389","#1f5ea8","#227FB0","#2ab0c5","#39c0b3","#b3cae5","#dbdde4","#e4e3e4","#f7ddbb","#efcab2","#bccacc","#c7d8d6","#d9ebe0","#ebf9e3","#f4f8d0","#5e7fb1","#dce8f7","#eff1f4","#fce1a8","#f7ec86","#8fb8ee","#cbe2f4","#dbe5eb","#f9d3b8","#e0b2a3","#a2e0f9","#cef5fc","#eafaeb","#fefcd3","#fdf4ba","#6bafd2","#a4c8dc","#d6cbca","#eabc96","#db8876","#b4ced8","#d7e5d4","#e2e8c9","#f1e5b9","#edd7ac","#29153e","#657489","#bfb6aa","#ead79d","#f2ebda","#20202f","#273550","#416081","#adacb2","#eac3a2","#555351","#555351","#8d7b6c","#cc9d7a","#fff9aa","#171c33","#525f83","#848896","#bb9d78","#f6e183","#ffe3c8","#efad9e","#c79797","#a78a92","#857d8d","#6f749e","#9a8daf","#d0a8b9","#f8bbb1","#fde6b1","#536a97","#8087ad","#bca391","#bd968a","#a38b8a","#325176","#7b9ea7","#9baf93","#dbaf81","#fbdf73","#727288","#8e889b","#d3c2bd","#f9d89a","#f8c785","#506e90","#7695aa","#a7bdb8","#e2e2b8","#fdf998","#634b5f","#868080","#b7b29b","#dfd6a4","#e9f3a2","#7e74b2","#b3a2c2","#e2cdbe","#f6cf97","#f4a77a","#34a4ca","#59d7dd","#a8f2f0","#d0f8ef","#d6f6e1","#7696cd","#8fb2e4","#b0cff0","#d7e5ec","#dee0e7","#8dd6c3","#c5e5e2","#eafaeb","#f9f7ca","#fceea1","#4e72c7","#6d9ed7","#a4c8d5","#b4d9e1","#c4d9d6","#47565f","#5b625a","#947461","#f98056","#f7ec86","#95b3bf","#c6cdd3","#e5d8d9","#f1e1d9","#f3e1cd","#4c86ab","#95a5bc","#bfcdc9","#dcd6c9","#edd9c7","#0f124a","#1b2360","#515b80","#758391","#e5e3b0","#889db6","#a5b8ce","#c1cfdd","#dee1e4","#d5d1cf","#74bddb","#a8d1eb","#cddbf5","#e4e6fb","#f6f4f8","#a7d3cb","#bcc1c4","#e5cab3","#fee6c5","#fdecd0","#325571","#8e9fa4","#decab2","#f2d580","#ffa642","#c5d4d7","#d6b98d","#c99262","#8c5962","#43577e"],g=[];g.length<d;){do var h=Math.floor(1e6*Math.random()+1);while(0<=g.indexOf(h));g.push(componentToHex(f[g.length]))}return g}function hidePlots(){$("#articlesPerJournalChartTitle").hide(),$("#articlesPerJournalChart").hide(),$("#articlesPerYearChartTitle").hide(),$("#articlesPerYearChart").hide(),$("#articlesPerTopicChartTitle").hide(),$("#articlesPerTopicChart").hide(),$("#histogram").hide(),map.closePopup()}function main(){const g=$("#style").text(),h=_.template($("#query").html()),k=$("#slider-container"),m=$("#slider-cities");map=L.map("map",{zoomControl:!1,center:[41.85,1.85],zoom:4,minZoom:2,maxZoom:18}),L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png",{maxZoom:18,zIndex:0}).addTo(map),L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}.png",{maxZoom:18,zIndex:0}).addTo(map),L.control.zoom({position:"bottomleft"}).addTo(map);const n=new carto.Client({apiKey:"9d3d3e19781c35ce76c075e4cfe9d5caa1604ce9",username:"carto-bsc"});let o=new carto.source.SQL(h({cities:500,year:selectedYearsArray,journal:selectedJournalsArray,edamcat:selectedTopicsArray})),p=new carto.style.CartoCSS(g),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]});n.addLayer(q),n.getLeafletLayer().addTo(map),$(document).ready(function(){$("#moreInfoButton").click(function(){$("#myModalMoreInfo").appendTo("body").modal("show")}),$("#feedbackButton").click(function(){$("#myModalFeedback").appendTo("body").modal("show")}),$(".modal").on("hidden.bs.modal",function(){$(this).removeData()}),$("[data-toggle=\"tooltip\"]").tooltip(),$("[data-toggle=tooltip]").tooltip({placement:$(this).data("placement")||"top"}),selectedYearsArray="2010,2011,2012,2013,2014",selectedJournalsArray="Oxford Bioinformatics,BMC Bioinformatics,Nucleic Acids Research,BMC Genomics,PLoS Computational Biology",selectedTopicsArray="'Computational Biology > Molecular genetics', 'Software > Tools', 'Computational Biology > Nucleic acids > DNA', 'Computational Biology > Nucleic acids > RNA', 'Computational Biology > Phylogeny', 'Computational Biology > Sequence analysis', 'Computational Biology > Molecular interactions, pathways and networks', 'Computational Biology > Structure analysis', 'Omics > Genomics > Functional genomics', 'Omics > Genomics > Pharmacogenomics', 'Proteomics', 'Omics > Genomics > Transcriptomics', 'Computational Biology > Sequence analysis > Mapping'",function(u){function v(E){E=E||window.event,C=E.clientX,D=E.clientY,document.onmouseup=y,document.onmousemove=w}function w(E){E=E||window.event,A=C-E.clientX,B=D-E.clientY,C=E.clientX,D=E.clientY,u.style.top=u.offsetTop-B+"px",u.style.left=u.offsetLeft-A+"px"}function y(){document.onmouseup=null,document.onmousemove=null}var A=0,B=0,C=0,D=0;document.getElementById(u.id+"header")?document.getElementById(u.id+"header").onmousedown=v:u.onmousedown=v}(document.getElementById("histogram")),$("#leftSidebar").hide(),$("#histogram").hide(),$("#articlesPerJournalChartTitle").hide(),$("#articlesPerJournalChart").hide(),$("#articlesPerYearChartTitle").hide(),$("#articlesPerYearChart").hide(),$("#articlesPerTopicChartTitle").hide(),$("#articlesPerTopicChart").hide(),$("#histogramClose").click(function(){hidePlots()}),$("#sidebarButtonOpen").click(function(){$("#sidebarButtonClosed").show(),$("#leftSidebar").fadeOut()}),$("#sidebarButtonClosed").click(function(){$("#sidebarButtonClosed").hide(),$("#leftSidebar").fadeIn()}),$("#plotArticlesPerJournal").click(function(){hidePlots(),$("#histogram").fadeIn(),$("#articlesPerJournalChartTitle").fadeIn(),$("#articlesPerJournalChart").fadeIn()}),$("#plotArticlesPerYear").click(function(){hidePlots(),$("#histogram").fadeIn(),$("#articlesPerYearChartTitle").fadeIn(),$("#articlesPerYearChart").fadeIn()}),$("#plotArticlesPerTopic").click(function(){hidePlots(),$("#histogram").fadeIn(),$("#articlesPerTopicChartTitle").fadeIn(),$("#articlesPerTopicChart").fadeIn()}),SQL_CLIENT.request({params:{q:"SELECT source,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE source IN ('Nucleic Acids Research', 'Oxford Bioinformatics', 'BMC Genomics', 'BMC Bioinformatics', 'PLoS Computational Biology') GROUP BY source"}}).then(function(u){if(u&&u.data){dataArray=[],labelsArray=[];for(var v=0;v<u.data.rows.length;v++)dataArray.push(u.data.rows[v].sum),labelsArray.push(u.data.rows[v].source);options={},data={datasets:[{data:dataArray,backgroundColor:getColorsArray(dataArray.length)}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerJournalChart").css("z-index",3);var w=$("#articlesPerJournalChart"),y=new Chart(w,{type:"pie",data:data,options:{maintainAspectRatio:!1,legend:{position:"left"}},borderWidth:1})}}).catch(function(){}),SQL_CLIENT.request({params:{q:"SELECT year,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE year IN (2010,2011,2012,2013,2014) GROUP BY year ORDER by year ASC"}}).then(function(u){if(u&&u.data){dataArray=[],labelsArray=[];for(var v=0;v<u.data.rows.length;v++)dataArray.push(u.data.rows[v].sum),labelsArray.push(u.data.rows[v].year);options={},data={datasets:[{data:dataArray,backgroundColor:getColorsArray(0),hoverBackgroundColor:getColorsArray(0)}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerYearChart").css("z-index",3);var w=$("#articlesPerYearChart"),y=new Chart(w,{type:"bar",data:data,options:{maintainAspectRatio:!1,legend:{display:!1}},borderWidth:1})}}).catch(function(){}),SQL_CLIENT.request({params:{q:"SELECT edamcategory,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE year IN (2010,2011,2012,2013,2014) GROUP BY edamcategory ORDER by edamcategory ASC"}}).then(function(u){if(u&&u.data){dataArray=[],labelsArray=[];for(var v=0;v<u.data.rows.length;v++)dataArray.push(u.data.rows[v].sum),labelToPush=u.data.rows[v].edamcategory.split(">"),labelToPush=labelToPush[labelToPush.length-1],labelToPush.includes("Molecular interactions")&&(labelToPush="Mol. int., pathways and networks"),labelsArray.push(labelToPush);options={},data={datasets:[{data:dataArray,backgroundColor:getColorsArray(dataArray.length),hoverBackgroundColor:getColorsArray(dataArray.length)}],labels:labelsArray},$("#map").css("z-index",1),$("#histogram").css("z-index",2),$("#articlesPerTopicChart").css("z-index",3);var w=$("#articlesPerTopicChart"),y=new Chart(w,{type:"pie",data:data,options:{maintainAspectRatio:!0,legend:{display:"left"}},borderWidth:1})}}).catch(function(){}),$("#topicSelector").multiselect({includeSelectAllOption:!0,allSelectedText:"All topics selected",buttonWidth:"200px",onChange:function(){},buttonText:function(u){if(0<u.length){var v=[];u.each(function(){v.push([$(this).val(),$(this).data("order")])}),v.sort(function(A,B){return A[1]-B[1]});for(var w="",y=0;y<v.length;y++)w+=v[y][0]+", ";selectedTopicsArray=w.substr(0,w.length-2),o.setQuery(h({cities:500,year:selectedYearsArray,journal:selectedJournalsArray,edamcat:selectedTopicsArray})),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),updatePerYearPlot(),updatePerJournalPlot(),updatePerTopicPlot(),hidePlots()}return 0===u.length?(o.setQuery(h({cities:500,year:["9999"],journal:selectedJournalsArray,edamcat:selectedTopicsArray})),selectedTopicsArray=["9999"],q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),"0 topics selected"):u.length+" topics selected"}},"selectAll"),$("option",$("#topicSelector")).each(function(){$(this).removeAttr("selected").prop("selected",!0)}),$("#topicSelector").multiselect("refresh"),$("#yearSelector").multiselect({includeSelectAllOption:!0,allSelectedText:"All years selected",buttonWidth:"200px",onChange:function(){},buttonText:function(u){if(0<u.length){var v=[];u.each(function(){v.push([$(this).text(),$(this).data("order")])}),v.sort(function(A,B){return A[1]-B[1]});for(var w="",y=0;y<v.length;y++)w+=v[y][0]+", ";selectedYearsArray=w.substr(0,w.length-2),o.setQuery(h({cities:500,year:selectedYearsArray,journal:selectedJournalsArray,edamcat:selectedTopicsArray})),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),updatePerYearPlot(),updatePerJournalPlot(),updatePerTopicPlot(),hidePlots()}return 0===u.length?(o.setQuery(h({cities:500,year:["9999"],journal:selectedJournalsArray,edamcat:selectedTopicsArray})),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),selectedYearsArray=["9999"],"0 years selected"):u.length+" years selected"}},"selectAll"),$("#journalsSelector").multiselect({includeSelectAllOption:!0,allSelectedText:"All journals selected",buttonWidth:"200px",onChange:function(){},buttonText:function(u){if(0<u.length){var v=[];u.each(function(){v.push([$(this).text(),$(this).data("order")])}),v.sort(function(A,B){return A[1]-B[1]});for(var w="",y=0;y<v.length;y++)w+="'"+v[y][0]+"', ";selectedJournalsArray=w.substr(0,w.length-2),o.setQuery(h({cities:500,year:selectedYearsArray,journal:selectedJournalsArray,edamcat:selectedTopicsArray})),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),updatePerYearPlot(),updatePerJournalPlot(),updatePerTopicPlot(),hidePlots()}return 0===u.length?(o.setQuery(h({cities:500,year:["9999"],journal:selectedJournalsArray,edamcat:selectedTopicsArray})),q=new carto.layer.Layer(o,p,{featureClickColumns:["name","papers"]}),selectedJournalsArray=["9999"],"0 journals selected"):u.length+" journals selected"}},"selectAll"),$("option",$("#journalsSelector")).each(function(){$(this).removeAttr("selected").prop("selected",!0)}),$("#journalsSelector").multiselect("refresh"),$("option",$("#yearSelector")).each(function(u){6>u&&$(this).removeAttr("selected").prop("selected",!1),4<u&&$(this).removeAttr("selected").prop("selected",!0),9<u&&$(this).removeAttr("selected").prop("selected",!1)}),$("#yearSelector").multiselect("refresh")});const r=L.popup({closeButton:!0});q.on("featureClicked",function(s){if(r.setLatLng(s.latLng),!r.isOpen()){let v="";if(v+=`<div class="popup-container" id="institutionWindow">`,s.data.name){var u="";"CSIC (Spanish National Research Council)"==s.data.name?(console.log("CSIC count"),u="SELECT COUNT(*) AS sum FROM articles_global_v1 WHERE nameaffiliation LIKE '%CSIC%' AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") AND year IN ("+selectedYearsArray+")"):"Universidad Aut\xF3noma de Madrid"==s.data.name?(console.log("UAM count"),u="SELECT COUNT(*) AS sum FROM articles_global_v1 WHERE nameaffiliation = 'Universidad Aut\xF3noma de Madrid' AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") AND year IN ("+selectedYearsArray+")"):u="SELECT SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE nameaffiliation = '"+s.data.name.replace("'","''")+"' AND source IN ("+selectedJournalsArray+") AND edamcategory IN ("+selectedTopicsArray+") AND year IN ("+selectedYearsArray+")",SQL_CLIENT.request({params:{q:u}}).then(function(w){if(w&&w.data){var y=w.data.rows[0].sum;v+=`<h4>INSTITUTION: ${s.data.name}</h4>`,v+=`<br>`,v+=`<p><b>PAPERS ON THIS PERIOD:</b> ${y}</p>`,v+=`<center><button type="button" id ="mostrarArticulosInstitucion" data-toggle="tooltip" data-placement="right" title="View the articles of this institution" class="btn btn-primary" style="z-index: 10; width: 70%;">View articles</button></center><br>`,v+=`<canvas id="bar-chart" width="400" height="250"></canvas><br>`,v+=`<canvas id="insPerTopicPieChart" width="500" height="250"></canvas>`,v+=`</div>`,v+=`<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Articles from this institution</h4><button type="button" id ="printArticulosInstitucion" data-toggle="tooltip" data-placement="right" title="Print the articles of this institution" class="btn btn-primary" style="z-index: 10; width: 30%;">Print</button>
</div>
<div class="modal-body">
<table id="tablaArticulosInstitucion" class="table tablesorter">
<thead>
<tr>
<th><a href="#">Title</a></th>
<th><a href="#">Year</a></th>
<th><a href="#">Source</a></th>
<th><a href="#">EDAM Category</a></th>
<th><a href="#">Citations</a></th>
<th><a href="#">DOI</a></th>
</tr>
</thead>
<tbody id="cuerpoTablaArticulos">
<tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>`,r.setContent(v),r.openOn(map),$("#mostrarArticulosInstitucion").click(function(){console.log("Hi");var G="";G="CSIC (Spanish National Research Council)"==s.data.name?"SELECT title,year,source,edamCategory,citations,doi FROM articles_global_v1 WHERE nameaffiliation LIKE '%CSIC%' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") ORDER by year ASC":"SELECT title,year,source,edamCategory,citations,doi FROM articles_global_v1 WHERE nameaffiliation = '"+s.data.name.replace("'","''")+"' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") ORDER by year ASC",SQL_CLIENT.request({params:{q:G}}).then(function(H){H&&H.data,console.log(H.data),$("#myModal").removeData(),$("#cuerpoTablaArticulos").empty();for(var I=0;I<H.data.rows.length;I++)console.log(I),$("#cuerpoTablaArticulos").append("<tr><td>"+H.data.rows[I].title+"</td><td>"+H.data.rows[I].year+"</td><td>"+H.data.rows[I].source+"</td><td>"+H.data.rows[I].edamcategory+"</td><td>"+H.data.rows[I].citations+"</td><td><a href=\"http://dx.doi.org/"+H.data.rows[I].doi+"\" target=\"_blank\">"+H.data.rows[I].doi+"</a></td><td>");$("#tablaArticulosInstitucion").tablesorter(),console.log("Sorting"),$("#cuerpoTablaArticulos").append("</tr>"),$("#myModal").appendTo("body").modal("show")}).catch(function(){})}),$("#printArticulosInstitucion").click(function(){var G="<h1>This data has been downloaded from BIOLITMAP</h1>Institution: "+s.data.name+"</br></br>";$(".modal-body").last().printThis({header:G})});var A=function(G){return G.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},D=[],E=[s.data.year],F="";"CSIC (Spanish National Research Council)"==s.data.name?(console.log("CSIC"),F="SELECT source,year,COUNT(*) as sum FROM articles_global_v1 WHERE nameaffiliation LIKE '%CSIC%' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY year,source ORDER by year ASC"):"Universidad Aut\xF3noma de Madrid"==s.data.name?(console.log("UAM"),F="SELECT source,year,COUNT(*) as sum FROM articles_global_v1 WHERE nameaffiliation = 'Universidad Aut\xF3noma de Madrid' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY year,source ORDER by year ASC"):F="SELECT source,year,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE nameaffiliation = '"+s.data.name.replace("'","''")+"' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY year,source ORDER by year ASC",SQL_CLIENT.request({params:{q:F}}).then(function(G){if(G&&G.data){console.log("Cuenta"),console.log(G),dataArray=[],labelsArray=[];for(var H=[],I=selectedYearsArray.split(","),J=0;J<G.data.rows.length;J++)H.includes(G.data.rows[J].source)||H.push(G.data.rows[J].source);H=selectedJournalsArray.split(",");for(var K=0;K<H.length;K++)H[K]=H[K].replace(/'/g,"").trim();for(var J=0;J<selectedYearsArray.split(",").length;J++)labelsArray.includes(parseInt(selectedYearsArray.split(",")[J].trim(),10))||labelsArray.push(parseInt(selectedYearsArray.split(",")[J].trim(),10));labelsArray.sort(function(X,Y){return X-Y});var M=labelsArray.length,N=H.length;datapackColors=getColorsArray(N);for(var J=0;J<N;J++){for(var O=[],P=[],R=0;R<selectedYearsArray.split(",").length;R++)O.push({year:parseInt(selectedYearsArray.split(",")[R].trim(),10),value:0});for(var S=0;S<G.data.rows.length;S++)if(G.data.rows[S].source==H[J]){for(var T=0;T<O.length;T++)parseInt(G.data.rows[S].year,10)==O[T].year&&(O[T].value=G.data.rows[S].sum);P.includes(parseInt(G.data.rows[S].year,10))||P.push(parseInt(G.data.rows[S].year,10))}finalDataArray=[];for(var T=0;T<O.length;T++)finalDataArray.push(O[T].value);var U={label:H[J],data:finalDataArray,backgroundColor:getJournalColor(H[J]),hoverBackgroundColor:getJournalColor(H[J]),hoverBorderWidth:2,hoverBorderColor:"lightgrey"};D.push(U)}var V=document.getElementById("bar-chart"),W=new Chart(V,{type:"bar",data:{labels:labelsArray,datasets:D},options:{title:{display:!0,text:"Articles per year and per journal with the selected filters"},animation:{duration:10},tooltips:{mode:"label",position:"nearest",intersection:!1,callbacks:{label:function(X,Y){return Y.datasets[X.datasetIndex].label+": "+A(X.yLabel)}}},scales:{xAxes:[{stacked:!0,gridLines:{display:!1}}],yAxes:[{stacked:!0,ticks:{beginAtZero:!0,callback:function(X){if(0==X%1)return X}}}]},legend:{display:!1}}})}}).catch(function(){}),"CSIC (Spanish National Research Council)"==s.data.name?(console.log("CSIC"),query2="SELECT edamcategory,COUNT(*) as sum FROM articles_global_v1 WHERE nameaffiliation LIKE '%CSIC%' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY edamcategory ORDER by edamcategory ASC"):"Universidad Aut\xF3noma de Madrid"==s.data.name?(console.log("UAM"),query2="SELECT edamcategory,COUNT(*) as sum FROM articles_global_v1 WHERE nameaffiliation = '"+s.data.name.replace("'","''")+"' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY edamcategory ORDER by edamcategory ASC"):query2="SELECT edamcategory,SUM(CAST(num_papers AS INT)) FROM results_full_280218_v1 WHERE nameaffiliation = '"+s.data.name.replace("'","''")+"' AND source IN ("+selectedJournalsArray+") AND year IN ("+selectedYearsArray+") AND edamcategory IN ("+selectedTopicsArray+") GROUP BY edamcategory ORDER by edamcategory ASC",SQL_CLIENT.request({params:{q:query2}}).then(function(G){if(G&&G.data){dataArray=[],labelsArray=[];for(var H=[],I=0;I<G.data.rows.length;I++)dataArray.push(G.data.rows[I].sum),labelToPush=G.data.rows[I].edamcategory.split(">"),labelToPush=labelToPush[labelToPush.length-1],labelToPush.includes("Molecular interactions")&&(labelToPush="Mol. int., pathways and networks"),labelsArray.push(labelToPush.trim()),H.push(getTopicColor(labelToPush));data={datasets:[{data:dataArray,backgroundColor:H}],labels:labelsArray};var J=document.getElementById("insPerTopicPieChart"),K=new Chart(J,{type:"doughnut",data:data,options:{title:{display:!0,text:"Articles per topic with the selected filters"},legend:{display:!1}},borderWidth:1})}}).catch(function(){})}}).catch(function(){})}}})}window.onload=main;