Fix null exception in charts api