Jose Napoleon Duarte, who was president of this beleaguered country until May 2 but now is out of a government job, sat at a desk in his Christian Democratic Party headquarters sketching a graph that traced the history of political violence during his two-year term.

It marched steadily upward in a ragged line of massacres, assassinations, coup attempts, and efforts to initiate reform, then ran off the edge of the paper before he finished the first year he spent in office.

"You cannot say we had one crisis," Duarte recalled. "We had a permanent crisis."

Yet Duarte seems content.

Such a record normally would be disastrous for a politician's career, and it cost Duarte's party a majority in the crucial March 28 elections for a constituent assembly. Nevertheless, he and other leading Christian Democrats are more relaxed and more optimistic about the future and their place in it than they have appeared since they joined the government in January 1980.

Although the right-wing parties that emerged with 60 percent of the vote openly despised Duarte's party, tough words from Washington and an ultimatum from the armed forces gave the Christian Democrats a role in the new government that they believe puts them in a good position for presidential elections expected in the next two years--all this guaranteed by El Salvador's military commanders.

Duarte seems almost bemused as he considers the transformation of his relations with the armed forces in the past decade.

Ten years ago the military tortured him and forced him into a seven-year exile after he won the 1972 presidential elections. Now the soldiers have assured him and his party a place in the current government at the expense of right-wing former officers such as the assembly president, Roberto D'Aubuisson.

"You have to remember that I started out as public enemy number one of the Army and to get that influence I have now it's been very, very careful work," Duarte said.

He spent two years compromising with the colonels who took power in a 1979 reformist coup and formed the government junta he calls a "joint venture between the military people and us," Duarte says. He defended them to a world accusing them of horrible human rights abuses in the fight against insurgents and argued that they gradually were establishing control over the extremes.

"We are converting the Army to democracy," said Duarte.

The military still controls the political life of El Salvador when it wants to.

"The Army is the only institution that's left organized in the country," Duarte said.

The difference is that for the moment it is guaranteeing a role for the Christian Democrats rather than ensuring their exclusion, a function one diplomat described privately as "a kind of coup for democracy."

Representatives of the Reagan administration and Congress made it clear to the military and the political parties here that for better or worse the Christian Democrats were the key to continued U.S. backing for the government. When the conservative parties balked and bitter squabbling continued for weeks, the Army called the parties together for a final consultation and flatly told them to name independent banker Alvaro Magana president of a government including near-equal representation of all three major parties: the once-official National Conciliation Party, D'Aubuisson's Nationalist Republican Alliance and the Christian Democrats.

What emerged is the current government where "everybody and nobody" has power, according to Duarte.

There is an independent president, the Christian Democrats have one of the three vice presidential slots and three of 15 Cabinet positions that are split five ways.

The problems of the Army accrue to the Army, while the economy, which has plunged toward outright disaster in the last three years, essentially becomes the responsibility of the right wing.

"We left the economic ministries to other parties," said Duarte. "We wanted the ministries where we could help people."

The Education Ministry is particularly important, Duarte said, since it accounts for about 50 percent of civilian government employment.

The Labor Ministry, meanwhile, keeps the party in contact with San Salvador's working class, where it has substantial support, and the Foreign Ministry will give a bright leader, Fidel Chavez Mena, a continuing high profile.

Meanwhile, the rancor of the first days after the election has given way to what Duarte calls a "government of coincidence" in which hatchets, if not buried, are put aside in a common effort to salvage the war-ravaged country.

Leftist critics of Duarte, including dissident members of his own party who have gone into exile, say that by compromising with the Army so often he ultimately endorsed its worst excesses, a wave of political repression in response to the growing guerrilla war that cost tens of thousands of lives while Duarte served on the junta.

Duarte does not like to talk about the numbers of dead. As he sees it, whatever they are--and some estimates exceed 30,000 since late 1979--they are fewer than they would have been had he not participated in the government.

"We set about reducing the cost: the cost of life, the cost to the economy," Duarte said.

Duarte said he feels that despite the bloodshed and near bankruptcy that marked his term, he and his party succeeded in their basic goal of averting full-scale war.