Skip to content

Instantly share code, notes, and snippets.

@Jonty
Forked from dsingleton/gchart-pie.py
Created November 4, 2009 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonty/226026 to your computer and use it in GitHub Desktop.
Save Jonty/226026 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
labels = []
values = []
for line in sys.stdin:
bits = line.strip().split(' ')
value = bits.pop(0)
label = ' '.join(bits)
labels.append(label)
values.append(int(value))
values = [value * 100 / sum(values) for value in values]
print "http://chart.apis.google.com/chart?cht=p&chd=t:%s&chs=600x300&chl=%s" % ( ','.join(map(str,values)), '|'.join(labels))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment