What is the etymology and meaning of the phrase "chalk it up"? For instance:
J.S. Farmer and W.E. Henley, Slang and Its Analogues (1890), says that "to chalk up, or to chalk it up" is "To credit, or take credit; to put to one's account." In the context of tavern bills, "take credit" means to accept a promise to pay such a debt. The book then offers three historical examples of this usage (with the year given first):
Slang and Its Analogues also reports that "chalking the lamppost" was mid-nineteenth-century slang in Philadelphia for bribery.
Christine Ammer, American Heritage Dictionary of Idioms (1997), says that "chalk up" has two meanings, with different dates of emergence in English:
In my view, Ammer invites misinterpretation of the common phrase "chalk it up to experience" by associating it with a success to be explained, rather than presenting it as an attempt to put a positive spin on something more or less unpleasant. I would have said that "chalk it up to experience" means something like "consider it part of the ongoing price you pay to become wiser and more experienced." I notice that FumbleFingers has made a similar point about that phrase.
Finally, Eric Partridge, Dictionary of Slang and Unconventional English (1961), reports that in the UK in the 1920s, "chalk it up!" could mean "Just look at that!" He cites J. Manchon's Le Slang (1923) as the source of this information.
It comes from literally writing up a debt with chalk. The OED defines it:
Their earliest citation is:
However, I found an antedating in The London adviser and guide - Page 27 - by John Trusler - 1586:
When did the figurative meaning come about? Christine Ammer's American Heritage Dictionary of Idioms (1997) has it from the first half of 1900s. The Routledge Dictionary of Historical Slang by Eric Partridge says:
I found an 1870 example of chalking to give credit, in The bane of a life by Thomas Wright:
I found an early example specifically of chalking it to experience in The Sun (New York [N.Y.]), 22 March 1909:
As noted, chalk it up is just another way of saying write up in chalk (that's OED's definition).
Years ago you might sometimes find a pub run by a trusting landlord who would run a slate for favoured clientele. The customer could order a drink and say "Chalk it up" or "Put it on the slate", and the landlord would write the price into a notebook for later settlement of the bill. Not that I ever saw any slates or chalk in such contexts - it was a metaphorical chalkboard.
Thus, one meaning of chalk it up is make a note of the cost, which will be paid at a later date. But I think by far the most common usage today is...
...which is normally said to someone who's put considerable effort into doing something that hasn't produced any obvious gain. By extension from this, you'll often see other "categorisations" besides experience used in the same construction, but usually that's the sense (whatever's being "chalked up" has failed to achieve its purpose, or turned out to be a disappointment for some reason).
Note that the "literal" sense of the modern usage is that your experience will (like the trusted customer in the pub), pay you back in the fullness of time (because you'll be older and wiser, so you'll do things better next time).
But not everybody grasps that. So, as Sven Yargs points out, even contributors to American Heritage Dictionary of Idioms interpret the expression as meaning ascribe, categorise, and hence extend use to contexts where it introduces an explanation (of anything, potentially even something good), rather than an amelioration/mitigation (of something which is apparently useless).
I believe it comes from the idea of writing something on a chalk board. At one time when you wanted to note why something had happened, you might note it on a chalk board. For example in many sports, scores were tallied on a chalk board, so if you wanted to denote an event like a fault, you would chalk it up.
All your examples seem to use the second form of the idiom. I suppose chalking it up here is a reference not specifically to a game, but to simply noting the cause of something on a chalk board, as a teacher might do in class.
Literally, chalk it up to means to use chalk to add to an account. It means you do not have to pay, at least not immediately, and if it is not your personal account then not ever.
Figuratively, you can speak of charging any negative outcome to the account of a metaphorical third party (such as “experience”), just as you would a debt. Again you are spared from paying or making amends.¹
So the meaning that the literal and figurative uses have in common is that there is a negative consequence which you do not have to pay for. As a figurative phrase, it is essentially a face saving gesture.
Here is the earliest use I found of the phrase in literature. (In this example, “G. H. R.” is a railroad company and the meaning is literal.)