Content deleted Content added
No edit summary |
Fixed off-by-one error |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1:
--- Example usage:
--- {{#invoke:Medical cases chart/data|externalData|page=COVID-19
--- =p._externalData({datapage="COVID-19
local p = {}
Line 21:
local change = current / previous * 100 - 100
local sign = change < 0 and "−" or "+"
return mw.ustring.format("%s%s%%", sign, lang:formatNum(round(math.abs(change))))▼
if (math.abs(change)) >= 10 then
return mw.ustring.format("%s%.0f%%", sign, (math.abs(change)))
end
if (math.abs(change)) < 1 then
return mw.ustring.format("%s%.3f%%", sign, (math.abs(change)))
end
end
Line 69 ⟶ 76:
}
local prevRecord = records[#records] or {}
if casesIndex and not prevRecord.cases and record.cases and record.cases > 0 then
record.options.firstright1 = "y"
end
if deathsIndex and prevRecord.deaths == 0 and record.deaths and record.deaths > 0 then
record.options.firstright2 = "y"
end
Line 94 ⟶ 101:
for i = #records, 1, -1 do
local record = records[i]
if i < #records and record.streak > 3 then
for j = i, i - record.streak + 3, -1 do
table.remove(records, j)
|