Skip to content

Commit

Permalink
rest color
Browse files Browse the repository at this point in the history
  • Loading branch information
wear committed Sep 6, 2010
1 parent b7f0f03 commit 573c17d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -29,7 +29,7 @@ def recommand_link(form)
end

def random_color
['FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF','C0C0C0'][rand(6)]
['194E84','1F242A','60BB22','F2BABB','FFC200','FF5B00','B80028','84002E','4AC0F2'][rand(8)]
end

end
11 changes: 5 additions & 6 deletions app/views/forms/_chart.html.erb
Expand Up @@ -4,7 +4,7 @@
<section class="span-10">
<% data = field.options.map {|o| @form.klass.count({"f#{field.id}" => Regexp.new('(\s|^)' + o.value + '(\s|$)')})} %>
<% if field.options.length >= 5 %>
<img src="<%= Gchart.bar(:data => data,:axis_with_labels => 'x,y',:axis_labels => [[0,data.max],field.options.map{|f| truncate(f.value,:length => 14)}.reverse],:orientation => 'horizontal',:bar_colors => random_color) %>" />
<img src="<%= Gchart.bar(:data => data,:axis_with_labels => 'x,y',:axis_labels => [[0,data.max],field.options.map{|f| truncate(f.value,:length => 14)}.reverse],:orientation => 'horizontal',:bar_colors => random_color,:height => field.options.length*30) %>" />
<% else %>
<img src="<%= Gchart.pie(
:data => data, :labels => field.options.map(&:value),:bar_colors => random_color ) %>" />
Expand All @@ -13,21 +13,20 @@

<section class="span-8 last">
<table class='grid' id='huizong' cellspacing="0" cellpadding="0">
<col width='40%'>
<col width='80%'>
<col width='20%'>
<col width='40%'>
<thead>
<tr>
<th>选项</th>
<th>数量</th>
<th>数量</th>
</tr>
</thead>
<tbody>
<% field.options.each do |option| %>
<% option_count = @form.klass.count({"f#{field.id}" => Regexp.new('(\s|^)' + option.value + '(\s|$)')}) %>
<%# percentage = option_count * 100 / @form.rows_count %>
<% percentage = option_count * 100 / @form.rows_count %>
<tr>
<td><%=option.value%><%#=link_to option.value,chart_form_path(@form,:filter => option) %></td>
<td style='text-align:left;'><%=option.value%><%#=link_to option.value,chart_form_path(@form,:filter => option) %></td>
<td><%= option_count %></td>
<% if false %>
<td style="text-align:left;">
Expand Down

0 comments on commit 573c17d

Please sign in to comment.