making generating charts a callback so it waits for data