Since work done is scalar product of force and displacement, it can be calculated as area under the force-displacement plot.
So, up to x1 displacement, work done, W1 = (30×4)2=60 J
But after, x1, the direction of force is reversed.
So, work done, W2 = ((45−30)×(−2))2=−15 J
Hence, total work done = W1 +W2 =60+(−15)=45 J