Created
March 27, 2011 12:30
-
-
Save yukioc/889164 to your computer and use it in GitHub Desktop.
Today's TEPCO power consumption for power saving
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
<html> | |
<body> | |
<div id="view"><i>Now loading TEPCO power consumption graph</i></div> | |
<script> | |
var cbTepco; | |
function getTepco(id,day){ | |
var s=document.createElement("script"); | |
s.type="text/javascript"; | |
s.src="http://tepco-usage-api.appspot.com/"+day+".json?callback=cbTepco" | |
cbTepco=(function(id,day){ | |
return function(pow){ | |
var per=function(i){return (i-1000)/5000*100|0;}; | |
var dat=""; | |
for(var i=0;i<=23;i++){ | |
if(i>0){dat+=","} | |
dat+=(i<pow.length)?per(pow[i].usage):0; | |
} | |
var max=per(pow[0].capacity); | |
var img=document.createElement('img'); | |
img.src="https://chart.googleapis.com/chart?chs=500x300" | |
+"&chtt="+encodeURI(day) | |
+"&chxt=x,y" | |
+"&chxr=1,1000,6000,1000" | |
+"&chxl=0:|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|" | |
+"&chg=0,10.0" | |
+"&chbh=10,2" | |
+"&chd=t1:"+dat+"|"+max | |
+"&chdl=today|capacity" | |
+"&chco=FFBB00,FF0000" | |
+"&cht=bvs" | |
+"&chm=H,FF0000,1,0,2" | |
; | |
document.getElementById(id).innerHTML=''; | |
document.getElementById(id).appendChild(img); | |
}})(id,day); | |
document.getElementById(id).appendChild(s); | |
} | |
(function(){ | |
var d=new Date(); | |
d.setTime(d.getTime()-2*60*60*1000); | |
getTepco('view',d.getFullYear()+'/'+(d.getMonth()+1)+'/'+d.getDate()); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment