3675
правок
Mansur700 (обсуждение | вклад) (Керла агӀо: «--<source lang=lua> --keywords are used for languages: they are the names of the actual parameters of the template local keywords = { barChart = 'bar c...») |
Mansur700 (обсуждение | вклад) Нет описания правки |
||
Строка 21: | Строка 21: | ||
unitsSuffix = 'units suffix', | unitsSuffix = 'units suffix', | ||
groupNames = 'group names', | groupNames = 'group names', | ||
hideGroupLegends = 'hide group legends', | |||
slices = 'slices', | slices = 'slices', | ||
slice = 'slice', | slice = 'slice', | ||
Строка 55: | Строка 56: | ||
'xanthin','#FFFF80', | 'xanthin','#FFFF80', | ||
'zinnia','#FF5005'} | 'zinnia','#FF5005'} | ||
local hideGroupLegends; | |||
local function nulOrWhitespace( s ) | local function nulOrWhitespace( s ) | ||
Строка 61: | Строка 64: | ||
local function createGroupList( tab, legends, cols ) | local function createGroupList( tab, legends, cols ) | ||
if #legends > 1 then | if #legends > 1 then | ||
table.insert( tab, mw.text.tag( 'div' ) ) | table.insert( tab, mw.text.tag( 'div' ) ) | ||
local list = {} | local list = {} | ||
Строка 103: | Строка 106: | ||
radius = getArg( 'radius', 150 ) | radius = getArg( 'radius', 150 ) | ||
hideGroupLegends = not nulOrWhitespace( args[keywords.hideGroupLegends] ) | |||
local slicesStr = getArg( 'slices' ) | local slicesStr = getArg( 'slices' ) | ||
local prefix = getArg( 'unitsPrefix', '', '_', ' ' ) | local prefix = getArg( 'unitsPrefix', '', '_', ' ' ) | ||
Строка 170: | Строка 174: | ||
style = string.format( '%s;border-width:%spx %spx %spx %spx;border-%s-color:%s', style, w1, w2, w3, w4, border, color ) | style = string.format( '%s;border-width:%spx %spx %spx %spx;border-%s-color:%s', style, w1, w2, w3, w4, border, color ) | ||
end | end | ||
addRes( mw.text.tag( 'div', { | addRes( mw.text.tag( 'div', { style = 'border: solid transparent;' .. style }, '' ) ) | ||
end | end | ||
Строка 203: | Строка 207: | ||
addRes( '</div>' ) -- close "position:relative" div that contains slices and imagemap. | addRes( '</div>' ) -- close "position:relative" div that contains slices and imagemap. | ||
addRes( '</div>' ) -- close "position:relative" div that contains slices and imagemap. | addRes( '</div>' ) -- close "position:relative" div that contains slices and imagemap. | ||
createGroupList( res, legends, colors ) -- legends | if not hideGroupLegends then | ||
createGroupList( res, legends, colors ) -- legends | |||
end | |||
addRes( '</div>' ) -- close containing div | addRes( '</div>' ) -- close containing div | ||
return frame:preprocess( table.concat( res, '\n' ) ) | return frame:preprocess( table.concat( res, '\n' ) ) | ||
Строка 238: | Строка 244: | ||
chartHeight = height - | chartHeight = height - 50 | ||
numGroups = #values | numGroups = #values | ||
numValues = #values[1] | numValues = #values[1] | ||
Строка 284: | Строка 290: | ||
elseif k == keywords.scalePerGroup then scalePerGroup = true | elseif k == keywords.scalePerGroup then scalePerGroup = true | ||
elseif k == keywords.defcolor then defcolor = v | elseif k == keywords.defcolor then defcolor = v | ||
elseif k == keywords.hideGroupLegends then hideGroupLegends = not nulOrWhitespace( v ) | |||
else | else | ||
for keyword, tab in pairs( { | for keyword, tab in pairs( { | ||
Строка 426: | Строка 433: | ||
function drawChart() | function drawChart() | ||
table.insert( res, mw.text.tag( 'div', { style = string.format( 'max-width:%spx;', width ) } ) ) | table.insert( res, mw.text.tag( 'div', { style = string.format( '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;padding-top:10px;min-height:%spx;min-width:%spx;max-width:%spx;", height, width, width ) } ) ) | ||
table.insert( res, mw.text.tag( 'div', { style = string.format("float:right;position:relative;min-height:%spx;min-width:%spx;max-width:%spx;border-left:1px black solid;border-bottom:1px black solid;", chartHeight, chartWidth, chartWidth ) } ) ) | table.insert( res, mw.text.tag( 'div', { style = string.format("float:right;position:relative;min-height:%spx;min-width:%spx;max-width:%spx;border-left:1px black solid;border-bottom:1px black solid;", chartHeight, chartWidth, chartWidth ) } ) ) | ||
Строка 442: | Строка 449: | ||
table.insert( res, '</div>' ) | table.insert( res, '</div>' ) | ||
table.insert( res, '</div>' ) | table.insert( res, '</div>' ) | ||
createGroupList( res, groupNames, colors ) | if not hideGroupLegends then | ||
createGroupList( res, groupNames, colors ) | |||
end | |||
table.insert( res, '</div>' ) | table.insert( res, '</div>' ) | ||
end | end |