What is the math behind popular Bitcoin graphs? I want to graph Namecoin (or similar *coin) technologies? How can I create graphs similar to http://bitcoin.sipa.be, and blockchain.info for Namecoin?

For example this thread discusses how to analyze difficulty over time and provides this  equation and correlation covering 4 difficulty adjustments.

I'd like to understand the math required to create such graphs so I can port the trending to other *coin usages. (which invariably have different values)
The math behind those graphs is pretty simple, the main problem is crawling through the data and creating readable images automatically.

Difficulty (red line) can always be read from the generated Blocks, no problem there.

1/3/7/14/whatever-window estimates I assume are calculated by counting how many Blocks were generated in a given time period and at what difficulty. In general I guess it should be:

Estimate = (Difficulty * MeasurementTime) / (10 minutes * BlockCount)