79 lines
2.0 KiB
Plaintext
79 lines
2.0 KiB
Plaintext
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 50).to_s%>px; margin: 0 auto" class="contentbox">
|
|
<div style="background:red"><b><%= answeredquestion.title%></b>
|
|
|
|
<ul>
|
|
<% answeredquestion.choices.each do |c| %>
|
|
<li>
|
|
<%= c.to_s %>: <%= answeredquestion.answers.where(choice_id: c.id).count %> votes
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
<script>
|
|
$(function () {
|
|
$('#container_question_<%= answeredquestion.id %>').highcharts({
|
|
chart: {
|
|
type: 'bar'
|
|
},
|
|
title: {
|
|
text: '<%= answeredquestion.title%>'
|
|
},
|
|
subtitle: {
|
|
text: '<%= answeredquestion.text %>'
|
|
},
|
|
xAxis: {
|
|
categories: [<%= raw(answeredquestion.choices.map{|c| "'"+escape_javascript(ff_icon("ffi1-good2"))+c.text+"'"}.join(",")) %>],
|
|
title: {
|
|
text: null
|
|
},
|
|
labels: {
|
|
useHTML: true
|
|
}
|
|
},
|
|
yAxis: {
|
|
min: 0,
|
|
title: {
|
|
text: 'Answers',
|
|
align: 'high'
|
|
},
|
|
labels: {
|
|
overflow: 'justify'
|
|
}
|
|
},
|
|
tooltip: {
|
|
valueSuffix: ' votes'
|
|
},
|
|
plotOptions: {
|
|
bar: {
|
|
dataLabels: {
|
|
enabled: true
|
|
}
|
|
}
|
|
},
|
|
legend: {
|
|
layout: 'vertical',
|
|
align: 'right',
|
|
verticalAlign: 'top',
|
|
x: -40,
|
|
y: 80,
|
|
floating: true,
|
|
borderWidth: 1,
|
|
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
|
|
shadow: true
|
|
},
|
|
credits: {
|
|
enabled: false
|
|
},
|
|
series: [{
|
|
name: '<%= answeredquestion.title%>',
|
|
data: [<%= raw(answeredquestion.choices.map{|c| c.answers.count.to_s}.join(",")) %>]
|
|
}]
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
</div>
|