Fix undefined chart issue