Module:Chart and Module:Chart/sandbox: Difference between pages
(Difference between pages)
imported>Ergzay Hopefully fix problems caused by wikipedia-wide changes that added overflow:auto settings to all pages that caused chart clipping and chart scrollbars |
imported>Pppery No edit summary |
||
Line 48: | Line 48: | ||
table.insert( tab, | table.insert( tab, | ||
mw.text.tag( 'ul', | mw.text.tag( 'ul', | ||
{style="list-style:none;column-width:12em;"}, | {style="width:100%;list-style:none;column-width:12em;"}, | ||
table.concat( list, '\n' ) | table.concat( list, '\n' ) | ||
) | ) | ||
Line 112: | Line 112: | ||
local function createImageMap() | local function createImageMap() | ||
addRes( '{{#tag:imagemap|', ' | addRes( '{{#tag:imagemap|', 'Image:Circle frame.svg{{!}}' .. ( radius * 2 ) .. 'px' ) | ||
addRes( unpack( imslices ) ) | addRes( unpack( imslices ) ) | ||
addRes( 'desc none', '}}' ) | addRes( 'desc none', '}}' ) | ||
Line 314: | Line 314: | ||
local function calcHeights( gi, i, val ) | local function calcHeights( gi, i, val ) | ||
local barHeight = | local barHeight = math.floor( val / yscales[gi] * chartHeight + 0.5 ) -- add half to make it "round" instead of "trunc" | ||
local top, base = chartHeight - barHeight, 0 | local top, base = chartHeight - barHeight, 0 | ||
if stack then | if stack then | ||
for j = 1, gi - 1 do | local rawbase = 0 | ||
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 = math.floor( chartHeight * rawbase / yscales[gi] ) -- normally, and especially if it's "stack", all the yscales must be equal. | |||
end | end | ||
if barHeight < 2 then | |||
barHeight = 2 -- Otherwise the template would try to create a bar with a negative height | |||
end | |||
return barHeight, top - base | return barHeight, top - base | ||
end | end | ||
Line 405: | Line 406: | ||
setOffset, setWidth = groupBounds( i ) | setOffset, setWidth = groupBounds( i ) | ||
-- setWidth = 0.85 * setWidth | -- setWidth = 0.85 * setWidth | ||
table.insert( res, mw.text.tag( 'div', { style = string.format( legendDivStyleFormat, setOffset + | table.insert( res, mw.text.tag( 'div', { style = string.format( legendDivStyleFormat, setOffset + 5, setWidth - 10, setWidth - 10 ) }, xlegends[i] or '' ) ) | ||
table.insert( res, mw.text.tag( 'div', { style = string.format( tickDivstyleFormat, setOffset + setWidth / 2 ) }, '' ) ) | table.insert( res, mw.text.tag( 'div', { style = string.format( tickDivstyleFormat, setOffset + setWidth / 2 ) }, '' ) ) | ||
end | end | ||
Line 412: | Line 413: | ||
local function drawChart() | local function drawChart() | ||
table.insert( res, mw.text.tag( 'div', { class = 'chart noresize', style = string.format( ' | table.insert( res, mw.text.tag( 'div', { class = 'chart noresize', style = string.format( 'margin-top:1em;max-width:%spx;', width ) } ) ) | ||
table.insert( res, mw.text.tag( 'div', { style = string.format("position:relative;min-height:%spx;min-width:%spx;max-width:%spx;", height, width, width ) } ) ) | table.insert( res, mw.text.tag( 'div', { style = string.format("position:relative;min-height:%spx;min-width:%spx;max-width:%spx;", height, width, width ) } ) ) | ||