how to rotate an object (a line) diagonally x,y
Euler rotations in multiple axes do not commute (their order matters) , and while you can set the start and end key points of a rotation with a combination of Euler rotations in various axes, in no way does that imply that interpolating those separate rotations will yield overall interpolation along a Great Circle when they are recombined.

Typically, for animation, you would parent the line-object to an Empty previously rotated in Z by 45 degrees, so you can rotate the Empty in only one of its axes, X or Y, to achieve the diagonal rotation of the line-object. 

The rotation in a single Euler axis will interpolate along a Great circle, and behave as expected.

However, Blender also provides other modes of rotation, which can be switched in the Item > Transform  panel of the Properties region in the 3D view. Quaternions will interpolate along Great Circle between keyed points, but are perhaps trickier to set in the viewport.

Analogous to parenting to an Empty, without actually parenting, might be Axis-Angle rotation. You define an axis, and key the rotation about it.



The rotations will only appear when their mode is active. You can key the switch between rotation modes, so as to have one take over from another in the course of an animation.

But it most circumstances, that might make things a bit complicated on your dope-sheet.