Novak Djokovic has progressed to the Rome Masters final despite losing his temper in his victory over Milos Raonic.