Inquiring minds want to know more about the pretty pictures on my statistics page. It’s no secret (the source code is available — it’s even fairly well commented), but I’ll explain it a bit further. First off, I don’t draw the pictures myself; I use the Python wrapper for the wonderful GDChart graphing library. All open source and cross platform, truly amazing stuff. The parts I do myself are crunching the raw data from the access logs, and then passing that data off to gdchart in a format it understands. For a pie chart, gdchart wants a list of labels (”Win95″, “Win98″, “Linux”, etc.), and a corresponding list of data values (43, 154, 63, etc.). It calculates the percentages automatically, draws the graph, and saves the image to disk. There’s a couple of options to control the output, like which colors it uses, and the format of the saved image, but that’s the basic idea. Search the source code for “def pie(” to see the options; the code is surprisingly readable, even if you don’t know Python.

§

Respond privately

I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)



§

firehosecodeplanet

© 2001–9 Mark Pilgrim