Fixed a bug with charts
Small refactoring