refactored Chart.init