Firstly, your scope is too broad.
As I mentioned at your comment line, the succession of each dynasty is very complicated in China, as if there is no rule but there is a definite rule I describe I will describe under the bar.
For example, in Yuan dynasty's case, very broadly saying, the emperor of each dynasty was elected according to the decision by Kurultai. where
All Great Khans of the Mongol Empire, for example Genghis Khan and Ögedei Khan, were formally elected in a Kurultai; khans of subordinate Mongol states, such as the Golden Horde, were elected by a similar regional Kurultai.
But already around 40 years after the death of Genghis Khan, the general rule was broken, the Wiki about the Yuan dynasty says,
Genghis Khan died on 18 August 1227, by which time the Mongol Empire ruled from the Pacific Ocean to the Caspian Sea, an empire twice the size of the Roman Empire or the Muslim Caliphate at their height. Genghis named his third son, the charismatic Ögedei, as his heir.
So your "primogeniture," was already broken here. ( And further disputes continued afterwards. )
Another example is, Song dynasty ( 960-1279 ), the tenth emperor, Gaozong was,
He was the ninth son of Emperor Huizong and a younger half-brother of Emperor Qinzong. Here already primogeniture rule was already broken.
General "Rule" ( but not rule but the mandate )
There is a "general rule" of the hereditary ( or the seize to power or the "requirements" every emperor needed, whatever ), according to the Wiki,
The title of emperor was hereditary, traditionally passed on from father to son in each dynasty. There are also instances where the throne is assumed by a younger brother, should the deceased Emperor have no male offspring. By convention in most dynasties, the eldest son born to the Empress (嫡長子/嫡长子) succeeded to the throne. In some cases when the empress did not bear any children, the emperor would have a child with another of his many wives (all children of the emperor were said also to be the children of the empress, regardless of birth mother). In some dynasties the succession of the empress' eldest son was disputed, and because many emperors had large numbers of progeny, there were wars of succession between rival sons. In an attempt to resolve after-death disputes, the emperor, while still living, often designated a Crown Prince (太子). Even such a clear designation, however, was often thwarted by jealousy and distrust, whether it was the crown prince plotting against the emperor, or brothers plotting against each other. Some emperors, like the Yongzheng Emperor, after abolishing the position of Crown Prince, placed the succession papers in a sealed box, only to be opened and announced after his death.
Unlike, for example, the Japanese monarchy, Chinese political theory allowed for a change in the ruling house. This was based on the concept of the "Mandate of Heaven". The theory behind this was that the Chinese emperor acted as the "Son of Heaven" and held a mandate to rule over everyone else in the world; but only as long as he served the people well. If the quality of rule became questionable because of repeated natural disasters such as flood or famine, or for other reasons, then rebellion was justified. This important concept legitimized the dynastic cycle or the change of dynasties.
This principle made it possible even for peasants to found new dynasties, as happened with the Han and Ming dynasties, and for the establishment of conquest dynasties such as the Mongol-led Yuan dynasty and Manchu-led Qing dynasty. It was moral integrity and benevolent leadership that determined the holder of the "Mandate of Heaven".
There has been only one lawful female reigning Emperor in China, Empress Zetian, who briefly replaced the Tang dynasty with her own Zhou dynasty. Many women, however, did become de facto leaders, usually as Empress Dowager. Prominent examples include Empress Dowager Lü of the Han dynasty and Empress Liu (Zhenzong) of the Sung dynasty and Empress Dowager Cixi of the Qing dynasty.
So it looks whoever it is, if the children or no children who should succeed is the under the "Mandate of Heaven" ( including self declaration ), he has the "chance" to be the emperor.
Responding to the update from the OP
Autocorrect made a grave mistake in the title and someone kindly came along and edited it, as was necessary. But in the process a vital point of the question was lost, namely that I am interested in the rules and what happened de facto and how much of a discrepancy there is
What do you mean by "de facto"? For instance, Lie Bei, who was the founder of Shu Hang, , was according to the above Wiki,
According to the 3rd-century historical text Records of the Three Kingdoms, Liu Bei was born in Zhuo County, Zhuo Commandery, which is in present-day Zhuozhou, Baoding, Hebei. He was a descendant of Liu Zhen, a son of Liu Sheng, who was the ninth son of Emperor Jing and the first King of Zhongshan in Han dynasty. However, Pei Songzhi's 5th-century commentary, based on the Dianlue (典略), said that Liu Bei was a descendant of the Marquis of Linyi (臨邑侯). As the title "Marquis of Linyi" was held by Liu Fu (劉復; grandson of Liu Yan) and later by Liu Fu's son Liu Taotu (劉騊駼), who were also descendants of Emperor Jing, it was possible that Liu Bei descended from this line rather than Liu Zhen's line. Liu Bei's grandfather Liu Xiong (劉雄) and father Liu Hong (劉弘) both served as clerks in the local commandery office.
Virtually nothing is revealed even by the official Three Kingdom. Another says, Lie Bei was nobody but an one of bunches of thugs, only hist family name is same with that of Hang's dynasty, which is Lie, and there are many people with their family name Lie in China today.
So the "de facto rule" is, like Zhang Jue,, who was nobody but a peasant but who led the broad rebellious campaign in the late Hang dynasty, whoever had the enough power to go viral against the then dynasty, had the right to become the "founder" or the "successor" of China.
According to the wik about Zhang,
Giving himself the title of "Great Teacher" (大賢良師), Zhang Jue led the Yellow Turban Rebellion with his younger brothers Zhang Bao (張寶) and Zhang Liang (張梁) in a campaign called the "Way of Heaven" or "Way of Peace". He and his brothers gave themselves titles: Zhang Bao was the "General of Land" (地公將軍), Zhang Liang was the "General of the People" (人公將軍); and Zhang Jue was the "General of Heaven" (天公將軍).6 The Yellow Turbans claimed to be Taoists, and rebelled against the Han dynasty in response to burdensome taxes, rampant corruption, and famine and flooding, which were seen as indications that the Han emperor had lost the mandate of heaven.
So whether it is because of the famine or the corruption, the emperor himself takes the risk of losing the "Mandate Of Heaven", which late becomes the potential cause of the rebellion and the exchange of the dynasty. Simple enough, eh?