https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AWikidataChart
Module:WikidataChart - Revision history
2025-06-01T13:37:12Z
Revision history for this page on the wiki
MediaWiki 1.45.0-wmf.3
https://en.wikipedia.org/w/index.php?title=Module:WikidataChart&diff=1066167910&oldid=prev
Zyxw: use English labels first, if available.
2022-01-17T03:46:42Z
<p>use English labels first, if available.</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:46, 17 January 2022</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 18:</td>
<td colspan="2" class="diff-lineno">Line 18:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local labels = entity.labels or {}</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local labels = entity.labels or {}</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> series.captions[seriesIdx] = (labels.<del style="font-weight: bold; text-decoration: none;">de</del> or labels.<del style="font-weight: bold; text-decoration: none;">en</del> or {}).value or id</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> series.captions[seriesIdx] = (labels.<ins style="font-weight: bold; text-decoration: none;">en</ins> or labels.<ins style="font-weight: bold; text-decoration: none;">de</ins> or {}).value or id</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local property = entity.claims[property]</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local property = entity.claims[property]</div></td>
</tr>
</table>
Zyxw
https://en.wikipedia.org/w/index.php?title=Module:WikidataChart&diff=1051428844&oldid=prev
Zyxw: from de:Modul:WikidataChart
2021-10-23T13:15:55Z
<p>from <a href="https://de.wikipedia.org/wiki/Modul:WikidataChart" class="extiw" title="de:Modul:WikidataChart">de:Modul:WikidataChart</a></p>
<p><b>New page</b></p><div>local graph = require("Module:Graph")<br />
<br />
local p = {}<br />
<br />
function p.plot(frame)<br />
local property = frame.args[1] or error("Wikidata property to chart required")<br />
local xQualifier = frame.args[2] or error("Wikidata qualifier for x axis required")<br />
local yIds = mw.text.split(frame.args["pageIds"] or "", ",", true)<br />
local xStart = frame.args["xStart"]<br />
local xEnd = frame.args["xEnd"]<br />
local precision = tonumber(frame.args["precision"])<br />
<br />
-- Collect data<br />
local series = { captions = {}, points = {} }<br />
for seriesIdx, id in ipairs(yIds) do<br />
if id == "" then id = nil end<br />
local entity = mw.wikibase.getEntity(id)<br />
<br />
local labels = entity.labels or {}<br />
series.captions[seriesIdx] = (labels.de or labels.en or {}).value or id<br />
<br />
local property = entity.claims[property]<br />
for _, item in ipairs(property) do<br />
if item.qualifiers and item.qualifiers[xQualifier] and item.qualifiers[xQualifier][1] then<br />
local qualifier = item.qualifiers[xQualifier][1]<br />
if qualifier.snaktype ~= "value" or qualifier.datatype ~= "time" then<br />
error("'xQualifier' parameter must be a time")<br />
end<br />
local x = applyPrecision(mw.text.trim(qualifier.datavalue.value.time, "+"), precision)<br />
<br />
if (not xStart or x >= xStart) and (not xEnd or string.sub(x, 1, #xEnd) <= xEnd) and qualifier.datavalue.value.precision >= (precision or 0) then<br />
local mainsnak = item.mainsnak<br />
if mainsnak.snaktype ~= "value" or mainsnak.datatype ~= "quantity" then<br />
error("'property' parameter must be numeric")<br />
end<br />
local y = tonumber(mainsnak.datavalue.value.amount)<br />
<br />
if not series.points[x] then series.points[x] = {} end<br />
series.points[x][seriesIdx] = y<br />
end<br />
end<br />
end<br />
end<br />
<br />
-- Sort x values<br />
local xValues = {}<br />
for k in pairs(series.points) do table.insert(xValues, k) end<br />
table.sort(xValues)<br />
<br />
local chartArgs =<br />
{<br />
type = "line",<br />
xType = "date",<br />
xAxisTitle = mw.wikibase.label(xQualifier),<br />
x = table.concat(xValues, ","),<br />
yType = "number",<br />
yAxisTitle = mw.wikibase.label(property)<br />
}<br />
-- Set legends / series titles<br />
for seriesIdx, caption in ipairs(series.captions) do<br />
chartArgs["y" .. seriesIdx] = ""<br />
chartArgs["y" .. seriesIdx .. "Title"] = caption<br />
end<br />
-- Set values<br />
local seriesCount = #series.captions<br />
for _, x in ipairs(xValues) do<br />
yValues = series.points[x]<br />
for seriesIdx = 1, seriesCount do<br />
chartArgs["y" .. seriesIdx] = chartArgs["y" .. seriesIdx] .. "," .. (yValues[seriesIdx] or "")<br />
end<br />
end<br />
-- Remove separators at the beginning<br />
for seriesIdx, _ in ipairs(series.captions) do<br />
chartArgs["y" .. seriesIdx] = mw.ustring.sub(chartArgs["y" .. seriesIdx], 2)<br />
end<br />
-- Transfer diagram parameters (all parameters that start with chart_ are transferred directly to the Graph module without a prefix)<br />
for k, v in pairs(frame.args) do<br />
local chartParam = string.match(k, "^chart_(.+)")<br />
if chartParam then chartArgs[chartParam] = v end<br />
end<br />
<br />
return graph.chart({ args = chartArgs })<br />
end<br />
<br />
function p.plotWrapper(frame)<br />
return p.plot(frame:getParent())<br />
end<br />
<br />
function applyPrecision(date, precision)<br />
if not precision then precision = math.huge end<br />
<br />
local _, _, year, month, day, hour, minute, second, timezone = string.find(date, "^(.?%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)(.+)$")<br />
if precision < 14 then second = "00" end<br />
if precision < 13 then minute = "00" end<br />
if precision < 12 then hour = "00" end<br />
if precision < 11 or day == "00" then day = "01" end<br />
if precision < 10 or month == "00" then month = "01" end<br />
return year .. "-" .. month .. "-" .. day .. "T" .. hour .. ":" .. minute .. ":" .. second .. timezone<br />
end<br />
<br />
return p</div>
Zyxw