Module:Chart: Difference between revisions

Content deleted Content added
Not seeing any reason why these large buffers on the text of the x-labels are needed so I'm reducing them, seems to work fine in my own testing
Fix strange white gaps and wrong-sized bars in graphs which were caused by rounding errors
Line 314:
 
local function calcHeights( gi, i, val )
local barHeight = math.max( 2, math.floor( val / yscales[gi] * chartHeight + 0.5 ) ) -- add half to make it "round" instead of "trunc", min height to 2 to avoid negative bar sizes
local top, base = chartHeight - barHeight, 0
if stack then
localfor rawbasej = 01, gi - 1 do
if tonumber(values[j][i]) > 0 then
for j = 1, gi - 1 do rawbase = rawbase + values[j][i] end -- sum the "i" value of all the groups below our group, gi.
base = base + math.floormax( chartHeight2, *math.floor( rawbasevalues[j][i] / yscales[gi] * chartHeight + 0.5 ) ) -- normally,sum andthe especially"i" ifvalue it'sof "stack"all the groups below our group, allgi, and keep the yscalessame mustcalculation befor each bar equal.
end
end
end
return barHeight, top - base