This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
binaryattraction/app/helpers/photos_helper.rb

26 lines
894 B
Ruby
Raw Normal View History

2008-10-01 02:19:35 -04:00
module Merb
module PhotosHelper
def vote_count(photo)
curl = Gchart.pie(
:size => '400x200',
:title => "Oneable Results",
:legend => [ 'Not One', 'One' ],
:data => [ photo.zero_votes, photo.one_votes ],
:theme => :pastel
)
"<img src='#{curl}' alt='Chart Results' />"
end
2008-10-17 04:53:38 -04:00
def stat_chart
curl = Gchart.pie(
:size => '415x275',
:title => "Voting results for #{@photo_ids.size} photos. Oneness #{"%.1f%%" % (@votes.select { |v| v.one? }.size.to_f / @votes.size.to_f * 100.0)}",
:legend => [ "Not One (#{@votes.select { |v| v.zero? }.size})", "One (#{@votes.select { |v| v.one? }.size})" ],
:data => [ @votes.select { |v| v.zero? }.size, @votes.select { |v| v.one? }.size ],
:theme => :pastel
)
"<img src='#{curl}' alt='Chart Results' />"
end
2008-10-01 02:19:35 -04:00
end
end # Merb