if #args.numwidth == 4 then
numwidth = numwidth + _numwidth(3) + _numwidth(4)
if args.numwidth:sub(3, 3) == 'n' then
numwidth = numwidth + 6
else
numwidth = numwidth + 10
end
if not args.right2 then
right1width = numwidth
end
end
right1width = right1width - 8 -- -8 because of padding  
if tonumber(barwidth) then
barargs.width = 85 + barwidth + numwidth .. 'px'
barargs.barwidth = barwidth .. 'px'
else
barargs.
barargs.bar
end  
local title = {}  
local function spaces(n)
local nbsp = '&nbsp;'
return '<span>' .. nbsp:rep(n) .. '</span>'
end  
local location = lang:ucfirst(mw.ustring.gsub(args.location, i18n.the_, ''))
local navbartitle = args.outbreak .. i18n._data .. '/' ..
(args.location3 and args.location3 .. '/' or '') ..
(args.location2 and args.location2 .. '/' or '') ..
location .. i18n._medicalCasesChart  
local navbar = require('Module:Navbar')._navbar
title[1] = (args.pretitle and args.pretitle .. ' ' or '') ..
args.disease .. ' ' .. i18n.casesIn .. ' ' .. args.location ..
(args.location2 and ', ' .. args.location2 or '') ..
(args.location3 and ', ' .. args.location3 or '') ..
(args.posttitle and ' ' .. args.posttitle or '') .. spaces(2) ..'(' ..
navbar({navbartitle, titleArg=':' .. mw.getCurrentFrame:getParent:getTitle, mini=1, nodiv=1}) ..
')
'  
title[2] = p._legend0({p._barColors[1], i18n.deaths})
args.recoveries = args.recoveries == nil and true or args.recoveries
title[3] = args.recoveries and spaces(3) .. p._legend0({p._barColors[2], args.reclbl or i18n.recoveries}) or ''
title[4] = args.altlbl1 ~= 'hide' and spaces(3) .. p._legend0({p._barColors[3], args.altlbl1 or i18n.activeCases}) or ''
title[5] = args.altlbl2 and spaces(3) .. p._legend0({p._barColors[4], args.altlbl2}) or ''
title[6] = args.altlbl3 and spaces(3) .. p._legend0({p._barColors[5], args.altlbl3}) or ''  
local togglesbar, buildargs = nil, {}  
args.right1 = args.right1 or i18n.noOfCases
args.duration = args.duration or 15
args.nooverlap = args.nooverlap or false  
buildargs.barwidth = tonumber(barwidth) or 280
buildargs.numwidth = args.numwidth
buildargs.rowheight = args.rowheight
if args.datapage then
local externalData = require('Module:Medical cases chart/data')._externalData
buildargs.data = externalData(args)
else
buildargs.data = args.data
end
-- if no right1data and right1 title is cases, use 3rd classification
buildargs.right1data = args.right1data or args.right1 == i18n.noOfCases and 3
-- if no right2data and right2 title is deaths, use 1st classification
buildargs.right2data = args.right2data or (args.right2 == i18n.noOfDeaths or args.right2 == i18n.noOfDeaths2) and 1
buildargs.changetype1 = (args.changetype1 or args.changetype or ''):sub(1, 1) -- 1st letter
buildargs.changetype2 = (args.changetype2 or args.changetype or ''):sub(1, 1) -- 1st letter
buildargs.collapsible = args.collapsible
buildargs.duration = args.duration
buildargs.nooverlap = args.nooverlap  
local dateList
barargs.bars, dateList = p._buildBars(buildargs)  
if buildargs.collapsible then
togglesbar = p._buildTogglesBar(dateList, args.duration, args.nooverlap)
end  
title[7] = togglesbar and '
' .. togglesbar or ''
barargs.title = table.concat(title)  
barargs.left1 =
'<div>' .. -- 85-8 because of padding
"**" .. i18n.date .. "**" .. '</div>'  
barargs.right1 =
'<div>' ..
"**" .. args.right1 .. "**" .. '</div>'  
if args.right2 then
local right2width = numwidth - right1width - 16 -- -8-8...
barargs.right2 =
'<div>' ..
"**" .. args.right2 .. "**" .. '</div>'
end  
barargs.caption = args.caption
return barBox._box(barargs)
end  
function p.chart
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(, {
valueFunc = function (key, value)
if value and value ~= '' then
key = key:gsub('%d', '')
if ({rowheight=1, duration=1, rightdata=1})[key] then -- if key in {...}
return tonumber(value) or value
end
if ({recoveries=1, collapsible=1, nooverlap=1})[key] then
return yesno(value)
end
return value
end
return nil
end
})
return p._chart(args)
end  
return p