mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
checkbox change. Draw bar graphs for each academic year selected. Center bar graphs in their column. Color the columns to match the sample colors on the checkboxes. Add scores on beta to top of graph. Automatically display the most recent year of data for the district. Modify logic for the insufficient data message or the 'measure not based on student/teacher surveys' message so it only shows if there are no bars with data to display.
63 lines
1.6 KiB
Ruby
63 lines
1.6 KiB
Ruby
class AnalyzeBarPresenter
|
|
include AnalyzeHelper
|
|
attr_reader :score, :x_position, :academic_year, :measure_id, :measure, :color
|
|
|
|
def initialize(measure:, academic_year:, score:, x_position:, color:)
|
|
@score = score
|
|
@x_position = x_position
|
|
@academic_year = academic_year
|
|
@measure = measure
|
|
@measure_id = measure.measure_id
|
|
@color = color
|
|
end
|
|
|
|
def y_offset
|
|
case zone.type
|
|
when :ideal, :approval
|
|
(analyze_zone_height * 2) - bar_height_percentage
|
|
else
|
|
(analyze_zone_height * 2)
|
|
end
|
|
end
|
|
|
|
def bar_color
|
|
"fill-#{zone.type}"
|
|
end
|
|
|
|
def bar_height_percentage
|
|
case zone.type
|
|
when :ideal
|
|
(percentage * zone_height_percentage + zone_height_percentage) * 100
|
|
when :approval
|
|
(percentage * zone_height_percentage) * 100
|
|
when :growth
|
|
((1 - percentage) * zone_height_percentage) * 100
|
|
when :watch
|
|
((1 - percentage) * zone_height_percentage + zone_height_percentage) * 100
|
|
when :warning
|
|
((1 - percentage) * zone_height_percentage + zone_height_percentage + zone_height_percentage) * 100
|
|
else
|
|
0.0
|
|
end
|
|
end
|
|
|
|
def percentage
|
|
(score.average - zone.low_benchmark) / (zone.high_benchmark - zone.low_benchmark)
|
|
end
|
|
|
|
def zone
|
|
zones = Zones.new(
|
|
watch_low_benchmark: measure.watch_low_benchmark,
|
|
growth_low_benchmark: measure.growth_low_benchmark,
|
|
approval_low_benchmark: measure.approval_low_benchmark,
|
|
ideal_low_benchmark: measure.ideal_low_benchmark
|
|
)
|
|
zones.zone_for_score(score.average)
|
|
end
|
|
|
|
def average
|
|
return 0 if score.average.nil?
|
|
|
|
score.average.round(2)
|
|
end
|
|
end
|