Skip to content

Instantly share code, notes, and snippets.

@bcdejp
Created February 21, 2015 03:49
Show Gist options
  • Save bcdejp/dc892c206488220e84fb to your computer and use it in GitHub Desktop.
Save bcdejp/dc892c206488220e84fb to your computer and use it in GitHub Desktop.
Google Chart APIを使ってグラフ表示するためのテンプレート
<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