charts generation refactoring