Skip to content
Snippets Groups Projects
Commit 0788de7f authored by Christopher Schankula's avatar Christopher Schankula :earth_africa:
Browse files

somewhat working histogram for the slides

parent dacc15f4
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ public class Main {
} catch (NumberFormatException e) {
if (taxonId == null) {
try {
taxonId = WormsAPI.nameToRecordID(matcher.group(2));
taxonId = BioTree.nameToTaxonId(matcher.group(2));
} catch (IOException e1) {
// TODO Auto-generated catch block
e.printStackTrace();
......
......@@ -24,6 +24,5 @@ public class TrawlExpert {
BioTree.write("data/biotree/");
DataStore.records.writeToFile("data/kdt.ser");
};
BasicSearch.init();
}
}
......@@ -211,4 +211,30 @@ public class KDT<KeyVal extends Comparable<KeyVal>> implements Serializable {
public int getK() {
return axes.size();
}
public String toString() {
return toString(root, "");
}
public void writeToFile(String fn) {
try {
FileOutputStream fileOut =
new FileOutputStream(fn);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
fileOut.close();
System.out.printf("Serialized data is saved in /tmp/kdtree.ser");
} catch (IOException i) {
i.printStackTrace();
}
}
private String toString(KDNode x, String depth) {
if (x == null) return depth + "null\n";
String result = "";
result += depth + x.keyval.toString() + "\n";
result += toString(x.left, depth + " ");
result += toString(x.right, depth + " ");
return result;
}
}
......@@ -12,5 +12,6 @@
<servlet-mapping>
<servlet-name>Trawl</servlet-name>
<url-pattern>/doBioLookup.do</url-pattern>
<url-pattern>/doHist.do</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
......@@ -5,7 +5,7 @@ function histogram(x,y){
y: y,
type: 'bar',
marker: {
color: 'blue',
color: '#76ADD6',
},
}
];
......@@ -32,5 +32,3 @@ function histogram(x,y){
}
window.onload = histogram([1990,1991,1992],[54656,65654,32555]);
......@@ -16,6 +16,9 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range
<!--JQuery-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="histogram.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!-- MUST load JQuery Library before loading this-->
......@@ -33,7 +36,7 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range
<a href="index.jsp" >TrawlExpert</a>
<span class="nav-bar">
<a href="about.html">About</a> |
<a href="index.html" target="_blank">Gitlab/Github Nonfunc!</a>
<a href="index.html" target="_blank">GitHub</a>
</span>
</div>
</header>
......@@ -63,7 +66,7 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range
<section id="yearIn">
Year Range:
<span id="fromtoYear">InnerHtml</span>
<span id="fromtoYear"></span>
<form>
<div id="slider-range"></div>
</form>
......@@ -80,9 +83,10 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range
<section id="outputWrapper">
<section id="outputDetails">Stuff like population count, entries found, etc. go here</section>
<section id="outputBox">Map, Histogram Box. Histogram selected by default but we might want to have a loading screen instead.
<div id="console">~~~ PSEUDO-CONSOLE ~~~<br></div>
<section id="outputDetails"><bold>Found 278143 results (0.204 seconds)</bold><br><bold>Total population:</bold> 66122855<br><!-- Stuff like population count, entries found, etc. go here --></section>
<section id="outputBox"><!-- Map, Histogram Box. Histogram selected by default but we might want to have a loading screen instead.-->
<!-- <div id="console">~~~ PSEUDO-CONSOLE ~~~<br></div> -->
<div id="histogram"></div>
</section>
</section>
</section>
......
// Initialization
function init() {
callUpdateSci({id:"pickAnimalia", value:2}); // Propagate Dropdowns on Startup
reqHistogram(2);
}
function resolveAny(obj) {
......@@ -105,6 +106,31 @@ function reqBioLookup(tagID, parentId){
// document.getElementById("console").innerHTML += "Sent request to " + path + ": " + jsonString + "<br>"; //RME
}
//This function will get the new nodelist from the server.
//ParentId is the taxId of the node that holds the list of children we want.
function reqHistogram(taxonId){
var path = 'doHist.do';
var params = {taxId: Number(taxonId)};
var xhr = new XMLHttpRequest();
xhr.open("POST", path);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //Send the proper header info
xhr.onreadystatechange = function() {//Call a function when the state changes (i.e. response comes back)
// Update the dropdown when response is ready
if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
var nodeList = JSON.parse(this.responseText);
histogram(nodeList["x"], nodeList["y"]);
}
else{
console.log("Server Response: Error"); //RME
}
};
var jsonString= JSON.stringify(params); //generate JSON string
xhr.send(jsonString); //send request to server
// document.getElementById("console").innerHTML += "Sent request to " + path + ": " + jsonString + "<br>"; //RME
}
// JQuery for Range Slider
$( function() {
$( "#slider-range" ).slider({
......
......@@ -74,30 +74,41 @@ a:hover{
}
#pickSci{
border: 1px solid olivedrab;
/*border: 1px solid olivedrab;*/
}
#yearIn{
width: 80%;
width: 30%;
}
#slider-range{
margin-left:4%;
}
#outputIn{
border: 1px solid blueviolet;
margin-left:1%;
/*border: 1px solid blueviolet;*/
}
#outputWrapper{
border: 1px solid grey;
/*border: 1px solid grey;*/
height: 100%;
margin-top: 3%;
}
#outputDetails{
border: 1px solid saddlebrown;
/*border: 1px solid saddlebrown;*/
}
#outputBox{
border: 1px solid darkred;
/*border: 1px solid darkred;*/
min-height: 60vh; /*TODO Perhaps replace this with something less volatile*/
}
#histogram{
/*border: 1px solid darkred;*/
min-height: 60vh; /*TODO Perhaps replace this with something less volatile*/
width:100%;
}
/*300/400/600/700*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment