base code for chart input