chart calculations moved to lib