Charge radii of magnesium isotopes and transition to