Fix bug in charts functionality