Emergence of charge order from the vortex state of a high-temperature superconductor