图表按好友列出的最近推文总比例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图表按好友列出的最近推文总比例相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env ruby require "rubygems" require "twitter" require "active_support" require "google_chart" twitter_user = "" twitter_pass = "" httpauth = Twitter::HTTPAuth.new(twitter_user, twitter_pass) client = Twitter::Base.new(httpauth) totals = {} client.friends_timeline(:count => 200).each do |t| user = t.user.screen_name if !totals.has_key? user totals[user] = 1 else totals[user] +=1 end end pc = GoogleChart::PieChart.new('500x200', "Total Proportion of Recent Tweets", false) totals.each do |key,val| pc.data key, val end puts pc.to_url
以上是关于图表按好友列出的最近推文总比例的主要内容,如果未能解决你的问题,请参考以下文章