improve chart dialog logic