parent
989a6e7d3b
commit
d9335206d8
@ -1,3 +1,40 @@
|
||||
// Place all the styles related to the Questions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
.answers {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #ccc;
|
||||
|
||||
.answer {
|
||||
border-top: 1px solid #ccc;
|
||||
|
||||
.text {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
line-height: 2em;
|
||||
div {
|
||||
margin: 0.25em 0;
|
||||
height: 1.5em;
|
||||
}
|
||||
}
|
||||
|
||||
.bar0 {
|
||||
background-color: red;
|
||||
}
|
||||
.bar1 {
|
||||
background-color: orange;
|
||||
}
|
||||
.bar2 {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
.bar3 {
|
||||
background-color: green;
|
||||
}
|
||||
.bar4 {
|
||||
background-color: gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,2 +1,12 @@
|
||||
%p
|
||||
=# data.inspect
|
||||
- histogram = data.responses.map(&:answer_index).group_by { |a| a.to_s }
|
||||
%table.answers
|
||||
%tbody
|
||||
- data.question.options.each_with_index do |option, index|
|
||||
%tr.answer
|
||||
- group = histogram[(index + 1).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}%"}
|
||||
|
||||
Loading…
Reference in new issue