Skip to content

Commit 7aa9658

Browse files
committed
Refactor: 統計ページの推移グラフの CSS のクラス化、固定値の定数化
1 parent b8e49ce commit 7aa9658

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

app/models/high_charts_builder.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class HighChartsBuilder
2+
HIGH_CHARTS_WIDTH = 600
3+
24
class << self
35
def global_options
46
LazyHighCharts::HighChartGlobals.new do |f|
@@ -18,7 +20,7 @@ def build_annual_dojos(source)
1820
{ title: { text: '増加数' }, tickInterval: 15, max: 75 },
1921
{ title: { text: '累積合計' }, tickInterval: 50, max: 250, opposite: true }
2022
]
21-
f.chart(width: 600, alignTicks: false)
23+
f.chart(width: HIGH_CHARTS_WIDTH, alignTicks: false)
2224
f.colors(["#A0D3B5", "#505D6B"])
2325
end
2426
end
@@ -35,7 +37,7 @@ def build_annual_event_histories(source)
3537
{ title: { text: '開催回数' }, tickInterval: 500, max: 2000 },
3638
{ title: { text: '累積合計' }, tickInterval: 3000, max: 12000, opposite: true }
3739
]
38-
f.chart(width: 600, alignTicks: false)
40+
f.chart(width: HIGH_CHARTS_WIDTH, alignTicks: false)
3941
f.colors(["#F4C34F", "#BD2561"])
4042
end
4143
end
@@ -52,7 +54,7 @@ def build_annual_participants(source)
5254
{ title: { text: '参加者数' }, tickInterval: 2500, max: 12500 },
5355
{ title: { text: '累積合計' }, tickInterval: 14000, max: 64000, opposite: true }
5456
]
55-
f.chart(width: 600, alignTicks: false)
57+
f.chart(width: HIGH_CHARTS_WIDTH, alignTicks: false)
5658
f.colors(["#EF685E", "#35637D"])
5759
end
5860
end

app/views/stats/show.html.erb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@
2020
<a href="#graph">📊</a>
2121
推移グラフ
2222
</h2>
23+
24+
<style>
25+
/* 中央寄せにする */
26+
.chart-wrapper { margin: 40px auto; }
27+
</style>
2328
<div align="center">
2429
<%= high_chart_globals(@high_charts_globals) %>
2530

26-
<!-- 道場数の推移 -->
27-
<p style="margin: 40px auto;"><%= high_chart("annual_dojos", @annual_dojos_chart) %></p>
28-
29-
<!-- 開催回数の推移 -->
30-
<p style="margin: 40px auto;"><%= high_chart("annual_event_histories", @annual_event_histories_chart) %></p>
31-
32-
<!-- 参加者数 -->
33-
<p style="margin: 40px auto;"><%= high_chart("annual_participants", @annual_participants_chart) %></p>
31+
<!-- 道場数、開催数、参加数の推移グラフ -->
32+
<div class='chart-wrapper'><%= high_chart("annual_dojos", @annual_dojos_chart) %></div>
33+
<div class='chart-wrapper'><%= high_chart("annual_event_histories", @annual_event_histories_chart) %></div>
34+
<div class='chart-wrapper'><%= high_chart("annual_participants", @annual_participants_chart) %></div>
3435
</div>
3536

3637
<h2 id="latest" style="margin-top: 70px; color: #333333;">

0 commit comments

Comments
 (0)