by 1803, "low spirits, the blues, the dumps," colloquial, probably from dulled, past participle of dull (v.) in the sense of "make (someone) slow-witted," with ending perhaps patterned on tantrum.
DEAR girl, from noise and London city,
I'm here among the blithe and witty;
Where young and old, from ev'ry clime,
Like adepts, learn to murder Time!
If you've the doldrums or ennui,
Forsake the town and come to me.
[from "A Marine Picture" in The Spirit of the Public Journals for 1802, London, 1803]
Transferred sense, in reference to sailing ships, "in a becalmed condition, unable to make headway" is by 1824. This was extended in nautical use to parts of the sea near the equator that abound in calms, squalls, and light, baffling winds (1848) and the weather characteristic of these parts. "Apparently due to a misunderstanding of the phrase 'in the doldrums', the state being taken as a locality" [OED].