Add unit tests to chart functions.
Rewrite chart functions to share data transformations.
Merge pull request #3 from eric-wu/master

Rewrite chart functions to share data transformations, add unit tests