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.pull/1/head
parent
30c97f4428
commit
50256cacce
@ -0,0 +1,2 @@
|
|||||||
|
module ColorHelper
|
||||||
|
end
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
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
|
||||||
@ -1,78 +1,102 @@
|
|||||||
class GroupedBarColumnPresenter
|
class GroupedBarColumnPresenter
|
||||||
include AnalyzeHelper
|
include AnalyzeHelper
|
||||||
attr_reader :score, :measure_name, :measure_id, :category, :position, :measure, :school, :academic_year
|
include ColorHelper
|
||||||
|
|
||||||
def initialize(measure:, school:, academic_year:, position:)
|
attr_reader :measure_name, :measure_id, :category, :position, :measure, :school, :academic_years
|
||||||
|
|
||||||
|
def initialize(measure:, school:, academic_years:, position:)
|
||||||
@measure = measure
|
@measure = measure
|
||||||
@measure_name = @measure.name
|
@measure_name = @measure.name
|
||||||
@measure_id = @measure.measure_id
|
@measure_id = @measure.measure_id
|
||||||
@category = @measure.subcategory.category
|
@category = @measure.subcategory.category
|
||||||
@school = school
|
@school = school
|
||||||
@academic_year = academic_year
|
@academic_years = academic_years
|
||||||
@position = position
|
@position = position
|
||||||
end
|
end
|
||||||
|
|
||||||
def score
|
def score(year_index)
|
||||||
measure.score(school:, academic_year:)
|
measure.score(school:, academic_year: academic_years[year_index])
|
||||||
end
|
end
|
||||||
|
|
||||||
def y_offset
|
def bars
|
||||||
case zone.type
|
@bars ||= yearly_scores.map.each_with_index do |item, index|
|
||||||
when :ideal, :approval
|
year = item[0]
|
||||||
(analyze_zone_height * 2) - bar_height_percentage
|
score = item[1]
|
||||||
else
|
AnalyzeBarPresenter.new(measure:, academic_year: year, score:, x_position: bar_x(index),
|
||||||
(analyze_zone_height * 2)
|
color: bar_color(year))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bar_color
|
def label
|
||||||
"fill-#{zone.type}"
|
'All Survey Data'
|
||||||
end
|
end
|
||||||
|
|
||||||
def bar_height_percentage
|
def basis
|
||||||
case zone.type
|
''
|
||||||
when :ideal
|
end
|
||||||
(percentage * zone_height_percentage + zone_height_percentage) * 100
|
|
||||||
when :approval
|
def show_irrelevancy_message?
|
||||||
(percentage * zone_height_percentage) * 100
|
!measure.includes_teacher_survey_items? && !measure.includes_student_survey_items?
|
||||||
when :growth
|
end
|
||||||
((1 - percentage) * zone_height_percentage) * 100
|
|
||||||
when :watch
|
def show_insufficient_data_message?
|
||||||
((1 - percentage) * zone_height_percentage + zone_height_percentage) * 100
|
scores = academic_years.map do |year|
|
||||||
when :warning
|
measure.score(school:, academic_year: year)
|
||||||
((1 - percentage) * zone_height_percentage + zone_height_percentage + zone_height_percentage) * 100
|
|
||||||
else
|
|
||||||
0.0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scores.all? { |score| !score.meets_teacher_threshold? && !score.meets_student_threshold? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def percentage
|
def column_midpoint
|
||||||
(score.average - zone.low_benchmark) / (zone.high_benchmark - zone.low_benchmark)
|
zone_label_width + (grouped_chart_column_width * (position + 1)) - (grouped_chart_column_width / 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def zone
|
def bar_width
|
||||||
zones = Zones.new(
|
3.5
|
||||||
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
|
end
|
||||||
|
|
||||||
def label
|
def message_x
|
||||||
'All Survey Data'
|
column_midpoint - message_width / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
def basis
|
def message_y
|
||||||
''
|
17
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_irrelevancy_message?
|
def message_width
|
||||||
!@measure.includes_teacher_survey_items? && !@measure.includes_student_survey_items?
|
20
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_insufficient_data_message?
|
def message_height
|
||||||
!score.meets_teacher_threshold? && !score.meets_student_threshold?
|
34
|
||||||
|
end
|
||||||
|
|
||||||
|
def column_end_x
|
||||||
|
zone_label_width + (grouped_chart_column_width * (position + 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
def column_start_x
|
||||||
|
zone_label_width + (grouped_chart_column_width * position)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def yearly_scores
|
||||||
|
yearly_scores = academic_years.each_with_index.map do |year, index|
|
||||||
|
[year, score(index)]
|
||||||
|
end
|
||||||
|
yearly_scores.reject do |yearly_score|
|
||||||
|
score = yearly_score[1]
|
||||||
|
score.average.nil? || score.average.zero? || score.average.nan?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bar_color(year)
|
||||||
|
@available_academic_years ||= AcademicYear.order(:range).all
|
||||||
|
colors[@available_academic_years.find_index(year)]
|
||||||
|
end
|
||||||
|
|
||||||
|
def bar_x(index)
|
||||||
|
column_start_x + (index * bar_width * 1.2) + ((column_end_x - column_start_x) - (yearly_scores.size * bar_width * 1.2)) / 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.2 KiB |
@ -1,30 +1,33 @@
|
|||||||
<g id="grouped-bar-column">
|
<g class="grouped-bar-column" data-for-measure-id="<%= presenter.measure.measure_id %>">
|
||||||
<rect x="<%= bar_label_x(presenter.position) - 2.5 %>%" y="<%= presenter.y_offset %>%" width="5%" height="<%= presenter.bar_height_percentage %>%" fill="#3E3A38" data-for-measure-id="<%= presenter.measure_id %>"/>
|
<% presenter.bars.each_with_index do |bar, index| %>
|
||||||
|
<rect data-for-academic-year="<%= bar.academic_year.range %>" x="<%= bar.x_position %>%" y="<%= bar.y_offset %>%" width="<%= presenter.bar_width %>%" height="<%= bar.bar_height_percentage %>%" fill="<%= bar.color %>" />
|
||||||
|
|
||||||
<% if ENV["SCORES"].present? && ENV["SCORES"].upcase == "SHOW" %>
|
<% if ENV["SCORES"].present? && ENV["SCORES"].upcase == "SHOW" %>
|
||||||
<text x="<%= bar_label_x(presenter.position) %>%" y="<%= 5 %>%" text-anchor="middle" dominant-baseline="middle" >
|
<text x="<%= bar.x_position + 1 %>%" y="5%" text-anchor="middle" dominant-baseline="middle" >
|
||||||
<%= presenter.score.average %>
|
<%= bar.average %>
|
||||||
</text>
|
</text>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<text class="graph-footer" x="<%= bar_label_x(presenter.position) %>%" y="<%= bar_label_height %>%" text-anchor="middle" dominant-baseline="middle" data-grouped-bar-label="<%= presenter.label %>">
|
|
||||||
|
<text class="graph-footer" x="<%= presenter.column_midpoint %>%" y="<%= bar_label_height %>%" text-anchor="middle" dominant-baseline="middle" data-grouped-bar-label="<%= presenter.label %>">
|
||||||
<%= presenter.label %>
|
<%= presenter.label %>
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
<% if presenter.show_irrelevancy_message? %>
|
<% if presenter.show_irrelevancy_message? %>
|
||||||
<rect x="<%= bar_label_x(presenter.position) - 10 %>%" y="<%= 17 %>%" rx="15" ry="15" width="20%" height="<%= 34 %>%" fill="white" stroke="gray"/>
|
<rect x="<%= presenter.message_x %>%" y="<%= presenter.message_y %>%" rx="15" ry="15" width="<%= presenter.message_width %>%" height="<%= presenter.message_height %>%" fill="white" stroke="gray"/>
|
||||||
|
|
||||||
<text x="<%= bar_label_x(presenter.position) %>%" y="<%= 20 %>%" text-anchor="middle">
|
<text x="<%= presenter.column_midpoint %>%" y="<%= 20 %>%" text-anchor="middle">
|
||||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="29%">measure not</tspan>
|
<tspan x="<%= presenter.column_midpoint %>%" y="29%">measure not</tspan>
|
||||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="34%">based on</tspan>
|
<tspan x="<%= presenter.column_midpoint %>%" y="34%">based on</tspan>
|
||||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="39%"><%= presenter.basis %> surveys </tspan>
|
<tspan x="<%= presenter.column_midpoint %>%" y="39%"><%= presenter.basis %> surveys </tspan>
|
||||||
</text>
|
</text>
|
||||||
<% elsif presenter.show_insufficient_data_message? %>
|
<% elsif presenter.show_insufficient_data_message? %>
|
||||||
<rect x="<%= bar_label_x(presenter.position) - 10 %>%" y="<%= 17 %>%" rx="15" ry="15" width="20%" height="<%= 34 %>%" fill="white" stroke="gray" />
|
<rect x="<%= presenter.message_x %>%" y="<%= presenter.message_y %>%" rx="15" ry="15" width="<%= presenter.message_width %>%" height="<%= presenter.message_height %>%" fill="white" stroke="gray" />
|
||||||
|
|
||||||
<text x="<%= bar_label_x(presenter.position) %>%" y="<%= 20 %>%" text-anchor="middle" >
|
<text x="<%= presenter.column_midpoint %>%" y="<%= 20 %>%" text-anchor="middle" >
|
||||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="29%">survey response</tspan>
|
<tspan x="<%= presenter.column_midpoint %>%" y="29%">survey response</tspan>
|
||||||
<tspan x="<%= bar_label_x(presenter.position) %>%" y="34%">rate below 25%</tspan>
|
<tspan x="<%= presenter.column_midpoint %>%" y="34%">rate below 25%</tspan>
|
||||||
</text>
|
</text>
|
||||||
<% end %>
|
<% end %>
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
Loading…
Reference in new issue