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

Edited histogram.jsp

parent fe47541f
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" %> <%@ page import="java.util.*, data.Record, model.TrawlExpert, search.BST, search.BasicSearchResult" %>
<head> <head>
<!-- Plotly.js --> <!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head> </head>
<body> <body>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div> <div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script> <script>
<% <%
TrawlExpert te = (TrawlExpert)request.getServletContext().getAttribute("trawl"); TrawlExpert te = (TrawlExpert)request.getServletContext().getAttribute("trawl");
BasicSearchResult result = te.rangeSearch(159512, 1960, 2016); BasicSearchResult result = te.rangeSearch(159512, 1960, 2016);
BST<Integer, Integer> histogram = result.histogram(); BST<Integer, Integer> histogram = result.histogram();
Iterable<Integer> results = histogram.keys(); Iterable<Integer> results = histogram.keys();
out.print("var y=[];"); out.print("var y=[];");
out.print("var x=[];"); out.print("var x=[];");
for (Integer year: results){ for (Integer year: results){
out.print("y.push("+ histogram.get(year) +");"); out.print("y.push("+ histogram.get(year) +");");
out.print("x.push("+ year +");"); out.print("x.push("+ year +");");
} }
out.print((String) request.getAttribute("url")); out.print((String) request.getAttribute("url"));
%> %>
var data = [ var data = [
{ x: x, { x: x,
y: y, y: y,
type: 'bar', type: 'bar',
orientation: 'h', orientation: 'h',
marker: { marker: {
color: 'blue', color: 'blue',
}, },
} }
]; ];
var layout = { var layout = {
title: 'Individual count vs Year', title: 'Individual count vs Year',
xaxis:{title: 'Year', xaxis:{title: 'Year',
autorange:'reversed' titlefont: {
}, family: 'Courier New, monospace',
yaxis:{title: 'Individual count', size: 18,
side:'right' color: '#7f7f7f'
} }
} },
Plotly.newPlot('Histogram', data,layout); yaxis:{title: 'Individual count',
</script> titlefont: {
</body> family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
}
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