Graphing NetNewsWire With the Google Chart API

From the archive — written 17 years ago. About old posts.

There’s a nice Ruby wrapper for the Google Chart API. Here’s that NetNewsWire group attention chart using it:

<p>

[sourcecode language=‘ruby’]

!/usr/bin/ruby

require ‘rubygems’

require ‘appscript’

require ‘google_chart’

include Appscript

nnw = app(“NetNewsWire”)

unwanted_groups = [“Clippings”, “Mobile”, “Flagged Items”, “Latest News”, “monitors”, “miscfeeds”]

groups = nnw.subscriptions[its.is_group.eq(true)].get

groups.reject!{|g| unwanted_groups.include?(g.display_name.get) }

pc = GoogleChart::PieChart.new(‘500x200’, “Groups”, false)

groups.each do |s|

pc\.data s\.display\_name\.get, s\.calculated\_attention\_score\.get

end

puts pc.to_url

[/sourcecode]

</p>

“pc.to_url” yields:

http://chart\.apis\.google\.com/chart?chtt=Groups&chd=s:9ieaHBA&cht=p&chl=mma|mac|blogs|politics|web|people\_blogs|news&chs=500x200

which produces this:

<div style="text\-align:center;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2009/01/chart.png)</div>

And here it is doing the Safari views-per-day history:

<div style="text\-align:center;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2009/01/c02424c4-a793-4630-9e58-b1206af280b5.jpg)</div>

#google charts #netnewswire #ruby

Drop a line about this.