Created
January 14, 2013 04:24
-
-
Save popowa/4527749 to your computer and use it in GitHub Desktop.
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
google.load("visualization", "1", {packages:["corechart"]}); | |
google.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable([ | |
['Age Groups','男性', '女性'], | |
['0-4歳',270,257], | |
['5-9',277,264], | |
['10-14',300 ,286], | |
['15-19',310,295], | |
['20-24',321, 306], | |
['25-29',358, 345], | |
['30-34',395, 385], | |
['35-39',475, 462], | |
['40-44',480, 470], | |
['45-49',414, 410], | |
['50-54',385, 385], | |
['55-59',392, 398], | |
['60-64',497, 517], | |
['65-69',398, 432], | |
['70-74',344, 395], | |
['75-79',275, 352], | |
['80-84', 185, 283], | |
['over 85', 125, 310] | |
]); | |
var options = { | |
//title: '年齢、男女別人口::平成24年12月1日現在 (概算値)', | |
vAxis: {title: '年代グループ(5歳おき)', titleTextStyle: {color: 'red'}}, | |
hAxis: {title: '人口 (万人)', titleTextStyle: {color: '#FF0000'}} | |
}; | |
var chart = new google.visualization.BarChart(document.getElementById('chart_div')); | |
chart.draw(data, options); | |
//yearly population | |
var data_year = google.visualization.arrayToDataTable([ | |
['Year', '確定人口(千人)'], | |
['1991', 124101], | |
['1992', 124567], | |
['1993', 124938], | |
['1994', 125265], | |
['1995(7)',125570], | |
['1996',125859], | |
['1997',126157], | |
['1998',126472], | |
['1999',126667], | |
['2000',126926], | |
['2001',127316], | |
['2002',127486], | |
['2003',127694], | |
['2004',127787], | |
['2005', 127768], | |
['2006', 127901], | |
['2007', 128033], | |
['2008', 128084], | |
['2009', 128032], | |
['2010', 128057], | |
['2011',127799 ] | |
]); | |
var options_year = { | |
//title: 'Company Performance' | |
}; | |
var chart_year = new google.visualization.LineChart(document.getElementById('chart_div_year')); | |
chart_year.draw(data_year, options_year); | |
//SpreadSheet | |
var opts = { | |
//sendMethod: 'xhr' | |
}; | |
var query = new google.visualization.Query('https://spreadsheets.google.com/tq?key=0AqYMJut9ccjYdFBZeFFES1hhOVpVeTN1dm9KMUV3dXc&gid=0',opts); | |
// Apply query language. | |
query.setQuery('SELECT A,C,D'); | |
// Send the query with a callback function. | |
query.send(handleQueryResponse); | |
} | |
function handleQueryResponse(response) { | |
if (response.isError()) { | |
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); | |
return; | |
} | |
var data_query = response.getDataTable(); | |
var lineChart = new google.visualization.LineChart(document.getElementById('chart_div_age')); | |
lineChart.draw(data_query, {title: '年齢(各歳)/男女別人口-総人口(平成23年10月1日現在)'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment