Created
February 21, 2015 03:49
-
-
Save bcdejp/dc892c206488220e84fb to your computer and use it in GitHub Desktop.
Google Chart APIを使ってグラフ表示するためのテンプレート
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> | |
<head> | |
<title>Temperature Chart</title> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load("visualization", "1", {packages:["corechart"]}); | |
google.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable([ | |
['Date', 'Temp'], | |
{% for record in temp_list %} | |
['{{record.date}}', {{record.temp}}], | |
{% endfor %} | |
]); | |
// グラフのオプションを設定 | |
var options = { | |
title: '{{title}}' | |
}; | |
var chart = new google.visualization.LineChart(document.getElementById('chart_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="chart_div" style="width: 80%; height: 400px;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment