Last active
December 7, 2015 16:42
-
-
Save namessanti/58066e3ec95991e679fd to your computer and use it in GitHub Desktop.
HeatSeek sensor data Visualization
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Analyzing sensor data</title> | |
<meta name='viewport' content='initial-scale=1.0, user-scalable=no'> | |
<meta http-equiv='content-type' content='text/html; charset=utf-8'> | |
<style type='text/css'> | |
html, body { | |
border: 0; | |
margin: 0; | |
padding: 0; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
} | |
#map { | |
height: 100%; | |
background-color: #384047; | |
} | |
</style> | |
<link rel='stylesheet' href='http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css'> | |
<script src='http://libs.cartocdn.com/cartodb.js/v3/cartodb.js'></script> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script> | |
function pad(n, width, z) { | |
z = z || '0'; n = n + ''; | |
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; | |
} | |
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | |
function main() { | |
cartodb.createVis('map', 'https://namessanti.cartodb.com/api/v2/viz/9b949cec-9b82-11e5-b7e1-0e787de82d45/viz.json') | |
.done(function(vis, layers) { | |
var slider = vis.getOverlay('time_slider'); | |
slider.formatter(function(d) { if(1 == 1){ $('.time .value').css('width','160px'); | |
return pad(d.getMonth()+1,2) +'/'+ pad(d.getDate(),2) +'/'+ d.getFullYear() + ' ' + pad(d.getHours(),2) +':'+pad(d.getMinutes(),2)+':'+pad(d.getSeconds(),2); | |
} | |
else { | |
$('.time .value').css('width','120px'); | |
var day = days[d.getDay()]; return pad(day,9,' ') + ' ' + pad(d.getHours(),2) +':'+pad(d.getMinutes(),2)+':'+pad(d.getSeconds(),2); } }) }) .error(function(err) { console.log(err); }); } | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment