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/quotes/stats.html.haml | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/views/quotes/stats.html.haml (limited to 'app/views/quotes') 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