| 1 | {{{ |
| 2 | #!html |
| 3 | <script type="text/javascript" src="https://www.google.com/jsapi"></script> |
| 4 | <script type="text/javascript"> |
| 5 | |
| 6 | // Load the Visualization API and the piechart package. |
| 7 | google.load('visualization', '1.0', {'packages':['corechart']}); |
| 8 | |
| 9 | // Set a callback to run when the Google Visualization API is loaded. |
| 10 | google.setOnLoadCallback(drawCharts); |
| 11 | |
| 12 | // Callback that creates and populates a data table, |
| 13 | // instantiates the pie chart, passes in the data and |
| 14 | // draws it. |
| 15 | function drawCharts() { |
| 16 | |
| 17 | var query = new google.visualization.Query( |
| 18 | 'https://docs.google.com/spreadsheet/tq?range=A1%3AC20&key=0AheWVEgfgX69dF9hbWNQT3RGUGJkYjhMRGdvSEFqVHc&gid=0&headers=1'); |
| 19 | |
| 20 | // Send the query with a callback function. |
| 21 | query.send(handleQueryResponse); |
| 22 | } |
| 23 | |
| 24 | function handleQueryResponse(response) { |
| 25 | if (response.isError()) { |
| 26 | alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | var rawData = response.getDataTable(); |
| 31 | var newPapersData = rawData.clone(); |
| 32 | var citationsData = rawData.clone(); |
| 33 | |
| 34 | newPapersData.removeColumn(2); |
| 35 | citationsData.removeColumn(1); |
| 36 | |
| 37 | // Set chart options |
| 38 | var newPapersOptions = {'title':'New Papers by WARP Users', |
| 39 | width:300, height:200, |
| 40 | axisTitlesPosition:'none', |
| 41 | legend:{'position':'none'}, |
| 42 | colors:['blue'], |
| 43 | chartArea:{left:'25',top:'25',width:'100%',height:'75%'}}; |
| 44 | |
| 45 | var citationsChartOptions = {'title':'WARP Citations', |
| 46 | width:300, height:200, |
| 47 | axisTitlesPosition:'none', |
| 48 | legend:{'position':'none'}, |
| 49 | colors:['green'], |
| 50 | chartArea:{left:'25',top:'25',width:'100%',height:'75%'}}; |
| 51 | |
| 52 | // Instantiate and draw our chart, passing in some options. |
| 53 | var newPapersChart = new google.visualization.ColumnChart(document.getElementById('div_newPapersChart')); |
| 54 | var citationsChart = new google.visualization.ColumnChart(document.getElementById('div_citationsChart')); |
| 55 | |
| 56 | newPapersChart.draw(newPapersData, newPapersOptions); |
| 57 | citationsChart.draw(citationsData, citationsChartOptions); |
| 58 | } |
| 59 | </script> |
| 60 | |
| 61 | |
| 62 | }}} |
| 63 | |
| 64 | {{{ |
| 65 | #!html |
| 66 | <div id="div_newPapersChart" style="float:right"></div> |
| 67 | <div style="float:clear"></div> |
| 68 | <div id="div_citationsChart" style="float:right"></div> |
| 69 | }}} |