#!/bin/bash url="http://chart.apis.google.com/chart?" # title chtt="What+are+the+top+3+issues+facing+Gentoo?" # color chco="45347b" # Use text encoding for data (floating-point numbers) chd="t:" while read i; do l=${i%:*} n=${i#*: } # Comment out if you want a total number for getting percentages # Total=163.0 (1.63) [[ $l = Total ]] && continue l="${l} (${n}%)" chl="${chl}${l}|" chd="${chd}${n}," done \ < <(awk '/^1/, /^2/ {print}' gentoo_survey.txt \ | grep ': [0-9]' gentoo_survey.txt \ | sort -t: -k2 -n -r \ | awk -F: \ 'BEGIN {other=0; tot=0} \ { tot+=$2; if ($2 > 3) printf("%s: %.1f\n", $1, $2/1.63); else other++} \ END {printf("%s: %.1f\n", "Other", other/1.63); print "Total: " tot}') # Strip off the last ones chd=${chd%,} chl=${chl%|} #chs="800x375" chs="1000x300" # 3d pie chart cht="p3" echo "${url}chs=${chs}&cht=${cht}&chd=${chd}&chl=${chl}&chtt=${chtt}&chco=${chco}"