Can you add a class to multiple elements in a single line of code?

My current code requires 3 lines of code to give these charts their animation. is there a way to define multiple elements in one line of code, something like this? I'm trying to clean up my code and make it easier for others to understand and the less clutter the better.