building new statistics js

New functions to make statistics from the data.
Still need some of the functions from the backend to run this, but
overall, it should work.