From 2c9c57287fafa4c256048c2f51cf632b5e37996f Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 18 Apr 2016 18:48:59 +0800 Subject: [PATCH] changed export sheet title and also fixed issue in chart rendering in result page --- app/views/admin/surveys/export.xlsx.axlsx | 2 +- app/views/surveys/result.html.erb | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/admin/surveys/export.xlsx.axlsx b/app/views/admin/surveys/export.xlsx.axlsx index 814ccb4..f6b11d3 100644 --- a/app/views/admin/surveys/export.xlsx.axlsx +++ b/app/views/admin/surveys/export.xlsx.axlsx @@ -1,7 +1,7 @@ # encoding: utf-8 wb = xlsx_package.workbook -wb.add_worksheet(name: @survey.title) do |sheet| +wb.add_worksheet(name: @survey.title[0..15]) do |sheet| row = [] @survey_questions.each_with_index do |question, i| diff --git a/app/views/surveys/result.html.erb b/app/views/surveys/result.html.erb index a25bdb4..9efe5c4 100644 --- a/app/views/surveys/result.html.erb +++ b/app/views/surveys/result.html.erb @@ -25,9 +25,9 @@
<% when SurveyQuestion::Radiogroup %> - <% question.survey_question_options.each do |option| %> + <% question.survey_question_options.each_with_index do |option,index| %>
  • -
    +
  • <% end %> <% end %> @@ -57,15 +57,17 @@ chart_<%= qid %>.draw(data_<%= qid %>, {title: '<%= question.title %>'}); <% when ::SurveyQuestion::Radiogroup %> <% options = Hash[question.survey_question_options.collect{|o| [ o.id.to_s, o.name ] }] %> + <% i = 0 %> <% @chart_data[qid].each do |option, groups| %> - var data_<%= qid %>_<%= option %> = google.visualization.arrayToDataTable([ + var data_<%= qid %> = google.visualization.arrayToDataTable([ ['<%= t("survey_question.option") %>', ''], <% groups.each do |group, count| %> ['<%= group %>', <%= count %>], <% end %> ]); - var chart_<%= qid %>_<%= option %> = new google.visualization.PieChart(document.getElementById('question_chart_<%= qid %>_<%= option %>')); - chart_<%= qid %>_<%= option %>.draw(data_<%= qid %>_<%= option %>, {title: '<%= question.title %> - <%= options[option] %>'}); + var chart_xx = new google.visualization.PieChart(document.getElementById('question_chart_<%= qid %>_<%= i.to_s %>')); + chart_xx.draw(data_<%= qid %>, {title: '<%= question.title %> - <%= options[option] %>'}); + <% i = i + 1 %> <% end %> <% end %> <% end %>