mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Refactored guage graph and presenter to make variable names clearer
This commit is contained in:
parent
03a63cb568
commit
d2c2eb8994
2 changed files with 32 additions and 34 deletions
|
|
@ -20,24 +20,35 @@ class GaugePresenter
|
|||
percentage_for @scale.approval_zone.low_benchmark
|
||||
end
|
||||
|
||||
def watch_low_legend
|
||||
percentage_for @scale.watch_zone.low_benchmark
|
||||
end
|
||||
|
||||
def growth_low_legend
|
||||
percentage_for @scale.growth_zone.low_benchmark
|
||||
end
|
||||
|
||||
def approval_low_legend
|
||||
percentage_for @scale.approval_zone.low_benchmark
|
||||
end
|
||||
|
||||
def ideal_low_legend
|
||||
percentage_for @scale.ideal_zone.low_benchmark
|
||||
def boundary_percentage_for(zone)
|
||||
case zone
|
||||
when :watch_low
|
||||
watch_low_boundary
|
||||
when :growth_low
|
||||
growth_low_boundary
|
||||
when :ideal_low
|
||||
ideal_low_boundary
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def watch_low_boundary
|
||||
percentage_for @scale.watch_zone.low_benchmark
|
||||
end
|
||||
|
||||
def growth_low_boundary
|
||||
percentage_for @scale.growth_zone.low_benchmark
|
||||
end
|
||||
|
||||
def approval_low_boundary
|
||||
percentage_for @scale.approval_zone.low_benchmark
|
||||
end
|
||||
|
||||
def ideal_low_boundary
|
||||
percentage_for @scale.ideal_zone.low_benchmark
|
||||
end
|
||||
|
||||
def zone
|
||||
@scale.zone_for_score(@score)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,31 +28,18 @@
|
|||
stroke-width="<%= stroke_width %>"
|
||||
/>
|
||||
|
||||
<% benchmark_boundaries = [:watch_low, :growth_low, :ideal_low]%>
|
||||
<% benchmark_boundaries.each do |zone| %>
|
||||
<line
|
||||
class="zone-benchmark stroke-gray-2"
|
||||
x1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.watch_low_legend)).x %>"
|
||||
y1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.watch_low_legend)).y %>"
|
||||
x2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.watch_low_legend)).x %>"
|
||||
y2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.watch_low_legend)).y %>"
|
||||
x1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.boundary_percentage_for(zone))).x %>"
|
||||
y1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.boundary_percentage_for(zone))).y %>"
|
||||
x2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.boundary_percentage_for(zone))).x %>"
|
||||
y2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.boundary_percentage_for(zone))).y %>"
|
||||
stroke-width="<%= stroke_width %>"
|
||||
/>
|
||||
<% end %>
|
||||
|
||||
<line
|
||||
class="zone-benchmark stroke-gray-2"
|
||||
x1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.growth_low_legend)).x %>"
|
||||
y1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.growth_low_legend)).y %>"
|
||||
x2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.growth_low_legend)).x %>"
|
||||
y2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.growth_low_legend)).y %>"
|
||||
stroke-width="<%= stroke_width %>"
|
||||
/>
|
||||
<line
|
||||
class="zone-benchmark stroke-gray-2"
|
||||
x1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.ideal_low_legend)).x %>"
|
||||
y1="<%= benchmark_line_point(outer_radius, angle_for(percentage: gauge.ideal_low_legend)).y %>"
|
||||
x2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.ideal_low_legend)).x %>"
|
||||
y2="<%= benchmark_line_point(inner_radius, angle_for(percentage: gauge.ideal_low_legend)).y %>"
|
||||
stroke-width="<%= stroke_width %>"
|
||||
/>
|
||||
<% if gauge.key_benchmark_percentage.present? %>
|
||||
<line
|
||||
class="zone-benchmark stroke-black"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue