Rewrite chartOutput function