Complete rewrite of Javascript charting functions.

Merged with wiki. Huge thanks to Paul DeCoursey for this awesome change!