chart setup function now works correctly