Use local Plotly #15

Merged
mattbk merged 4 commits from plotly into master 2017-11-15 21:27:46 -06:00
9 changed files with 187087 additions and 105 deletions
Showing only changes of commit 3dafa8adbe - Show all commits

View File

@ -17,9 +17,18 @@
-->
<link rel="stylesheet" href="/static/css/normalize.css">
<link rel="stylesheet" href="/static/css/skeleton.css">
<link rel="stylesheet" type="text/css" href="/static/css/jquery.datetimepicker.css"/ >
<!-- Favicon
-->
<link rel="icon" type="image/png" href="/static/images/favicon.png">
<!~~ D3.js https://github.com/d3/d3/releases~~>
<script src="static/javascript/d3.min.js"></script>
<!~~ jQuery https://jquery.com/download/ ~~>
<script src="static/javascript/jquery-3.2.1.min.js"></script>
<!~~ Plotly.js https://github.com/plotly/plotly.js/releases/ ~~>
<script src="static/javascript/plotly.js"></script>
<script src="static/javascript/jquery.datetimepicker.full.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js" ></script>
</head>
<body>
<div class="container">
@ -48,7 +57,6 @@
<div class="row">
<div class="eleven columns">
<div class="one column">
<a href="" id="plotly">Plotly</a>
<a href="/">Live</a>
</div>
<form id="range_select" action = "/history" method="GET">
@ -68,9 +76,7 @@
</form>
</div>
</div>
<div class="row">
<a href="" id="plotly_url" target="_blank"></a><span id="plotly_wait"></span>
</div>
<div class='row' id='plotly-plot'></div>
<div class="row">
<div class="one-third column" style="margin-top: 5%">
<strong>Showing all records</strong>
@ -122,11 +128,7 @@
</div>
</div>
</body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/jquery.datetimepicker.css"/ >
<script src="/static/javascript/jquery.datetimepicker.full.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js" ></script>
<script>
@ -150,96 +152,11 @@
jQuery(".timezone").val(timezone.name());
jQuery("#range_select").submit();
});
jQuery("#plotly").click(function(){
jQuery("#plotly_wait").text("Sending data...");
jQuery("#plotly_url").text("");
{% autoescape false %}
jQuery.get("/to_plotly?{{query_string}}")
{% endautoescape %}
.done(function( data ) {
jQuery("#plotly_url").attr("href",data);
jQuery("#plotly_url").text("Click to see your plot");
jQuery("#plotly_wait").text("");
});
return false; //This is so that the click on the link does not cause the page to refresh
});
</script>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
<script>
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
data.addColumn('number', 'Temperature');
data.addRows([
{% for row in temp %}
[new Date({{row[0][0:4]}},{{row[0][5:7]}}-1,{{row[0][8:10]}},{{row[0][11:13]}},{{row[0][14:16]}}),{{'%0.2f'|format(row[1])}}],
{% endfor %}
]);
var options = {
width: 600,
height: 563,
hAxis: {
title: "Date",
gridlines: { count: {{temp_items}}, color: '#CCC' },
format: 'dd-MMM-yyyy HH:mm' },
vAxis: {
title: 'Degrees'
},
title: 'Temperature',
curveType: 'function' //Makes line curved
};
var chart = new google.visualization.LineChart(document.getElementById('chart_temps'));
chart.draw(data, options);
}
</script>
<script>
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
data.addColumn('number', 'Humidity');
data.addRows([
{% for row in hum %}
[new Date({{row[0][0:4]}},{{row[0][5:7]}}-1,{{row[0][8:10]}},{{row[0][11:13]}},{{row[0][14:16]}}),{{'%0.2f'|format(row[1])}}],
{% endfor %}
]);
var options = {
width: 600,
height: 563,
hAxis: {
title: "Date",
gridlines: { count: {{hum_items}}, color: '#CCC' },
format: 'dd-MMM-yyyy HH:mm' },
vAxis: {
title: 'Percent'
},
title: 'Humidity',
curveType: 'function' //Makes line curved
};
var chart = new google.visualization.LineChart(document.getElementById('chart_humid'));
chart.draw(data, options);
}
</script>
<div id='plotly-plot'></div>
{{ graphJSON }}
<footer>
<!~~ D3.js https://github.com/d3/d3/releases~~>
<script src="static/javascript/d3.min.js"></script>
<!~~ jQuery https://jquery.com/download/ ~~>
<script src="static/javascript/jquery-3.2.1.min.js"></script>
<!~~ Plotly.js https://github.com/plotly/plotly.js/releases/ ~~>
<script src="static/javascript/plotly.js"></script>
<!~~Plot data~~>
<script type="text/javascript">
var graph = {{graphJSON | safe}};