-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from scottwillson/total-racer-days
Total racer days
- Loading branch information
Showing
4 changed files
with
59 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,9 @@ | |
.margin-4 { | ||
margin: 4rem; | ||
} | ||
|
||
.stats-chart { | ||
height:800px; | ||
margin: 4rem 0; | ||
width:100%; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module Admin | ||
class StatsController < Admin::AdminController | ||
def index | ||
@years = %w[2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024] | ||
@chart_data = Stats.racer_days_by_discipline(@years) | ||
@years = Stats.years | ||
@racer_days_by_discipline = Stats.racer_days_by_discipline | ||
@total_racer_days = Stats.total_racer_days | ||
end | ||
end | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
<div id="racer-days-by-discipline" style="width:100%; height:800px;"></div> | ||
<div id="racer-days-by-discipline" class="stats-chart"></div> | ||
<div id="total-racer-days" class="stats-chart"></div> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
Highcharts.chart('racer-days-by-discipline', { | ||
title: { | ||
text: 'By Discipline' | ||
}, | ||
xAxis: { | ||
categories: <%= raw @years %> | ||
}, | ||
yAxis: { | ||
document.addEventListener('DOMContentLoaded', function() { | ||
Highcharts.chart('racer-days-by-discipline', { | ||
title: { | ||
text: 'Racer Days' | ||
} | ||
}, | ||
series: <%= raw @chart_data.to_json %> | ||
text: 'By Discipline' | ||
}, | ||
xAxis: { | ||
categories: <%= raw @years %> | ||
}, | ||
yAxis: { | ||
title: { | ||
text: 'Racer Days' | ||
} | ||
}, | ||
series: <%= raw @racer_days_by_discipline.to_json %> | ||
}); | ||
Highcharts.chart('total-racer-days', { | ||
title: { | ||
text: 'Total Racer Days' | ||
}, | ||
xAxis: { | ||
categories: <%= raw @years %> | ||
}, | ||
yAxis: { | ||
title: { | ||
text: 'Racer Days' | ||
} | ||
}, | ||
series: <%= raw @total_racer_days.to_json %> | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</script> |