Skip to content

Instantly share code, notes, and snippets.

@klochner
Created February 24, 2011 20:56
Show Gist options
  • Save klochner/842869 to your computer and use it in GitHub Desktop.
Save klochner/842869 to your computer and use it in GitHub Desktop.
def distribution_chart_helper(width,height,sent,click)
data = [sent,click].map{|d| [d,0.01].max}.join("|")
legend = "sent|clicks"
data_labels = (0..1).map{|i| "N*f0*,000000,#{i},-1,11"}.join("|")
max_val = [sent,click,1].max
series_colors = %Q{76a4fb,405887}
url = %Q{http://chart.apis.google.com/chart?chxt=y&chbh=a&chs=#{width}x#{height}&cht=bvg&chf=bg,s,efefef}
url += %Q{&chds=0,#{max_val*1.1}&chxr=0,0,#{max_val}}
url += %Q{&chco=#{series_colors}}
url += %Q{&chd=t:#{data}&&chdl=#{legend}}
url += %Q{&chm=#{data_labels}}
url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment