Cleanup chart rendering code