Clean up chart drawing code