Refactored guage graph and presenter to make variable names clearer

pull/1/head
Nelson Jovel 4 years ago
parent 03a63cb568
commit d2c2eb8994

@ -20,24 +20,35 @@ class GaugePresenter
percentage_for @scale.approval_zone.low_benchmark
end
def watch_low_legend
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_legend
def growth_low_boundary
percentage_for @scale.growth_zone.low_benchmark
end
def approval_low_legend
def approval_low_boundary
percentage_for @scale.approval_zone.low_benchmark
end
def ideal_low_legend
def ideal_low_boundary
percentage_for @scale.ideal_zone.low_benchmark
end
private
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…
Cancel
Save