Magnetic anisotropy of two-dimensional nanostructures: Transition-metal triangular stripes