From a9a078a7f4a7a0a9c4e57c02f66722f4d6c1cec6 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 16:22:01 -0400 Subject: Added quotes stats page --- app/views/layouts/quotes.html.haml | 1 + app/views/quotes/stats.html.haml | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/views/quotes/stats.html.haml (limited to 'app/views') 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 @@ - if user_signed_in? %li= link_to_unless_current "Submit", new_quote_url %li= link_to_unless_current "Tags", tags_quotes_url + %li= link_to_unless_current "Stats", stats_quotes_url %li= link_to_unless_current "Feed", latest_quotes_url(:atom) .cleardiv #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 @@ +%script{ :type => "text/javascript", :src => "https://www.gstatic.com/charts/loader.js" } +%script{ :type => "text/javascript" } + google.charts.load('visualization', '1.0', {'packages':['corechart']}); + google.charts.setOnLoadCallback(drawChart); + function drawChart() + { + var data = new google.visualization.DataTable(); + data.addColumn('string', 'Month'); + data.addColumn('number', 'Quotes Submitted'); + data.addRows([ + - @months.each do |month| + ['#{month[:name]}', #{month[:number]}], + ]); + var options = {'title':'Quotes Submitted in the Last 12 Months', 'width':1000, 'height':500, 'legend':'none', 'hAxis.maxAlternation':1}; + var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); + chart.draw(data, options); + //var data2 = new google.visualization.DataTable(); + //data2.addColumn('string', 'Month'); + //data2.addColumn('number', 'Quotes'); + //data2.addRows([ + //- @months2.each do |month| + // ['\#{month[:name]}', \#{month[:number]}], + //]); + //var options2 = {'title':'Number of Quotes', 'width':1000, 'height':500, 'legend':'none', 'hAxis.maxAlternation':1}; + //var chart2 = new google.visualization.AreaChart(document.getElementById('chart2_div')); + //chart2.draw(data2, options2); + var data3 = new google.visualization.DataTable(); + data3.addColumn('string', 'Speaker'); + data3.addColumn('number', 'Quotes'); + data3.addRows([ + - @by_speaker.each do |speaker| + ['#{speaker[0]}', #{speaker[1]}], + ]); + var options3 = {'title':'Number of Quotes per Speaker', 'width':1000, 'height':500}; + var chart3 = new google.visualization.ColumnChart(document.getElementById('chart3_div')); + chart3.draw(data3, options3); + } +%p.normal Because charts are fun, we've compiled a few charts here containing statistics about the Four Island Quotes DB. +#chart2_div +#chart_div +#chart3_div -- cgit 1.4.1