refactoring and fixing of chartdata