Commit e1b6143a authored by Romain Loth's avatar Romain Loth

histogram: simpler div management and background hiding

parent 68d77288
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#search_histogram_wrapper{ #search_histogram_wrapper{
margin: 0 ; margin: 0 ;
/* overwrite bootstrap's /* overwrite bootstrap's
* grid element padding*/ * grid element padding*/
padding-right: 2em ; padding-right: 2em ;
margin-left: -.5em ; margin-left: -.5em ;
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#search_histogram{ #search_histogram{
min-height: 15em ; min-height: 15em ;
font-size: 85%; font-size: 85%;
background-color: #F9F9F9 ;
display: none;
} }
/* dygraph internal canvas */ /* dygraph internal canvas */
#search_histogram canvas{ #search_histogram canvas{
......
...@@ -33,6 +33,8 @@ var wosYearTotals = { ...@@ -33,6 +33,8 @@ var wosYearTotals = {
"2015" : 1772592 "2015" : 1772592
} }
var $search_histogram = $("#search_histogram")
//method for calling the ISC-API and get pubs-distribution of the suggested term //method for calling the ISC-API and get pubs-distribution of the suggested term
function search_proposed_terms_and_draw( the_queries ) { function search_proposed_terms_and_draw( the_queries ) {
...@@ -40,7 +42,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -40,7 +42,7 @@ function search_proposed_terms_and_draw( the_queries ) {
// +"i'm searching:\n" // +"i'm searching:\n"
// +JSON.stringify(the_queries)) ; // +JSON.stringify(the_queries)) ;
$("#search_histogram").html("Searching for matching WOS data...") $search_histogram.html("Searching for matching WOS data...")
var args = { var args = {
// the_queries is an array of str // the_queries is an array of str
...@@ -50,7 +52,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -50,7 +52,7 @@ function search_proposed_terms_and_draw( the_queries ) {
} }
var docs_years = [] ; var docs_years = [] ;
$("#search_histogram") $search_histogram
.html('<p class="micromessage">Waiting for histogram data</p>') .html('<p class="micromessage">Waiting for histogram data</p>')
$.ajax({ $.ajax({
...@@ -80,10 +82,10 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -80,10 +82,10 @@ function search_proposed_terms_and_draw( the_queries ) {
} }
// docs_years is now an array of couples [[1989,42],[1990,100],...] // docs_years is now an array of couples [[1989,42],[1990,100],...]
console.log("docs_years",docs_years) // console.log("docs_years",docs_years)
// counts_by_year_array // counts_by_year_array
draw_histogram(docs_years, "search_histogram") ; draw_histogram(docs_years) ;
return true ; return true ;
} }
}, },
...@@ -91,7 +93,7 @@ function search_proposed_terms_and_draw( the_queries ) { ...@@ -91,7 +93,7 @@ function search_proposed_terms_and_draw( the_queries ) {
error: function(exception) { error: function(exception) {
console.log("search_proposed_terms_and_draw:exception" console.log("search_proposed_terms_and_draw:exception"
+ JSON.stringify(exception)) + JSON.stringify(exception))
$("#search_histogram") $search_histogram
.html('<p class="micromessage">' .html('<p class="micromessage">'
+'<b>No histogram</b>: too many nodes selected</b>' +'<b>No histogram</b>: too many nodes selected</b>'
+'</p>') +'</p>')
...@@ -113,11 +115,13 @@ $("#searchinput").on("tw:gotNodeSet", function(e) { ...@@ -113,11 +115,13 @@ $("#searchinput").on("tw:gotNodeSet", function(e) {
$("#searchinput").on("tw:eraseNodeSet", function(e) { $("#searchinput").on("tw:eraseNodeSet", function(e) {
// console.log("event 'erase'") ; // console.log("event 'erase'") ;
clean_histogram() ; clean_histogram() ;
$search_histogram.hide() ;
}); });
// emptyNodeSet event when Tinaweb search found nothing // emptyNodeSet event when Tinaweb search found nothing
$("#searchinput").on("tw:emptyNodeSet", function(e) { $("#searchinput").on("tw:emptyNodeSet", function(e) {
clean_histogram() ; clean_histogram() ;
$search_histogram.hide() ;
}); });
...@@ -146,12 +150,11 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) { ...@@ -146,12 +150,11 @@ function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) {
// use dygraph lib to draw below the crowdsourcing div // use dygraph lib to draw below the crowdsourcing div
function draw_histogram(counts_by_year_array, div_id) { function draw_histogram(counts_by_year_array) {
// 1) layout for the div#search_histogram // 1) layout for the div#search_histogram
// /!\ this div *needs* padding:0 /!\; // /!\ this div *needs* padding:0 /!\;
$("#"+div_id).height("15em") $search_histogram.height("15em").show()
.css("background-color", "#F9F9F9")
// 2) data preparation // 2) data preparation
//~ var years = [] ; //~ var years = [] ;
...@@ -164,7 +167,7 @@ function draw_histogram(counts_by_year_array, div_id) { ...@@ -164,7 +167,7 @@ function draw_histogram(counts_by_year_array, div_id) {
// console.log('=== GRAPH PREPARATION ===') ; // console.log('=== GRAPH PREPARATION ===') ;
// 3) call histogram lib // 3) call histogram lib
new Dygraph(document.getElementById(div_id), new Dygraph($search_histogram[0],
counts_by_year_array, counts_by_year_array,
{ {
labels: ['year', 'n'], labels: ['year', 'n'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment