Skip to content

Commit

Permalink
Merge pull request #122 from identity-research-lab/drop-percentages-f…
Browse files Browse the repository at this point in the history
…rom-categories

Remove percentages and add explainer to category word cloud
  • Loading branch information
CoralineAda authored Sep 14, 2024
2 parents a461059 + d371d17 commit 4456909
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/controllers/codebooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def show

# Support the previous/next navigation controls

Rails.logger.info("!!! => @context = #{@context}, @question.key = #{@question.key}")
sections = Question::QUESTIONS.keys.map(&:to_s)
previous_index = (sections.index(@question.key) - 1)
next_index = (sections.index(@question.key) + 1) % sections.length
Expand Down
4 changes: 2 additions & 2 deletions app/views/codebooks/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<% end %>
<% if @total_codes.to_i > 0 %>
<p>This word cloud reflects the relative frequency of codes within each derived category.</p>
<ul class="word-cloud">
<% @categories_histogram.keys.sort{|a,b| @categories_histogram[a] <=> @categories_histogram[b]}.reverse.each do |category| %>
<% font_size = ((@categories_histogram[category] / @total_codes.to_f) * 60).to_i + 5 %>
<% percentage = ((@categories_histogram[category] / @total_codes.to_f) * 100).to_i %>
<li style="font-size: <%= [font_size, 9].max %>px;"><%= category %> (<%= percentage < 1 ? "<1" : percentage %>%)</li>
<li style="font-size: <%= [font_size, 9].max %>px;"><%= category %></li>
<% end %>
</ul>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4456909

Please sign in to comment.