I need to export statistics from a database into PDF files, with a program. The database contains several tests and they need to be displayed as barcharts. Here is an example:

The problem is clear: when xlabels are long, then the chart goes out of the page. However, I cannot tell in advance, how long the labels will be. Sometimes they will be just simple words. Sometimes whome sentences.
The question is: how to calculate the size needed for the labels, and auto-scale the rest of the bar chart to fit on the page horizontally?
\subsection{Irányítási kompetencia}
%
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=,
xmax=61.1111111111,
width=12cm,
height={ 1cm + ( 4.0 * 1cm ) },
symbolic y coords={{Tervezés},{Szervezés},{Döntőképesség},{Ellenőrzés}},
%ylabel={Irányítási kompetencia}, % This is not really needed, need to save space!
xlabel={Pontérték \%},
ytick=data, % Without this, y labels will be written for every "tick". And not for every bar.
nodes near coords,
nodes near coords align = {horizontal}
]
\addplot [draw=black, fill=cyan!40!black] coordinates {
(37.5,{Tervezés})
(61.1111111111,{Szervezés})
(31.25,{Döntőképesség})
(31.25,{Ellenőrzés})
};
\end{axis}
\end{tikzpicture}
%
%
\subsection{Vezetési kompetencia}
%
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=,
xmax=60.0,
width=12cm,
height={ 1cm + ( 11.0 * 1cm ) },
symbolic y coords={{Megbízhatóság},{Stressztűrés},{Figyelemkoncentráció},{Szabálykövetés},{Önkontroll},{Holisztikus gondolkodás},{Analitikus gondolkodás},{Szervezőkészség},{Alkalmazkodó képesség},{Rendszerező, struktúráló képesség},{Vezetői szerep}},
%ylabel={Vezetési kompetencia}, % This is not really needed, need to save space!
xlabel={Pontérték \%},
ytick=data, % Without this, y labels will be written for every "tick". And not for every bar.
nodes near coords,
nodes near coords align = {horizontal}
]
\addplot [draw=black, fill=cyan!40!black] coordinates {
(55.0,{Megbízhatóság})
(60.0,{Stressztűrés})
(30.0,{Figyelemkoncentráció})
(33.3333333333,{Szabálykövetés})
(35.0,{Önkontroll})
(35.0,{Holisztikus gondolkodás})
(38.8888888889,{Analitikus gondolkodás})
(59.0909090909,{Szervezőkészség})
(54.1666666667,{Alkalmazkodó képesség})
(40.9090909091,{Rendszerező, struktúráló képesség})
(36.3636363636,{Vezetői szerep})
};
\end{axis}
\end{tikzpicture}

UPDATE: I have also tried to put the whole tizkpicture into \resizebox{\linewidth}{!}{...} but it also scales vertically, and that is bad, because the number of bars in the chart varies. So by "scaling" I mean: specify the width of the chart. What I don't mean is: "scale the chart that was already rendered".

tikzscale. See http://tex.stackexchange.com/questions/36297/pgfplots-how-can-i-scale-to-text-width – Jake Apr 05 '13 at 06:31