Content deleted Content added
fixed wrapping problem |
better xtick alignment |
||
Line 35:
local defColors = require "Module:Plotter/DefaultColors"
local hideGroupLegends
local function nulOrWhitespace( s )
Line 192 ⟶ 193:
function barChart( frame )
local args = frame.args -- can be changed to frame:getParent().args
local values, xlegends, colors, tooltips, yscales, yscalesneg = {}, {}, {}, {} ,{}, {}, {}, {}
Line 202 ⟶ 203:
local numGroups, numValues
local scaleWidth
▲ local optint
end▼
▲ end
▲ table.insert( res, frame:extensionTag{ name = 'templatestyles', args = { src = 'TemplateStyles sandbox/Ita140188/styles.css'} })
▲ function createGroupList( tab, legends, cols )
▲ local spanStyle = "padding:0 1em;background-color:%s;border:1px solid %s;margin-right:1em;-webkit-print-color-adjust:exact;"
table.insert(
▲ end
▲ local span = mw.text.tag( 'span', { style = string.format( spanStyle, cols[gi], cols[gi] ) }, ' ' ) .. ' '.. legends[gi]
▲ table.insert( list, mw.text.tag( 'li', {}, span ) )
▲ table.insert( tab,
▲ mw.text.tag( 'ul',
▲ {style="width:100%;list-style:none;-webkit-column-width:12em;-moz-column-width:12em;column-width:12em;"},
▲ )
▲ table.insert( tab, '</div>' )
▲ end
▲ end
Line 335 ⟶ 328:
local sumneg = math.min( unpack( sums ) )
for i = 1, #values do
end
else
for i, group in ipairs( values ) do
end
end
Line 347 ⟶ 340:
for i, scale in ipairs( yscalesneg ) do yscalesneg[i] = roundup( scale * 0.9999 ) end
if not scalePerGroup then for i = 1, #values do
end end
end
Line 361 ⟶ 354:
function calcHeights( gi, i, val )
else
if stack then
local rawbase = 0
Line 392 ⟶ 385:
function groupBounds( i )
local setWidth =
-- local setOffset = ( i - 1 ) * setWidth
local setOffset = ( i - 1 ) * setWidth
Line 401 ⟶ 394:
local setOffset, setWidth = groupBounds( i )
if stack or numGroups == 1 then
local barWidth = math.min( 38,
return setOffset + (setWidth - barWidth) / 2, barWidth
end
setWidth = 0.85 * setWidth
local barWidth =
local left = setOffset +
return left, barWidth
end
Line 430 ⟶ 423:
function drawYScale()
function drawSingle( gi, color, single )
local yscale = yscales[gi]
Line 450 ⟶ 443:
local divNotch = mw.text.tag( 'div', { style = string.format( valStyleStrNotch, y, color ) }, ' ' )
table.insert( res, divCntnr )
else
table.insert( res, '</div>' )
table.insert( res, '<div style="clear:right;display:block"></div>' )
Line 495 ⟶ 488:
for i = 1, numValues do
if not nulOrWhitespace( xlegends[i] ) then
table.insert( res, mw.text.tag( 'div', { style = string.format( legendDivStyleFormat, setWidth, offsetleft ) }, xlegends[i] or '' ) )
offsetleft=0;
else
end
Line 508 ⟶ 501:
end
local setOffset, setWidth
local tickDivStyleFormat = "display:block;float:left;position:relative;height:5px;vertical-align:top;border-left:1px solid black;width:%spx;text-align:center;margin:0px 0px 0px %spx;"
Line 515 ⟶ 508:
for i = 1, numValues do
if not nulOrWhitespace( xlegends[i] ) then
offsetleft=0;
else
end
end
Line 527 ⟶ 520:
table.insert( res, mw.text.tag( 'div', { style = string.format("position:relative;padding:1em 0em 1em 0em;") } ) ) -- container div
table.insert( res, mw.text.tag( 'div', { style = string.format("position:relative;white-space:nowrap;" ) } ) ) -- container div
drawYScale()
table.insert( res, '</div><div style="position:relative;display:inline-block">' )
|