Magnetic phase diagram of the semi-Heusler alloys from first principles