$("#search_histogram").html("Searching for matching WOS data...")
$("#search_histogram").html("Searching for matching WOS data...")
varargs={
varargs={
// the_queries is an array of str
// the_queries is an array of str
"q":the_queries,
"q":the_queries,
...
@@ -18,7 +49,7 @@ function search_proposed_terms_and_draw( the_queries ) {
...
@@ -18,7 +49,7 @@ function search_proposed_terms_and_draw( the_queries ) {
"until":2015
"until":2015
}
}
vardocs_years=[];
vardocs_years=[];
$("#search_histogram")
$("#search_histogram")
.html('<p class="micromessage">Waiting for histogram data</p>')
.html('<p class="micromessage">Waiting for histogram data</p>')
...
@@ -28,21 +59,29 @@ function search_proposed_terms_and_draw( the_queries ) {
...
@@ -28,21 +59,29 @@ function search_proposed_terms_and_draw( the_queries ) {
data:args,
data:args,
dataType:"json",
dataType:"json",
success:function(data,textStatus,jqXHR){
success:function(data,textStatus,jqXHR){
// ES aggs response, for example
// ES aggs response, for example
// data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}}
// data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}}
// console.log(">> incoming api data <<")
// console.log(">> incoming api data <<")
// console.log(data)
// console.log(data)
if(data.total==0){
if(data.total==0){
returnfalse;
returnfalse;
}
}
else{
else{
for(variindata.aggs.publicationCount.buckets){
for(variindata.aggs.publicationCount.buckets){
varelem=data.aggs.publicationCount.buckets[i]
varelem=data.aggs.publicationCount.buckets[i]
docs_years.push([elem.key+"",elem.doc_count])
varyear=elem.key+""
varndocs=elem.doc_count
// result is over [0;1]
varnormalized_ndocs=ndocs/wosYearTotals[year]
docs_years.push([year,normalized_ndocs])
}
}
// docs_years is now an array of couples [[1989,42],[1990,100],...]
console.log("docs_years",docs_years)
// counts_by_year_array
// counts_by_year_array
draw_histogram(docs_years,"search_histogram");
draw_histogram(docs_years,"search_histogram");
returntrue;
returntrue;
...
@@ -50,7 +89,7 @@ function search_proposed_terms_and_draw( the_queries ) {
...
@@ -50,7 +89,7 @@ function search_proposed_terms_and_draw( the_queries ) {