Add null check for chart definition