<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FIta140188%2Fchartsvg</id>
	<title>Module:Sandbox/Ita140188/chartsvg - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FIta140188%2Fchartsvg"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Ita140188/chartsvg&amp;action=history"/>
	<updated>2026-05-10T04:48:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Ita140188/chartsvg&amp;diff=145563&amp;oldid=prev</id>
		<title>imported&gt;Ita140188 at 05:08, 31 July 2018</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Ita140188/chartsvg&amp;diff=145563&amp;oldid=prev"/>
		<updated>2018-07-31T05:08:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&amp;lt;source lang=lua&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
    keywords are used for languages: they are the names of the actual&lt;br /&gt;
    parameters of the template&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local keywords = {&lt;br /&gt;
    barChart = &amp;#039;bar chart&amp;#039;,&lt;br /&gt;
    width = &amp;#039;width&amp;#039;,&lt;br /&gt;
    height = &amp;#039;height&amp;#039;,&lt;br /&gt;
    stack = &amp;#039;stack&amp;#039;,&lt;br /&gt;
    colors = &amp;#039;colors&amp;#039;,&lt;br /&gt;
    group = &amp;#039;group&amp;#039;,&lt;br /&gt;
    xlegend = &amp;#039;x legends&amp;#039;,&lt;br /&gt;
    tooltip = &amp;#039;tooltip&amp;#039;,&lt;br /&gt;
    accumulateTooltip = &amp;#039;tooltip value accumulation&amp;#039;,&lt;br /&gt;
    links = &amp;#039;links&amp;#039;,&lt;br /&gt;
    defcolor = &amp;#039;default color&amp;#039;,&lt;br /&gt;
    scalePerGroup = &amp;#039;scale per group&amp;#039;,&lt;br /&gt;
    unitsPrefix = &amp;#039;units prefix&amp;#039;,&lt;br /&gt;
    unitsSuffix = &amp;#039;units suffix&amp;#039;,&lt;br /&gt;
    groupNames = &amp;#039;group names&amp;#039;,&lt;br /&gt;
    hideGroupLegends = &amp;#039;hide group legends&amp;#039;,&lt;br /&gt;
    slices = &amp;#039;slices&amp;#039;,&lt;br /&gt;
    slice = &amp;#039;slice&amp;#039;,&lt;br /&gt;
    radius = &amp;#039;radius&amp;#039;,&lt;br /&gt;
    percent = &amp;#039;percent&amp;#039;,&lt;br /&gt;
&lt;br /&gt;
} -- here is what you want to translate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function barChart( frame )&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
    local res = {}&lt;br /&gt;
    local args = frame.args -- can be changed to frame:getParent().args&lt;br /&gt;
    local values, xlegends, colors, tooltips, yscales = {}, {}, {}, {} ,{}, {}, {}&lt;br /&gt;
    local groupNames, unitsSuffix, unitsPrefix, links = {}, {}, {}, {}&lt;br /&gt;
    local width, height, stack, delimiter = 500, 350, false, args.delimiter or &amp;#039;:&amp;#039;&lt;br /&gt;
    local chartWidth, chartHeight, defcolor, scalePerGroup, accumulateTooltip&lt;br /&gt;
&lt;br /&gt;
    local numGroups, numValues&lt;br /&gt;
    local scaleWidth&lt;br /&gt;
