mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
we have a gauge! next up, let's style the page
This commit is contained in:
parent
5d6c1000f4
commit
25578a896f
29 changed files with 614 additions and 112 deletions
34
app/presenters/gauge_presenter.rb
Normal file
34
app/presenters/gauge_presenter.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class GaugePresenter
|
||||
def initialize(scale:, score:)
|
||||
@scale = scale
|
||||
@score = score
|
||||
end
|
||||
|
||||
def title
|
||||
zone.type.to_s.capitalize
|
||||
end
|
||||
|
||||
def color_class
|
||||
"fill-#{zone.type}"
|
||||
end
|
||||
|
||||
def score_percentage
|
||||
percentage_for @score
|
||||
end
|
||||
|
||||
def key_benchmark_percentage
|
||||
percentage_for @scale.approval_zone.low_benchmark
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def zone
|
||||
@scale.zone_for_score(@score)
|
||||
end
|
||||
|
||||
def percentage_for(number)
|
||||
scale_minimum = @scale.warning_zone.low_benchmark
|
||||
scale_maximum = @scale.ideal_zone.high_benchmark
|
||||
(number - scale_minimum) / (scale_maximum - scale_minimum)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue