Skip to content

Commit

Permalink
Adding a zoom in/out method
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Faria <rodrigoadfaria@gmail.com>
  • Loading branch information
rodrigoadfaria committed Oct 30, 2016
1 parent c241d9b commit 3c49c57
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 155 deletions.
20 changes: 15 additions & 5 deletions app/assets/javascripts/charts.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
//google.charts.load('current', {'packages':['line']});
//google.charts.setOnLoadCallback(drawChart);

$(document).ready(function() {
updateChart();
setInterval(updateChart, 5000);

$('#in').on("click", function() {
updateChart('in');
});

$('#out').on("click", function() {
updateChart('out');
});
});

function updateChart() {
function updateChart(zoom) {
var route = 'https://edx-ruby-rails-rodrigoadfaria-1.c9users.io/sensor_values/'
if (zoom)
route += '?zoom='+ zoom;

$.ajax({
url: 'https://edx-ruby-rails-rodrigoadfaria-1.c9users.io/sensor_values/',
url: route,
complete : function() {
// do nothing
},
Expand Down Expand Up @@ -37,7 +47,7 @@ function drawChart(sensor_values) {
var options = {
chart: {
title: 'Leitor de Consumo',
subtitle: 'medida em Watt'
subtitle: 'Medida em Watt'
},
width: 900,
height: 500,
Expand Down
Loading

0 comments on commit 3c49c57

Please sign in to comment.