&lt;br /&gt;
	local defColors = require &amp;quot;Module:Plotter/DefaultColors&amp;quot;&lt;br /&gt;
	local hideGroupLegends&lt;br /&gt;
	&lt;br /&gt;
	local function nulOrWhitespace( s )&lt;br /&gt;
	    return not s or mw.text.trim( s ) == &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert( res, frame:extensionTag{ name = &amp;#039;templatestyles&amp;#039;, args = { src = &amp;#039;TemplateStyles sandbox/Ita140188/styles.css&amp;#039;} })&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	function createGroupList( tab, legends, cols )&lt;br /&gt;
	    if #legends &amp;gt; 1 and not hideGroupLegends then&lt;br /&gt;
	        table.insert( tab, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( &amp;quot;width:%spx;&amp;quot;, chartWidth ) } ) )&lt;br /&gt;
	        local list = {}&lt;br /&gt;
	        local spanStyle = &amp;quot;padding:0 1em;background-color:%s;border:1px solid %s;margin-right:1em;-webkit-print-color-adjust:exact;&amp;quot;&lt;br /&gt;
	        for gi = 1, #legends do&lt;br /&gt;
	            local span = mw.text.tag( &amp;#039;span&amp;#039;, { style = string.format( spanStyle, cols[gi], cols[gi] ) }, &amp;#039;&amp;amp;nbsp;&amp;#039; ) .. &amp;#039; &amp;#039;..  legends[gi]&lt;br /&gt;
	            table.insert( list, mw.text.tag( &amp;#039;li&amp;#039;, {}, span ) )&lt;br /&gt;
	        end&lt;br /&gt;
	        table.insert( tab,&lt;br /&gt;
	            mw.text.tag( &amp;#039;ul&amp;#039;,&lt;br /&gt;
	                {style=&amp;quot;width:100%;list-style:none;-webkit-column-width:12em;-moz-column-width:12em;column-width:12em;&amp;quot;},&lt;br /&gt;
	                table.concat( list, &amp;#039;\n&amp;#039; )&lt;br /&gt;
	            )&lt;br /&gt;
	        )&lt;br /&gt;
	        table.insert( tab, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
	    end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    function validate()&lt;br /&gt;
        function asGroups( name, tab, toDuplicate, emptyOK )&lt;br /&gt;
            if #tab == 0 and not emptyOK then&lt;br /&gt;
                error( &amp;quot;must supply values for &amp;quot; .. keywords[name] )&lt;br /&gt;
            end&lt;br /&gt;
            if #tab == 1 and toDuplicate then&lt;br /&gt;
                for i = 2, numGroups do tab[i] = tab[1] end&lt;br /&gt;
            end&lt;br /&gt;
            if #tab &amp;gt; 0 and #tab ~= numGroups then&lt;br /&gt;
                error ( keywords[name] .. &amp;#039; must contain the same number of items as the number of groups, but it contains &amp;#039; .. #tab .. &amp;#039; items and there are &amp;#039; .. numGroups .. &amp;#039; groups&amp;#039;)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- do all sorts of validation here, so we can assume all params are good from now on.&lt;br /&gt;
        -- among other things, replace numerical values with mw.language:parseFormattedNumber() result&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        chartHeight = height - 80&lt;br /&gt;
        numGroups = #values&lt;br /&gt;
        numValues = #values[1]&lt;br /&gt;
        defcolor = defcolor or &amp;#039;blue&amp;#039;&lt;br /&gt;
        colors[1] = colors[1] or defcolor&lt;br /&gt;
        scaleWidth = scalePerGroup and 80 * numGroups or 30&lt;br /&gt;
        chartWidth = width -scaleWidth&lt;br /&gt;
        asGroups( &amp;#039;unitsPrefix&amp;#039;, unitsPrefix, true, true )&lt;br /&gt;
        asGroups( &amp;#039;unitsSuffix&amp;#039;, unitsSuffix, true, true )&lt;br /&gt;
        asGroups( &amp;#039;colors&amp;#039;, colors, true, true )&lt;br /&gt;
        asGroups( &amp;#039;groupNames&amp;#039;, groupNames, false, false )&lt;br /&gt;
        if stack and scalePerGroup then&lt;br /&gt;
            error( string.format( &amp;#039;Illegal settings: %s and %s are incompatible.&amp;#039;, keyword.stack, keyword.scalePerGroup ) )&lt;br /&gt;
        end&lt;br /&gt;
        for gi = 2, numGroups do&lt;br /&gt;
            if #values[gi] ~= numValues then error( keywords.group .. &amp;quot; &amp;quot; .. gi .. &amp;quot; does not have same number of values as &amp;quot; .. keywords.group .. &amp;quot; 1&amp;quot; ) end&lt;br /&gt;
        end&lt;br /&gt;
        if #xlegends ~= numValues then error( &amp;#039;Illegal number of &amp;#039; .. keywords.xlegend .. &amp;#039;. Should be exactly &amp;#039; .. numValues ) end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function extractParams()&lt;br /&gt;
        function testone( keyword, key, val, tab )&lt;br /&gt;
            i = keyword == key and 0 or key:match( keyword .. &amp;quot;%s+(%d+)&amp;quot; )&lt;br /&gt;
            if not i then return end&lt;br /&gt;
            i = tonumber( i ) or error(&amp;quot;Expect numerical index for key &amp;quot; .. keyword .. &amp;quot; instead of &amp;#039;&amp;quot; .. key .. &amp;quot;&amp;#039;&amp;quot;)&lt;br /&gt;
            if i &amp;gt; 0 then tab[i] = {} end&lt;br /&gt;
            for s in mw.text.gsplit( val, &amp;#039;%s*&amp;#039; .. delimiter .. &amp;#039;%s*&amp;#039; ) do&lt;br /&gt;
                table.insert( i == 0 and tab or tab[i], s )&lt;br /&gt;
            end&lt;br /&gt;
            return true&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        for k, v in pairs( args ) do&lt;br /&gt;
            if k == keywords.width then&lt;br /&gt;
                width = tonumber( v )&lt;br /&gt;
                if not width or width &amp;lt; 200 then&lt;br /&gt;
                    error( &amp;#039;Illegal width value (must be a number, and at least 200): &amp;#039; .. v )&lt;br /&gt;
                end&lt;br /&gt;
            elseif k == keywords.height then&lt;br /&gt;
                height = tonumber( v )&lt;br /&gt;
                if not height or height &amp;lt; 200 then&lt;br /&gt;
                    error( &amp;#039;Illegal height value (must be a number, and at least 200): &amp;#039; .. v )&lt;br /&gt;
                end&lt;br /&gt;
            elseif k == keywords.stack then stack = true&lt;br /&gt;
            elseif k == keywords.scalePerGroup then scalePerGroup = true&lt;br /&gt;
            elseif k == keywords.defcolor then defcolor = v&lt;br /&gt;
            elseif k == keywords.accumulateTooltip then accumulateTooltip = not nulOrWhitespace( v )&lt;br /&gt;
            elseif k == keywords.hideGroupLegends then hideGroupLegends = not nulOrWhitespace( v )&lt;br /&gt;
            else&lt;br /&gt;
                for keyword, tab in pairs( {&lt;br /&gt;
                    group = values,&lt;br /&gt;
                    xlegend = xlegends,&lt;br /&gt;
                    colors = colors,&lt;br /&gt;
                    tooltip = tooltips,&lt;br /&gt;
                    unitsPrefix = unitsPrefix,&lt;br /&gt;
                    unitsSuffix = unitsSuffix,&lt;br /&gt;
                    groupNames = groupNames,&lt;br /&gt;
                    links = links,&lt;br /&gt;
                    } ) do&lt;br /&gt;
                        if testone( keywords[keyword], k, v, tab )&lt;br /&gt;
                            then break&lt;br /&gt;
                        end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function roundup( x ) -- returns the next round number: eg., for 30 to 39.999 will return 40, for 3000 to 3999.99 wil return 4000. for 10 - 14.999 will return 15.&lt;br /&gt;
        local ordermag = 10 ^ math.floor( math.log10( x ) )&lt;br /&gt;
        local normalized = x /  ordermag&lt;br /&gt;
        local top = normalized &amp;gt;= 1.5 and ( math.floor( normalized + 1 ) ) or 1.5&lt;br /&gt;
        return ordermag * top, top, ordermag&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function calcHeightLimits() -- if limits were passed by user, use them, otherwise calculate. for &amp;quot;stack&amp;quot; there&amp;#039;s only one limet.&lt;br /&gt;
        if stack then&lt;br /&gt;
            local sums = {}&lt;br /&gt;
            for _, group in pairs( values ) do&lt;br /&gt;
                for i, val in ipairs( group ) do sums[i] = ( sums[i] or 0 ) + val end&lt;br /&gt;
            end&lt;br /&gt;
            local sum = math.max( unpack( sums ) )&lt;br /&gt;
            for i = 1, #values do yscales[i] = sum end&lt;br /&gt;
        else&lt;br /&gt;
            for i, group in ipairs( values ) do yscales[i] = math.max( unpack( group ) ) end&lt;br /&gt;
        end&lt;br /&gt;
        for i, scale in ipairs( yscales ) do yscales[i] = roundup( scale * 0.9999 ) end&lt;br /&gt;
        if not scalePerGroup then for i = 1, #values do yscales[i] = math.max( unpack( yscales ) ) end end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function tooltip( gi, i, val )&lt;br /&gt;
        if tooltips and tooltips[gi] and not nulOrWhitespace( tooltips[gi][i] ) then return tooltips[gi][i], true end&lt;br /&gt;
        local groupName = not nulOrWhitespace( groupNames[gi] ) and groupNames[gi] .. &amp;#039;: &amp;#039; or &amp;#039;&amp;#039;&lt;br /&gt;
        local prefix = unitsPrefix[gi] or unitsPrefix[1] or &amp;#039;&amp;#039;&lt;br /&gt;
        local suffix = unitsSuffix[gi] or unitsSuffix[1] or &amp;#039;&amp;#039;&lt;br /&gt;
        return mw.ustring.gsub(groupName .. prefix .. mw.getContentLanguage():formatNum( tonumber( val ) or 0 ) .. suffix, &amp;#039;_&amp;#039;, &amp;#039; &amp;#039;), false&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function calcHeights( gi, i, val )&lt;br /&gt;
        local barHeight = math.floor( val / yscales[gi] * chartHeight + 0.5 ) -- add half to make it &amp;quot;round&amp;quot; instead of &amp;quot;trunc&amp;quot;&lt;br /&gt;
        local top, base = chartHeight - barHeight, 0&lt;br /&gt;
        if stack then&lt;br /&gt;
            local rawbase = 0&lt;br /&gt;
            for j = 1, gi - 1 do rawbase = rawbase + values[j][i] end -- sum the &amp;quot;i&amp;quot; value of all the groups below our group, gi.&lt;br /&gt;
            base = math.floor( chartHeight * rawbase / yscales[gi] ) -- normally, and especially if it&amp;#039;s &amp;quot;stack&amp;quot;, all the yscales must be equal.&lt;br /&gt;
        end&lt;br /&gt;
        return barHeight, top - base&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function groupBounds( i )&lt;br /&gt;
        local setWidth = math.floor( chartWidth / numValues )&lt;br /&gt;
        -- local setOffset = ( i - 1 ) * setWidth&lt;br /&gt;
        local setOffset = ( i - 1 ) * setWidth&lt;br /&gt;
        return setOffset, setWidth&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function calcx( gi, i )&lt;br /&gt;
        local setOffset, setWidth = groupBounds( i )&lt;br /&gt;
        if stack or numGroups == 1 then&lt;br /&gt;
            local barWidth = math.min( 38, math.floor( 0.8 * setWidth ) )&lt;br /&gt;
            return setOffset + (setWidth - barWidth) / 2, barWidth&lt;br /&gt;
        end&lt;br /&gt;
        setWidth = 0.85 * setWidth&lt;br /&gt;
        local barWidth = math.floor( 0.75 * setWidth / numGroups )&lt;br /&gt;
        local left = setOffset + math.floor( ( gi - 1 ) / numGroups * setWidth )&lt;br /&gt;
        return left, barWidth&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    function drawbar( gi, i, val, ttval )&lt;br /&gt;
        if val == &amp;#039;0&amp;#039; then return end -- do not show single line (borders....) if value is 0, or rather, &amp;#039;0&amp;#039;. see talkpage&lt;br /&gt;
&lt;br /&gt;
        local color, tooltip, custom = colors[gi] or defcolor or &amp;#039;blue&amp;#039;, tooltip( gi, i, ttval or val )&lt;br /&gt;
        local left, barWidth = calcx( gi, i )&lt;br /&gt;
        local barHeight, top = calcHeights( gi, i, val )&lt;br /&gt;
        &lt;br /&gt;
        -- borders so it shows up when printing&lt;br /&gt;
        local style = string.format(&amp;quot;x:%spx;y:%spx;height:%spx;width:%spx;fill:%s;&amp;quot;, left, top, barHeight-1, barWidth-2, color)&lt;br /&gt;
        local link = links[gi] and links[gi][i] or &amp;#039;&amp;#039;&lt;br /&gt;
        -- local img = not nulOrWhitespace( link ) and mw.ustring.format( &amp;#039;[[File:Transparent.png|1000px|link=%s|%s]]&amp;#039;, link, custom and tooltip or &amp;#039;&amp;#039; ) or &amp;#039;&amp;#039;&lt;br /&gt;
        local img = string.format(&amp;quot;&amp;lt;title&amp;gt;%s&amp;lt;/title&amp;gt;&amp;quot;,tooltip);&lt;br /&gt;
        table.insert( res, mw.text.tag( &amp;#039;rect&amp;#039;, { style = style, class = &amp;quot;chart2-bar&amp;quot; }, img ) )&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    function drawYScale()&lt;br /&gt;
    	&lt;br /&gt;
        function drawSingle( gi, color, single )&lt;br /&gt;
            local yscale = yscales[gi]&lt;br /&gt;
            local _, top, ordermag = roundup( yscale * 0.999 )&lt;br /&gt;
            local numnotches = top &amp;lt;= 1.5 and top * 4&lt;br /&gt;
                    or top &amp;lt; 4  and top * 2&lt;br /&gt;
                    or top&lt;br /&gt;
            local valStyleStrCntnr = &amp;#039;display:block;position:relative;height:%spx;text-align:right;margin:0px;&amp;#039; -- SINGLE ELEMENT OF Y AXIS&lt;br /&gt;
            local valStyleStrValue = &amp;#039;display:block;position:relative;float:right;height:%spx;text-align:right;margin:%spx 0px 0px 0px;vertical-align:middle;line-height:%spx;&amp;#039; -- value&lt;br /&gt;
            local valStyleStrNotch = &amp;#039;display:block;position:relative;float:right;height:%spx;text-align:right;width:5px; border-top:1px solid black&amp;#039; -- notch&lt;br /&gt;
                -- or &amp;#039;position:relative;height=20px;text-align:right;vertical-align:middle;max-width:%spx;top:%spx;left:3px;background-color:%s;color:white;font-weight:bold;text-shadow:-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000;padding:0 2px&amp;#039;&lt;br /&gt;
            -- local notchStyleStr = &amp;#039;position:absolute;height=1px;min-width:5px;top:%spx;left:%spx;border:1px solid %s;&amp;#039;&lt;br /&gt;
            for i = 1, numnotches do&lt;br /&gt;
                local val = (numnotches - i + 1) / numnotches * yscale -- value of this notch&lt;br /&gt;
                local y = ( 1 / numnotches * chartHeight )   --chartHeight - calcHeights( gi, 1, val ) -- height of a single notch&lt;br /&gt;
                local divCntnr = mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( valStyleStrCntnr, y, color ) } )&lt;br /&gt;
                local divValue = mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( valStyleStrValue, y, -y/2, y, color ) }, mw.getContentLanguage():formatNum( tonumber( val ) or 0 ) )&lt;br /&gt;
                local divNotch = mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( valStyleStrNotch, y, color ) }, &amp;#039;&amp;amp;nbsp;&amp;#039; ) &lt;br /&gt;
                table.insert( res, divCntnr )&lt;br /&gt;
                table.insert( res, divNotch )&lt;br /&gt;
                table.insert( res, divValue )&lt;br /&gt;
                table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
                table.insert( res, &amp;#039;&amp;lt;div style=&amp;quot;clear:right;display:block&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
                &lt;br /&gt;
                &lt;br /&gt;
                -- div = mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( notchStyleStr, y, width - 4, color ) }, &amp;#039;&amp;#039; )&lt;br /&gt;
                -- table.insert( res, div )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if scalePerGroup then&lt;br /&gt;
            -- local colWidth = 80&lt;br /&gt;
            -- local colStyle = &amp;quot;position:absolute;height:%spx;min-width:%spx;left:%spx;border-right:1px solid %s;color:%s&amp;quot;&lt;br /&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            -- local colStyle = &amp;quot;height:%spx;border-right:1px solid %s;color:%s;display:inline-block;text-align:right&amp;quot;&lt;br /&gt;
            -- for gi = 1, numGroups do&lt;br /&gt;
            --     -- local left = ( gi - 1 ) * colWidth&lt;br /&gt;
            --     local color = colors[gi] or defcolor&lt;br /&gt;
            --     -- table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( colStyle, chartHeight, colWidth, left, color, color ) } ) )&lt;br /&gt;
            --     table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( colStyle, chartHeight, color, color ) } ) )&lt;br /&gt;
            --     drawSingle( gi, color )&lt;br /&gt;
            --     table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
            -- end&lt;br /&gt;
        else&lt;br /&gt;
            drawSingle( 1, &amp;#039;black&amp;#039;,  true ) -- gi is the id of y axis when more than 1 &lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    function drawXlegends()&lt;br /&gt;
        local setOffset, setWidth&lt;br /&gt;
        local legendDivStyleFormat = &amp;quot;display:block;float:left;position:relative;vertical-align:top;width:%spx;text-align:center;margin:0px 0px 0px %spx;&amp;quot;&lt;br /&gt;
        -- local tickDivstyleFormat = &amp;quot;position:absolute;left:%spx;height:10px;width:1px;border-left:1px solid black;&amp;quot;&lt;br /&gt;
        local offsetleft = 0;&lt;br /&gt;
        setOffset, setWidth = groupBounds( 1 )&lt;br /&gt;
        for i = 1, numValues do&lt;br /&gt;
            if not nulOrWhitespace( xlegends[i] ) then&lt;br /&gt;
                table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( legendDivStyleFormat, setWidth, offsetleft ) }, xlegends[i] or &amp;#039;&amp;#039; ) )&lt;br /&gt;
                offsetleft=0;&lt;br /&gt;
            else&lt;br /&gt;
            	offsetleft=offsetleft+setWidth;&lt;br /&gt;
            end&lt;br /&gt;
            &lt;br /&gt;
                -- setOffset, setWidth = groupBounds( i )&lt;br /&gt;
                -- table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( legendDivStyleFormat, setWidth ) }, xlegends[i] or &amp;#039;&amp;#039; ) )&lt;br /&gt;
            &lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    function drawChart()&lt;br /&gt;
        table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format(&amp;quot;position:relative;padding:1em 0em 1em 0em;&amp;quot;) } ) ) -- container div&lt;br /&gt;
        table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format(&amp;quot;position:relative;&amp;quot; ) } ) ) -- container div&lt;br /&gt;
		table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format(&amp;quot;position:relative;height:%spx;display:inline-block;text-align:right;vertical-align:top;&amp;quot;, chartHeight ) } ) )&lt;br /&gt;
        drawYScale()&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;position:relative;display:inline-block&amp;quot;&amp;gt;&amp;#039; )&lt;br /&gt;
        &lt;br /&gt;
        -- table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format(&amp;quot;height:%spx;width:%spx;border-left:1px black solid;border-bottom:1px black solid;display:block;margin:0px;padding:0px;&amp;quot;, chartHeight, chartWidth ) } ) ) -- the actual chart&lt;br /&gt;
        table.insert( res, mw.text.tag( &amp;#039;svg&amp;#039;, { style = string.format(&amp;quot;height:%spx;width:%spx;border-left:1px black solid;border-bottom:1px black solid;&amp;quot;, chartHeight, chartWidth ) } ) ) -- the actual chart&lt;br /&gt;
        local acum = stack and accumulateTooltip and {}&lt;br /&gt;
        for gi, group in pairs( values ) do&lt;br /&gt;
            for i, val in ipairs( group ) do&lt;br /&gt;
                if acum then acum[i] = ( acum[i] or 0 ) + val end&lt;br /&gt;
                drawbar( gi, i, val, acum and acum[i] )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        -- table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/svg&amp;gt;&amp;#039; )&lt;br /&gt;
        &lt;br /&gt;
        table.insert( res, mw.text.tag( &amp;#039;div&amp;#039;, { style = string.format( &amp;quot;position:relative;width:%spx;&amp;quot;, chartWidth ) } ) ) -- X legends&lt;br /&gt;
        drawXlegends()&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
        createGroupList( res, groupNames, colors )&lt;br /&gt;
        table.insert( res, &amp;#039;&amp;lt;/div&amp;gt;&amp;#039; )&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    extractParams()&lt;br /&gt;
    validate()&lt;br /&gt;
    calcHeightLimits()&lt;br /&gt;
    drawChart()&lt;br /&gt;
    return table.concat( res, &amp;quot;\n&amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
    [&amp;#039;bar-chart&amp;#039;] = barChart,&lt;br /&gt;
    [keywords.barChart] = barChart,&lt;br /&gt;
}&lt;br /&gt;
--&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Ita140188</name></author>
	</entry>
</feed>