sqm-dashboards/app/views/shared/_histogram.html.haml
2017-11-01 16:21:36 -04:00

12 lines
505 B
Text

- histogram = data.responses.map(&:answer_index_with_reverse).group_by { |a| a.to_s }
%table.answers
%tbody
- data.question.options_with_reverse.each_with_index do |option, index|
%tr.answer
- group = histogram[index.to_s]
- width = (100 * (group.blank? ? 0 : group.length)) / histogram.values.flatten.length
%td.text
= "#{option}:"
= group.blank? ? 0 : group.length
%td.count
%div{class: "bar#{index}", style: "width: #{width}%"}