bb4274d refactor chart into functions