Tidied up chart functionality