Here is an example of doing this in pure XQuery, this will work in eXist, or any other XQuery 1.0 processor:
declare variable $local:max-graph-height := 400; (: pixels :)
declare variable $local:graph-bar-width := 120; (: pixels :)
declare variable $local:graph-bar-spacing := 10; (: pixels :)
declare variable $local:graph-text-below := 20; (: pixels :)
let $awkeny := doc("/db/Dane/akweny.xml")//akwen[xs:int(powierzchnia) gt 100]
let $max-powierzchnia := max($awkeny/powierzchnia)
return
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
id="graph"
height="{ $local:max-graph-height + ($local:graph-text-below * 2) }"
width="{ ($local:graph-bar-width + $local:graph-bar-spacing) * count($awkeny) }">
<linearGradient x1="0%" x2="0%" y1="10%" y2="100%" id="gradient">
<stop style="stop-color:#0000FF" offset="0"></stop>
<stop style="stop-color:#FFFFFF" offset="1"></stop>
</linearGradient>
{
for $awken at $i in $awkeny
let $height := (xs:float($awken/*:powierzchnia) div $max-powierzchnia) * $local:max-graph-height
let $x := ($i - 1) * ($local:graph-bar-with + $local:graph-bar-spacing)
let $y := $local:max-graph-height - $height
return
(
<rect width="{$local:graph-bar-with}"
height="{$height}" x="{$x}" y="{$y}"
fill="url(#gradient)"></rect>,
<text x="{$x}"
y="{$local:max-graph-height + $local:graph-text-below}"
fill="red">{$awken/*:nazwa/text()}</text>
)
}
</svg>
The above XQuery when run on your awkeny.xml produces a bar-chart in SVG that looks like the following:
Now I think you just need to work that into your XQuery in eXist as you appear from your example to be taking parameters from the incoming HTTP Request, however I can see from your question that you already know how to do that. So you should now be well on your way...