-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a viz.html that will contain the code of the interface. Started…
… javascript coding, updated style.css
- Loading branch information
1 parent
679ea20
commit 1791271
Showing
4 changed files
with
145 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script> | ||
var graphDiv = document.getElementById('tester'), | ||
data = [{x: [], y:[]}], | ||
layout = {}; | ||
|
||
Plotly.newPlot(graphDiv, data, layout); | ||
|
||
$.get("/data", function(data){ | ||
console.log(data) | ||
myfunction(data); | ||
}) | ||
|
||
function myfunction(data){ | ||
var xaxis = [] | ||
var yaxis = [] | ||
response_json = JSON.parse(data); | ||
for (i=0; i < response_json.length; i++){ | ||
xaxis.push(response_json[i].country) | ||
yaxis.push(response_json[i].total_usd) | ||
} | ||
|
||
|
||
graphDiv.data = [ | ||
{ | ||
x: xaxis, | ||
y: yaxis, | ||
type: 'bar' | ||
} | ||
]; | ||
|
||
graphDiv.layout = { | ||
title: 'Total trade (in USD) of edible commodities for top countries', | ||
yaxis: {title : {text: 'Trade in USD'}, range: [0,160000000000]} | ||
}; | ||
|
||
Plotly.react(graphDiv, graphDiv.data, graphDiv.layout); | ||
} | ||
|
||
$(document).ready(function() { | ||
|
||
$("select").on('change', function(event){ | ||
var yearvalue = document.getElementById("year-value").value; | ||
var dataToBeSent = document.getElementById("mySelect").value; | ||
$.ajax({ | ||
type: "POST", | ||
url: "send_data", | ||
contentType: "application/json", | ||
data: JSON.stringify([dataToBeSent, yearvalue, $top.data("from"), $top.data("to")]), | ||
dataType: "json", | ||
success: function (response) { | ||
console.log(Date.now()); | ||
|
||
myfunction(response); | ||
}, | ||
error: function (error) { | ||
console.log(error); | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<html xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<head> | ||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | ||
<!-- <script type="text/javascript" src="main.js"></script> --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.0/js/ion.rangeSlider.min.js"></script> | ||
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.0/css/ion.rangeSlider.min.css"/> | ||
<script type="text/javascript" src="{{ url_for('static', filename='IRViz.js') }}"></script> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> | ||
</head> | ||
|
||
<div class = "ex1"> | ||
<select id="mySelect"> | ||
<option>MAP</option> | ||
<option>nDCG</option> | ||
</select> | ||
| ||
<input type="text" id="range-value" value="2002" class="autoupdate"/> | ||
<input type="submit" value="Submit"> | ||
</div> | ||
|
||
<div id="tester"></div> | ||
|
||
<div id="topslider"></div> | ||
|
||
</html> |