Improve script code

Factor out loading of CSV data into separate function and parameterize
drawChart function.