Firstly, your scope is too broad.
As I mentioned in the comments above, the actual succession within each dynasty was very complicated in China, to the point that it might seem as if there were no rule even though there was a definite rule that I describe I will describe under the bar.
For example, in Yuan dynasty's case, very broadly saying, each emperor was elected according to a decision of the Kurultai:
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 Genghis Khan himself broke this general rule
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 both the normal Mongol system and your primogeniture were already broken here (although this was before the formalization of the Yuan in China) and further disputes continued afterwards.
Another example was during the Song dynasty ( 960-1279 ), whose tenth emperor Gaozong
was the ninth son of Emperor Huizong and a younger half-brother of Emperor Qinzong.
Here primogeniture was broken again.
General "Rule" (well, Mandate )
There was a "general rule" of inheritance ( or seizure of power ) or the "requirements" every emperor needed, whatever. According to Wikipedia,
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's 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 Wu 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 Song dynasty and Empress Dowager Cixi of the Qing dynasty.
So it looks as if whoever, whether children or not, might succeed is the under the "Mandate of Heaven" ( including self declaration ) and 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, Liu Bei, who was the founder of Shu Han, was, according to 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 history of the Three Kingdoms. Another says, Liu Bei was nobody but one of bunches of thugs, and it was a coincidence that his family name was the same as that of the Han's dynasty.
So the "de facto rule" is, like Zhang Jue, who was nobody but a peasant but who led a broad rebellious campaign in the late Han 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 Wiki 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 later becomes the potential cause of the rebellion and the change of the dynasty. Simple enough, eh?