Skip to content
Snippets Groups Projects
Commit a21c3703 authored by Ray Liu's avatar Ray Liu
Browse files

Modified histogram.jsp

parent a19070ba
No related branches found
No related tags found
No related merge requests found
<%@ page import="java.util.*, data.Record, model.TrawlExpert, search.BST, search.BasicSearchResult" %>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script>
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<%
<body>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script>
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"));
%>
var data = [
{ x: x,
y: y,
type: 'bar',
orientation: 'h',
marker: {
color: 'blue',
},
}
];
var layout = {
title: '',
xaxis:{title: 'Year',
autorange:'reversed'
},
yaxis:{title: 'Individual count',
side:'right'
}
}
Plotly.newPlot('Histogram', data,layout);
</script>
\ No newline at end of file
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"));
%>
var data = [
{ x: x,
y: y,
type: 'bar',
orientation: 'h',
marker: {
color: 'blue',
},
}
];
var layout = {
title: '',
xaxis:{title: 'Year',
autorange:'reversed'
},
yaxis:{title: 'Individual count',
side:'right'
}
}
Plotly.newPlot('Histogram', data,layout);
</script>
</body>
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