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

Edited histogram

parent c784de31
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="insert, some, keywords"> <!--TODO-->
<meta name="description" content="insert a description"> <!--TODO-->
<title>About|TrawlTool</title>
<link rel="stylesheet" type="text/css" href="style.css">
<!--Fonts-->
<!--Open Sans Rg-400/Semi-600/Bd-700-->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
</head>
<body>
<header>
<div class="headerWrapper">
<a href="index.jsp" >TrawlTool</a>
<span class="nav-bar">
<a href="about.html">About</a> |
<a href="index.jsp" target="_blank">Gitlab/Github Nonfunc!</a>
</span>
</div>
</header>
<section>
Insert some info about the project, blah blah blah.<br>
Add photo credit if applicable
</section>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="insert, some, keywords"> <!--TODO-->
<meta name="description" content="insert a description"> <!--TODO-->
<title>About|TrawlTool</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<!--Fonts-->
<!--Open Sans Rg-400/Semi-600/Bd-700-->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
</head>
<body>
<header>
<div class="headerWrapper">
<a href="index.jsp" >TrawlTool</a>
<span class="nav-bar">
<a href="about.html">About</a> |
<a href="index.jsp" target="_blank">Gitlab/Github Nonfunc!</a>
</span>
</div>
</header>
<section>
Insert some info about the project, blah blah blah.<br>
Add photo credit if applicable
</section>
<div id="histogram">
</div>
</body>
<script src="histogram.js"></script>
</html>
\ No newline at end of file
function histogram(x,y){
console.log("Histogram")
var data = [
{ x: x,
y: y,
type: 'bar',
marker: {
color: 'blue',
},
}
];
var layout = {
title: 'Individual count vs Year',
xaxis:{title: 'Year',
type: 'category',
titlefont: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
},
yaxis:{title: 'Individual count',
titlefont: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
}
Plotly.newPlot('histogram', data,layout);
}
window.onload = histogram([1990,1991,1992],[54656,65654,32555]);
<%@ page import="java.util.*, data.Record, model.TrawlExpert, search.BST, search.BasicSearchResult" %>
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="org.json.simple.parser.JSONParser"%>
<body>
<div id="histogram"><!-- 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(2, 1960, 2016);
BST<Integer, Integer> histogram = result.histogram();
Iterable<Integer> results = histogram.keys();
out.print("var y=[];");
out.print("var x=[];");
JSONParser parser = new JSONParser();
JSONObject js = new JSONObject();
JSONArray x = new JSONArray();
JSONArray y = new JSONArray();
for (Integer year: results){
out.print("\ty.push("+ histogram.get(year) +");\n");
out.print("\tx.push('"+ year +"');\n");
x.add(year);
y.add(histogram.get(year));
}
js.put("year", x);
js.put("individualCount", y);
out.print(js.toJSONString());
%>
var data = [
{ x: x,
y: y,
type: 'bar',
marker: {
color: 'blue',
},
}
];
%>
var layout = {
title: 'Individual count vs Year',
xaxis:{title: 'Year',
type: 'category',
titlefont: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
},
yaxis:{title: 'Individual count',
titlefont: {
family: 'Courier New, monospace',
size: 18,
color: '#7f7f7f'
}
}
}
Plotly.newPlot('histogram', data,layout);
</script>
</body>
\ No newline at end of file
\ No newline at end of file
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