From efeec5c36f2b10b2d9f4c0b11ff6ec63d54b4b86 Mon Sep 17 00:00:00 2001 From: Schankula Christopher <schankuc@mcmaster.ca> Date: Wed, 28 Mar 2018 09:15:37 -0400 Subject: [PATCH] edits to histogram --- tomcat/webapps/Trawl/histogram.jsp | 4 +- .../Trawl/org/apache/jsp/histogram_jsp.java | 86 +++++++++++-------- .../Trawl/org/apache/jsp/index_jsp.java | 17 ++-- 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/tomcat/webapps/Trawl/histogram.jsp b/tomcat/webapps/Trawl/histogram.jsp index 67f31a3..4b52955 100644 --- a/tomcat/webapps/Trawl/histogram.jsp +++ b/tomcat/webapps/Trawl/histogram.jsp @@ -11,7 +11,7 @@ <body> - <div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div> + <div id="histogram"><!-- Plotly chart will be drawn inside this DIV --></div> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script> @@ -53,6 +53,6 @@ side:'right' } } - Plotly.newPlot('Histogram', data,layout); + Plotly.newPlot('histogram', data,layout); </script> </body> diff --git a/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/histogram_jsp.java b/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/histogram_jsp.java index 890e149..47c8883 100644 --- a/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/histogram_jsp.java +++ b/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/histogram_jsp.java @@ -1,7 +1,7 @@ /* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/9.0.6 - * Generated at: 2018-03-28 12:47:47 UTC + * Generated at: 2018-03-28 13:10:35 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. @@ -124,49 +124,65 @@ public final class histogram_jsp extends org.apache.jasper.runtime.HttpJspBase _jspx_out = out; out.write("\n"); - out.write("<script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script>\n"); - out.write("<script>\n"); out.write("\n"); + out.write("\n"); + out.write("\n"); + out.write("\n"); + out.write("\n"); + out.write("<head>\n"); + out.write(" <!-- Plotly.js -->\n"); + out.write(" <script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script>\n"); + out.write("</head>\n"); + out.write("\n"); + out.write("<body>\n"); + out.write(" \n"); + out.write(" <div id=\"histogram\"><!-- Plotly chart will be drawn inside this DIV --></div>\n"); + out.write(" <script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script>\n"); + out.write("\t<script>\n"); + out.write("\n"); + out.write("\t"); - TrawlExpert te = (TrawlExpert)request.getServletContext().getAttribute("trawl"); - BasicSearchResult result = te.rangeSearch(159512, 1960, 2016); - - BST<Integer, Integer> histogram = result.histogram(); - Iterable<Integer> results = histogram.keys(); - out.print("var y=[];"); - out.print("var x=[];"); - for (Integer year: results){ - out.print("y.push("+ histogram.get(year) +");"); - out.print("x.push("+ year +");"); - } + TrawlExpert te = (TrawlExpert)request.getServletContext().getAttribute("trawl"); + BasicSearchResult result = te.rangeSearch(159512, 1960, 2016); - out.print((String) request.getAttribute("url")); + BST<Integer, Integer> histogram = result.histogram(); + Iterable<Integer> results = histogram.keys(); + out.print("var y=[];"); + out.print("var x=[];"); + for (Integer year: results){ + out.print("y.push("+ histogram.get(year) +");"); + out.print("x.push("+ year +");"); + } + out.print((String) request.getAttribute("url")); + out.write("\n"); out.write("\n"); - out.write("var data = [\n"); - out.write(" { x: x,\n"); - out.write(" y: y,\n"); - out.write(" type: 'bar',\n"); - out.write(" orientation: 'h',\n"); - out.write(" marker: {\n"); - out.write(" color: 'blue',\n"); - out.write(" },\n"); - out.write(" }\n"); - out.write("];\n"); + out.write("\tvar data = [\n"); + out.write(" \t{ \tx: x,\n"); + out.write(" \ty: y,\n"); + out.write(" \ttype: 'bar',\n"); + out.write(" \torientation: 'h',\n"); + out.write(" \tmarker: {\n"); + out.write(" \tcolor: 'blue',\n"); + out.write(" \t},\n"); + out.write(" \t}\n"); + out.write("\t];\n"); out.write("\n"); - out.write("var layout = {\n"); - out.write(" xaxis:{\n"); - out.write(" autorange:'reversed'\n"); - out.write(" },\n"); - out.write(" yaxis:{\n"); - out.write(" side:'right'\n"); - out.write(" }\n"); - out.write("}\n"); - out.write("Plotly.newPlot('Histogram', data,layout); \n"); - out.write("</script>"); + out.write("\tvar layout = {\n"); + out.write("\t\ttitle: 'Individual count vs Year',\n"); + out.write(" \txaxis:{title: 'Year',\n"); + out.write(" \t\tautorange:'reversed'\n"); + out.write(" \t},\n"); + out.write(" \tyaxis:{title: 'Individual count',\n"); + out.write(" \t\tside:'right'\n"); + out.write(" \t\t}\n"); + out.write("\t}\n"); + out.write("\tPlotly.newPlot('histogram', data,layout); \n"); + out.write("\t</script>\n"); + out.write("</body>\n"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; diff --git a/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/index_jsp.java b/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/index_jsp.java index bfa0be7..0adee56 100644 --- a/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/index_jsp.java +++ b/tomcat/work/Catalina/localhost/Trawl/org/apache/jsp/index_jsp.java @@ -1,7 +1,7 @@ /* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/9.0.6 - * Generated at: 2018-03-27 23:07:59 UTC + * Generated at: 2018-03-28 13:10:15 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. @@ -117,9 +117,7 @@ public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase out.write("\n"); out.write("<!--\n"); - out.write("\n"); out.write("Double Handle Slider Modified from: http://jqueryui.com/slider/#range\n"); - out.write("\n"); out.write("-->\n"); out.write("\n"); out.write("<!DOCTYPE html>\n"); @@ -146,7 +144,6 @@ public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase out.write("\n"); out.write(" <!--Plugins-->\n"); out.write("</head>\n"); - out.write("\n"); out.write("<body>\n"); out.write(" <header>\n"); out.write(" <a href=\"index.html\" >TrawlTool</a>\n"); @@ -161,32 +158,28 @@ public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase out.write(" <section id=\"nameDropdownIn\">\n"); out.write(" <form method=\"POST\" action=\"doBioLookup.do\"> <!--.do extension is not necessary. This field is the servlet's url in web.xml-->\n"); out.write(" Phylum:\n"); - out.write(" <select name=\"phylum\" size=\"1\">\n"); - out.write(" <option>Arthropoda</option>\n"); + out.write(" <select name=\"phylum\" size=\"1\" onChange=\"this.form.submit()\">\n"); + out.write(" <option value=\"0\">Arthropoda</option>\n"); out.write(" <option>Chordata</option>\n"); out.write(" <option>Mollusca</option>\n"); out.write(" </select>\n"); - out.write(" <input type=\"SUBMIT\">\n"); out.write("\n"); out.write(" Class:\n"); - out.write(" <select name=\"class\" size=\"1\">\n"); + out.write(" <select name=\"class\" size=\"1\" onChange=\"alert()\">\n"); + out.write(" <option>SomeClass</option>\n"); out.write(" </select>\n"); - out.write(" <!--<input type=\"SUBMIT\">-->\n"); out.write("\n"); out.write(" Order:\n"); out.write(" <select name=\"order\" size=\"1\">\n"); out.write(" </select>\n"); - out.write(" <!--<input type=\"SUBMIT\">-->\n"); out.write("\n"); out.write(" Family:\n"); out.write(" <select name=\"family\" size=\"1\">\n"); out.write(" </select>\n"); - out.write(" <!--<input type=\"SUBMIT\">-->\n"); out.write("\n"); out.write(" Genus:\n"); out.write(" <select name=\"genus\" size=\"1\">\n"); out.write(" </select>\n"); - out.write(" <!--<input type=\"SUBMIT\">-->\n"); out.write("\n"); out.write(" Species:\n"); out.write(" <select name=\"species\" size=\"1\">\n"); -- GitLab