Stat: Refactor sparkline js.

- Reuse drawing logic for drawing all bars in the beginning
- Better naming