SU2-33 | Изменена логика раскраски

This commit is contained in:
ARLakhin
2026-04-27 13:02:28 +03:00
parent 3f889b5b9a
commit 37e7d25976
2 changed files with 14 additions and 18 deletions
+11 -15
View File
@@ -4,8 +4,8 @@ module OrganisationsHelper
return nil if code.nil? || code.size < 2 return nil if code.nil? || code.size < 2
prefix = code[0, 2] prefix = code[0, 2]
case prefix case prefix
when '21', '22', '23', '24' when '21', '22', '23', '24', '25'
'21-24' '21-25'
else else
prefix prefix
end end
@@ -16,8 +16,8 @@ module OrganisationsHelper
prefix = code[0, 2] prefix = code[0, 2]
return false unless prefix.match?(/\A\d{2}\z/) return false unless prefix.match?(/\A\d{2}\z/)
if type_data == 'min_max' if type_data == 'min_max'
return false if %w[16 17].include?(prefix) return false if %w[16 17 29].include?(prefix) || prefix.start_with?("3")
return true if %w[21 22 23 24 25 29].include?(prefix) return true if %w[21 22 23 24 25].include?(prefix)
return !code.end_with?('00') return !code.end_with?('00')
elsif type_data == 'comparsion' elsif type_data == 'comparsion'
return code.end_with?('00') return code.end_with?('00')
@@ -43,18 +43,14 @@ module OrganisationsHelper
prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result| prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result|
next if code.nil? || !keep_code?(code) next if code.nil? || !keep_code?(code)
group = group_key(code) group = group_key(code)
result[group] ||= Hash.new { |h, k| h[k] = [] } result[group] ||= []
values.each_with_index do |value, index| result[group] += values.map { |value| parse_number(value)}
result[group][index + 1] << parse_number(value)
end
end end
min_max_data = prepared_data.transform_values do |columns| min_max_data = prepared_data.transform_values do |values|
columns.transform_values do |values| sorted = values.sort
sorted = values.sort size = sorted.size
size = sorted.size p50 = size.odd? ? sorted[size / 2] : (sorted[size / 2 - 1] + sorted[size / 2]) / 2.0
p50 = size.odd? ? sorted[size / 2] : (sorted[size / 2 - 1] + sorted[size / 2]) / 2.0 { min: sorted.first, p50: p50, max: sorted.last }
{ min: sorted.first, p50: p50, max: sorted.last }
end
end end
elsif type_data == 'comparsion' elsif type_data == 'comparsion'
prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result| prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result|
+3 -3
View File
@@ -43,9 +43,9 @@
- @current_doc_info1[key].each_with_index do |value, index| - @current_doc_info1[key].each_with_index do |value, index|
- key_group = key[1].nil? ? nil : group_key(key[1]) - key_group = key[1].nil? ? nil : group_key(key[1])
- if min_max_data.has_key?(key_group) && keep_code?(key[1]) - if min_max_data.has_key?(key_group) && keep_code?(key[1])
- min_value = min_max_data[key_group][index + 1][:min] - min_value = min_max_data[key_group][:min]
- max_value = min_max_data[key_group][index + 1][:max] - max_value = min_max_data[key_group][:max]
- p50 = min_max_data[key_group][index + 1][:p50] - p50 = min_max_data[key_group][:p50]
- color = get_color_for_cell(value, min: min_value, median: p50, max: max_value) - color = get_color_for_cell(value, min: min_value, median: p50, max: max_value)
td style="background-color: #{color}" = value td style="background-color: #{color}" = value
- elsif comparsion_data.has_key?(key[1]) && keep_code?(key[1], type_data: 'comparsion') - elsif comparsion_data.has_key?(key[1]) && keep_code?(key[1], type_data: 'comparsion')