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(&quot;Module:Graph&quot;)<br /> <br /> local p = {}<br /> <br /> function p.plot(frame)<br /> local property = frame.args[1] or error(&quot;Wikidata property to chart required&quot;)<br /> local xQualifier = frame.args[2] or error(&quot;Wikidata qualifier for x axis required&quot;)<br /> local yIds = mw.text.split(frame.args[&quot;pageIds&quot;] or &quot;&quot;, &quot;,&quot;, true)<br /> local xStart = frame.args[&quot;xStart&quot;]<br /> local xEnd = frame.args[&quot;xEnd&quot;]<br /> local precision = tonumber(frame.args[&quot;precision&quot;])<br /> <br /> -- Collect data<br /> local series = { captions = {}, points = {} }<br /> for seriesIdx, id in ipairs(yIds) do<br /> if id == &quot;&quot; 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 ~= &quot;value&quot; or qualifier.datatype ~= &quot;time&quot; then<br /> error(&quot;&#039;xQualifier&#039; parameter must be a time&quot;)<br /> end<br /> local x = applyPrecision(mw.text.trim(qualifier.datavalue.value.time, &quot;+&quot;), precision)<br /> <br /> if (not xStart or x &gt;= xStart) and (not xEnd or string.sub(x, 1, #xEnd) &lt;= xEnd) and qualifier.datavalue.value.precision &gt;= (precision or 0) then<br /> local mainsnak = item.mainsnak<br /> if mainsnak.snaktype ~= &quot;value&quot; or mainsnak.datatype ~= &quot;quantity&quot; then<br /> error(&quot;&#039;property&#039; parameter must be numeric&quot;)<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 = &quot;line&quot;,<br /> xType = &quot;date&quot;,<br /> xAxisTitle = mw.wikibase.label(xQualifier),<br /> x = table.concat(xValues, &quot;,&quot;),<br /> yType = &quot;number&quot;,<br /> yAxisTitle = mw.wikibase.label(property)<br /> }<br /> -- Set legends / series titles<br /> for seriesIdx, caption in ipairs(series.captions) do<br /> chartArgs[&quot;y&quot; .. seriesIdx] = &quot;&quot;<br /> chartArgs[&quot;y&quot; .. seriesIdx .. &quot;Title&quot;] = 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[&quot;y&quot; .. seriesIdx] = chartArgs[&quot;y&quot; .. seriesIdx] .. &quot;,&quot; .. (yValues[seriesIdx] or &quot;&quot;)<br /> end<br /> end<br /> -- Remove separators at the beginning<br /> for seriesIdx, _ in ipairs(series.captions) do<br /> chartArgs[&quot;y&quot; .. seriesIdx] = mw.ustring.sub(chartArgs[&quot;y&quot; .. 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, &quot;^chart_(.+)&quot;)<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, &quot;^(.?%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)(.+)$&quot;)<br /> if precision &lt; 14 then second = &quot;00&quot; end<br /> if precision &lt; 13 then minute = &quot;00&quot; end<br /> if precision &lt; 12 then hour = &quot;00&quot; end<br /> if precision &lt; 11 or day == &quot;00&quot; then day = &quot;01&quot; end<br /> if precision &lt; 10 or month == &quot;00&quot; then month = &quot;01&quot; end<br /> return year .. &quot;-&quot; .. month .. &quot;-&quot; .. day .. &quot;T&quot; .. hour .. &quot;:&quot; .. minute .. &quot;:&quot; .. second .. timezone<br /> end<br /> <br /> return p</div> Zyxw