diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/layouts/quotes.html.haml | 1 | ||||
-rw-r--r-- | app/views/quotes/stats.html.haml | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/app/views/layouts/quotes.html.haml b/app/views/layouts/quotes.html.haml index 68607f6..f42eee0 100644 --- a/app/views/layouts/quotes.html.haml +++ b/app/views/layouts/quotes.html.haml | |||
@@ -23,6 +23,7 @@ | |||
23 | - if user_signed_in? | 23 | - if user_signed_in? |
24 | %li= link_to_unless_current "Submit", new_quote_url | 24 | %li= link_to_unless_current "Submit", new_quote_url |
25 | %li= link_to_unless_current "Tags", tags_quotes_url | 25 | %li= link_to_unless_current "Tags", tags_quotes_url |
26 | %li= link_to_unless_current "Stats", stats_quotes_url | ||
26 | %li= link_to_unless_current "Feed", latest_quotes_url(:atom) | 27 | %li= link_to_unless_current "Feed", latest_quotes_url(:atom) |
27 | .cleardiv | 28 | .cleardiv |
28 | #page-body | 29 | #page-body |
diff --git a/app/views/quotes/stats.html.haml b/app/views/quotes/stats.html.haml new file mode 100644 index 0000000..d7a8140 --- /dev/null +++ b/app/views/quotes/stats.html.haml | |||
@@ -0,0 +1,41 @@ | |||
1 | %script{ :type => "text/javascript", :src => "https://www.gstatic.com/charts/loader.js" } | ||
2 | %script{ :type => "text/javascript" } | ||
3 | google.charts.load('visualization', '1.0', {'packages':['corechart']}); | ||
4 | google.charts.setOnLoadCallback(drawChart); | ||
5 | function drawChart() | ||
6 | { | ||
7 | var data = new google.visualization.DataTable(); | ||
8 | data.addColumn('string', 'Month'); | ||
9 | data.addColumn('number', 'Quotes Submitted'); | ||
10 | data.addRows([ | ||
11 | - @months.each do |month| | ||
12 | ['#{month[:name]}', #{month[:number]}], | ||
13 | ]); | ||
14 | var options = {'title':'Quotes Submitted in the Last 12 Months', 'width':1000, 'height':500, 'legend':'none', 'hAxis.maxAlternation':1}; | ||
15 | var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); | ||
16 | chart.draw(data, options); | ||
17 | //var data2 = new google.visualization.DataTable(); | ||
18 | //data2.addColumn('string', 'Month'); | ||
19 | //data2.addColumn('number', 'Quotes'); | ||
20 | //data2.addRows([ | ||
21 | //- @months2.each do |month| | ||
22 | // ['\#{month[:name]}', \#{month[:number]}], | ||
23 | //]); | ||
24 | //var options2 = {'title':'Number of Quotes', 'width':1000, 'height':500, 'legend':'none', 'hAxis.maxAlternation':1}; | ||
25 | //var chart2 = new google.visualization.AreaChart(document.getElementById('chart2_div')); | ||
26 | //chart2.draw(data2, options2); | ||
27 | var data3 = new google.visualization.DataTable(); | ||
28 | data3.addColumn('string', 'Speaker'); | ||
29 | data3.addColumn('number', 'Quotes'); | ||
30 | data3.addRows([ | ||
31 | - @by_speaker.each do |speaker| | ||
32 | ['#{speaker[0]}', #{speaker[1]}], | ||
33 | ]); | ||
34 | var options3 = {'title':'Number of Quotes per Speaker', 'width':1000, 'height':500}; | ||
35 | var chart3 = new google.visualization.ColumnChart(document.getElementById('chart3_div')); | ||
36 | chart3.draw(data3, options3); | ||
37 | } | ||
38 | %p.normal Because charts are fun, we've compiled a few charts here containing statistics about the Four Island Quotes DB. | ||
39 | #chart2_div | ||
40 | #chart_div | ||
41 | #chart3_div | ||