Move conversion functions and string variable into lib.js

This avoids duplication and makes things easier to maintain. It does add a
small amount of overhead but that seems negligible when looking at load times
and processing times.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the conversion functions

It turns out this was not as straight forward as I assumed when implementing
things. Given the massive amount of data that might have to be converted the
lookup and function call overhead made using the more elegant conversion
function way too slow when convering the values in the large arrays. But at
least for these two values there was no difference so I used this "just
because".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improve the hover behavior in stats

With this change the hover function finally notices if we are hovering over a
different series within the same data point - so we now get the correct hover
behavior when moving the mouse over the different bars for the same data point
and most importantly we can get the tooltip to pop up for the average if that
ends up being overlaid ontop of the energy bar (which typically happens in a
weekly chart).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>