October 7th, 2004, 03:22 AM
poll - SVG
i am suppsoed to make a simple poll with SVG and python,
can anybody help me??
i need some suggestions, and maybe some links where i can find code exmples, and so on ???
October 7th, 2004, 05:55 AM
Just a few things to check, really just for more spacific info on what you want here. By SVG you mean Scalable Vector Graphics right? I've never used this. But I'm assuming that you want something like the polls on Devshed? Or the little green lines on Google?
October 7th, 2004, 02:01 PM
yeah, youre right SVG is Scalar Vector Graphics. i want to make a poll which have three options like "yes" "no" and "dont know". i wants show results these results with diagram and i wants to write that code in python ??
hope its helps,
October 7th, 2004, 06:25 PM
Ok, I think I know what you're getting at. But, before I have a go at this - using Python CGI - it would be great if you could post a link to something similar .
October 8th, 2004, 05:40 AM
something like this: http://www.sfgate.com/polls/
October 9th, 2004, 08:35 AM
If you can execute dynamic Pages then SVG is probably overkill. But, after messing around with it for a bit I didn't really come up with anything useful/relevent in that area... that is except a function for calculating the length of the precent bar:
This was mainly due to not having PIL installed on my system anymore - though I will be changing that later today. Anyway, I'd suggest that you take a look at the PIL module, available from:
def percentBar(votes, total, length):
#Takes the number of votes for this bar, the 'total' number of votes and
#the length of the bar and calculates the size of this bar to be drawn.
positiveSize = (votes / total) * length
#Returns a Tuple containing the actual percentage of votes and the length
#(as a float) of the two sides; if you're only interested in the positive
#side of the bar then ignore the third value in this Tuple.
return ((votes / total) * 100, positiveSize, length - positiveSize)
There is also an article on devshed regarding this (first link), though it doesn't really cover drawing shapes, so you might want to look here aswell (second link):
Last edited by netytan; October 9th, 2004 at 08:38 AM.
October 9th, 2004, 08:18 PM
Just a small tweak:
The float to make sure you have a non-zero result when integers are passed and the int to round down positiveSize to the nearest pixel.
positiveSize = int((votes / float(total)) * length)
October 10th, 2004, 06:01 AM
Thanks Grim! I don't know why I didn't think of that .