Module:Chart: Difference between revisions

Content deleted Content added
m Protected "Module:Chart": High-risk module ([Edit=Require autoconfirmed or confirmed access] (indefinite))
add optional |y tick marks= per talk page
Line 14:
group = 'group',
xlegend = 'x legends',
yticks = 'y tick marks',
tooltip = 'tooltip',
accumulateTooltip = 'tooltip value accumulation',
Line 192 ⟶ 193:
local values, xlegends, colors, tooltips, yscales = {}, {}, {}, {} ,{}, {}, {}
local groupNames, unitsSuffix, unitsPrefix, links = {}, {}, {}, {}
local width, height, yticks, stack, delimiter = 500, 350, -1, false, args.delimiter or ':'
local chartWidth, chartHeight, defcolor, scalePerGroup, accumulateTooltip
 
Line 260 ⟶ 261:
end
elseif k == keywords.stack then stack = true
elseif k == keywords.yticks then yticks = tonumber(v) or -1
elseif k == keywords.scalePerGroup then scalePerGroup = true
elseif k == keywords.defcolor then defcolor = v
Line 359 ⟶ 361:
 
function drawYScale()
function drawSingle( gi, color, width, yticks, single )
local yscale = yscales[gi]
local _, top, ordermag = roundup( yscale * 0.999 )
local numnotches = topyticks <>= 1.50 and topyticks * 4or
or (top <= 4 1.5 and top * 24
or top < 4 and top * or top2
or top)
local valStyleStr =
single and 'position:absolute;height=20px;text-align:right;vertical-align:middle;width:%spx;top:%spx;padding:0 2px'
Line 386 ⟶ 389:
local color = colors[gi] or defcolor
table.insert( res, mw.text.tag( 'div', { style = string.format( colStyle, chartHeight, colWidth, left, color, color ) } ) )
drawSingle( gi, color, colWidth, yticks )
table.insert( res, '</div>' )
end
else
drawSingle( 1, 'black', scaleWidth, yticks, true )
end
end