Wikipedia Diskussion:Lua/Modul/Graph

aus Wikipedia, der freien Enzyklopädie
(Weitergeleitet von Modul Diskussion:Graph)
Letzter Kommentar: vor 8 Monaten von Pietrasagh in Abschnitt Vega 5
Zur Navigation springen Zur Suche springen

Fehler in Modul?[Quelltext bearbeiten]

Vorlage:GraphChart Vorlage:GraphChart Vorlage:GraphChart

Ich bruache einen Ersatz für diese Einbindung normalerweise sollte das hier die Grafik 2 sein, der Rest sind nur Tests. Da sollen aber bitteschön Jahreszahlen stehen und keine, was weiß ich, Literangaben? Das wird jedoch nur für die Balkendiagramme ausgegeben. Wie bekommt man das so hin, dass dort auch Jahresangaben stehen? Kann das bitte jemand anpassen, oder kann man nur die Balken für derartige Darstellungen nutzen, dann sollte das in der Doku aber erklärt werden. --Liebe Grüße, Lómelinde Diskussion 19:02, 17. Dez. 2015 (CET)Beantworten

Minor cleanup[Quelltext bearbeiten]

User:Mps, there are two minor bugs I found: for pie graphs, you add "axes":[], and you make two identical transformations "from": {"data": "chart", "transform": [{"type": "pie", "field": "y"}]} inside each mark (text and arc), instead of making one common data source and using it for both of the marks. Regardless, great job on keeping the graphs going! :) --Yurik (Diskussion) 00:29, 3. Feb. 2016 (CET)Beantworten

P.S. I think it would be good to also add a filtering transform for the text mark when doing pie chart, so that if you want to print a label for each slice, and the pie slice is very small, don't print for it:
      "from": {
        "data": "values",
        "transform": [{"type": "filter", "test": "(datum.layout_end - datum.layout_start) > 0.2"}]
      },

--Yurik (Diskussion) 01:26, 3. Feb. 2016 (CET)Beantworten

Error in error[Quelltext bearbeiten]

With this bogus code (missing coma at the end of first y values line):

{{Graph:Chart
 |width=400
 |height=100
 |xAxisTitle=X
 |yAxisTitle=Y
 |yType=number
 |type=rect
 |x= 
 1, 2, 3, 4,
 5, 8, 9,10
 |y=
10,12, 6,14
 2,10, 7, 9
}}

currently renders as:

Lua-Fehler in Modul:Graph, Zeile 243: attempt to concatenate global 'name' (a nil value)

There is tow problems:

  • The script error is hidden by the graph tag. My suggestion is to add the graph tag directly in the Module rather than in the template.
  • There is an error when generating the error message, as it uses an undefined global name (line 243).

Regards, --Zebulon84 (Diskussion) 16:58, 13. Apr. 2016 (CEST)Beantworten

Graphs not displaying on mobile version pages.[Quelltext bearbeiten]

Sorry for writing in English. There is a problem with Graph images on mobile version pages. If you look at the mobile version of this page the graph images are just blank rectangles. This seems to be true for all graphs and maps that use this module. It affects the images that are in subsections of the page, (first paragraphs work fine) because the mobile version has a system ('lazy image loader') to only download an image if the user scrolls down the page. From what I have found by right-clicking 'inspect' over the empty graph, (but I am afraid with very limited technical knowledge) the problem could be in the way the lazy loader creates a <div class="mw-graph" section, which includes:

<img width="0" height="0" class="mw-graph-img image-lazy-loaded" alt="" src="/api/rest_v1/page/graph/png/....png" srcset style>

So the correct image is there and ready to be displayed, but nothing is visible because there is zero width and height. But I have no idea how the lazy loader finds these sizes, or why it is failing.

Comparing this to a wikimedia.commons image, this has (for example)

<img width="400" height="300" class="thumbimage image-lazy-loaded" alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/5/53/....jpg" srcset="" style="width: 400px; height: 300px;">

The use of the 'graph' module in maps means it is particularly missed if reading from a mobile phone about a place you are in. If there is someone with the understanding to sort this out, it will be a big benefit. Thanks, RobinLeicester (Diskussion) 21:25, 14. Mär. 2019 (CET)Beantworten

A solution to the problem has been found through a style.css file, enabling the relevant height and width to inherit appropriate values. This has been applied to the en: and mediawiki versions of Graph:Street map with marks, but may need rolling out to other graph modules and other languages. If anyone knows how the structure of the various graph templates works, and can do this in an efficient manner, it will re-instate a lot of graphs on mobile devices. More details of the fix are at phabT216431, and the css is at www.mediawiki.org/wiki/Template:Graph:Street_map_with_marks/styles.css. RobinLeicester (Diskussion) 20:10, 7. Mai 2019 (CEST)Beantworten

Zeilenumbruch in Legende[Quelltext bearbeiten]

Lange Legenden sind schwierig - entweder wird die Grafik unendlich breit, wenn man das nicht will, hilft ein Zeilenumbruch, aber das wird nicht richtig unterstützt: Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert. Kann das möglicherweise leicht repariert werden? Das wäre schön. --dingensfünf 14:36, 19. Jul. 2019 (CEST)Beantworten

Wie man das repariert, weiß ich leider nicht. Doch eine mögliche schnelle Lösung wäre die Benutzung der Vorlage:Farblegende anstelle der eingebauten Legende. --Birger (Diskussion) 08:12, 13. Mär. 2020 (CET)Beantworten

Problem with <nowiki> and this module[Quelltext bearbeiten]

Hello. There is a compatibility problem between colour templates that use nowiki tags (such as en:Template:Liberal Democrats (UK)/meta/color) and this module. Please see en:Template talk:Graph:Chart#Problem with nowiki and this template. 202.159.169.45 (talk) 22:54, 15 September 2019 (UTC) (nicht signierter Beitrag von 202.159.169.45 (Diskussion) 01:18, 16. Sep. 2019 (CEST))Beantworten

Die nowiki-Tags können mit dem Code in den nachfolgenden Abschnitten interagieren und wurden daher verschleiert. Mathglot (Diskussion) 23:26, 1. Sep. 2022 (CEST)Beantworten

showSymbols doesn't respect opacity values[Quelltext bearbeiten]

The showSymbols parameter doesn't respect opacity values. Here's a clearer/simpler example. The lines conform to the opacity of #40FF0000 (#FF0000 at 25% opacity); the symbols do not (they display as #FF0000 at 100% opacity). Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert. Alex 21 (Diskussion) 11:41, 22. Sep. 2019 (CEST)Beantworten

Any thoughts? Alex 21 (Diskussion) 04:10, 4. Okt. 2019 (CEST)Beantworten
I've looked into this and it would be possible to change Modul:Graph accordingly to set the same opacity value. (These are the changes that I tried.) However, the resulting diagram does not fully convince me, because the opacities add up and the color of the line is stronger where it overlaps with the symbol.
What do you think? --Birger (Diskussion) 17:19, 16. Feb. 2020 (CET)Beantworten

Formatfehler für Datum bei type=rect?[Quelltext bearbeiten]

Frohes Fest, bei type=rect (und stackedrect) wird ein Datum auf der X-Achse falsch formatiert. --Aeroid (Diskussion) 08:17, 24. Dez. 2019 (CET)Beantworten

Vorlage:GraphChart Vorlage:GraphChart

Hallo Aeroid, die schnelle Lösung besteht wahrscheinlich darin, beim Blockdiagramm die Jahreszahlen als String zu verarbeiten. Also einfach xType=date weglassen. Das sollte dann so wie hier unten dargestellt aussehen. Für eine bessere Lösung müsste man tiefer in das Lua-Modul einsteigen. Grüße, --Birger (Diskussion) 16:17, 16. Feb. 2020 (CET)Beantworten
Vorlage:GraphChart
Inzwischen habe ich tiefer in das Modul reingeschaut. In der Funktion "getXscale" wird bei "type=rect" die X-Achse fest eingestellt auf "xscale.type = "ordinal". Dabei geht dann vermutlich die Information verloren, dass es sich ursprünglich um ein Datum gehandelt hat. Also besser die schnelle Lösung wie oben beschrieben verwenden. --Birger (Diskussion) 17:48, 16. Feb. 2020 (CET)Beantworten

Relicense[Quelltext bearbeiten]

(sorry for the English) because dewiki and most wikimedia projects use CC-BY-SA-3.0, this module cannot be imported to enwikinews. Would the contributors be willing to release their work into the public domain, so that licensing isn't an issue? The following users have made contributions and would need to agree: Mps, Yurik, Yair rand, Tom.Reding, Leoncastro, Birger Fricke, Toohool (contributions imported from enwiki). Please consider allowing this to be used on wikinews by releasing your contributions into the public domain (just need to confirm that each of you are okay with it by saying so below). Thanks so much, --DannyS712 (Diskussion) 20:42, 7. Apr. 2020 (CEST)Beantworten

Certainly. I agree to release my contributions to this module to the public domain. (Note that licensing under CC-BY or CC-0 would work as well, if I understand correctly.) --Yair rand (Diskussion) 21:02, 7. Apr. 2020 (CEST)Beantworten
I agree too. Toohool (Diskussion) 00:12, 8. Apr. 2020 (CEST)Beantworten
I agree. --Birger (Diskussion) 07:05, 8. Apr. 2020 (CEST)Beantworten
Same here, cc0 is fine )) --Yurik (Diskussion) 06:33, 17. Apr. 2020 (CEST)Beantworten
I agree. Tom.Reding (Diskussion) 13:29, 17. Apr. 2020 (CEST)Beantworten
I agree. -- Leoncastro (Diskussion) 14:54, 17. Apr. 2020 (CEST)Beantworten
Fine by me too. But it would be nice that when you copy it over, to at least link to (e.g. on the talk page) where you got it from. As Yair has mentioned CC-BY should also work on Wikinews as the only requirement is attribution. --Mps、かみまみたDisk. 12:44, 19. Apr. 2020 (CEST)Beantworten
Mps, Yurik, Yair rand, Tom.Reding, Leoncastro, Birger Fricke, Toohool sorry for the trouble, but a user on enwikinews believes that your agreement that the contributions be released into the public domain is not enough, and wants you to also explicitly state that you agree to license it under CC0 as well. Do you agree? Thanks, --DannyS712 (Diskussion) 21:23, 19. Apr. 2020 (CEST)Beantworten
I agree to CC0. Toohool (Diskussion) 22:53, 19. Apr. 2020 (CEST)Beantworten
I am not a licensing expert, but I think that from the moment we allow to release this into the public domain (PD), you can do almost anything you want with this, except redistribute it under a non-derivative license (ND, like CC-BY-ND or CC-BY-NC-ND). PD is fully compatible with CC0 or CC-BY. So, do whatever you want. Regards. -- Leoncastro (Diskussion) 00:11, 20. Apr. 2020 (CEST)Beantworten
I agree with you, but an admin on enwikinews doesn't, and wanted to be sure --DannyS712 (Diskussion) 00:32, 20. Apr. 2020 (CEST)Beantworten
Leoncastro just to be clear, you agree to CC0? --DannyS712 (Diskussion) 12:10, 20. Apr. 2020 (CEST)Beantworten
@DannyS712, I have agreed to release this work into the public domain, so I have agreed to use it with other compatible licenses, including CC0 or CC-BY, as I said. -- Leoncastro (Diskussion) 15:24, 20. Apr. 2020 (CEST)Beantworten
I agree to CC0. Tom.Reding (Diskussion) 11:35, 20. Apr. 2020 (CEST)Beantworten
I agree to CC0. --Yair rand (Diskussion) 05:23, 27. Apr. 2020 (CEST)Beantworten
I agree to CC0. --Mps、かみまみたDisk. 15:48, 3. Mai 2020 (CEST)Beantworten
I agree to CC0. --Birger (Diskussion) 08:44, 9. Jun. 2020 (CEST)Beantworten

ShowSymbols upgrade[Quelltext bearbeiten]

Hi, I made small upgrade for showSymbols, and linewidths. Now new option are available:

  • linewidths: linewidths may be defined for for series with csv
  • showSymbols: number as size or default 2.5, may be defined for for series with csv
  • symbolsShape: circle, x, square, cross, diamond, triangle_up, triangle_down, triangle_right, triangle_left - may be defined for for series with csv
  • showSymbols: number or default 2.5,
  • symbolsNoFill: if true symbol without fill (only stroke),
  • symbolsStroke: symbol stroke, default 2.5 if "x" of symbolsNoFill

You can check it out here

For debugging I added function "chartDebugger" that return vega JSON and other runtime info.

Please let me know if it what you expect. My next ideas: "serialization" of symbols settings and line widths.

Vorlage:Graph:Chart/Spielwiese Vorlage:Graph:Chart/Spielwiese Vorlage:Graph:Chart/Spielwiese

--Pietrasagh (Diskussion) 17:57, 8. Apr. 2020 (CEST)Beantworten

If you like it or not ;-) changes are in current version
Please check if your favorite graphs are displayed correctly or maybe could be updated with new options
linewidths: different line widths may be defined for each series of data with csv, if set to 0 with "showSymbols" results with points graph
showSymbols: show symbol on data point for line graphs, if number is provided it's size of symbol, default 2.5. may be defined for each series of data with csv
symbolsShape: custom shape for symbol: circle, x, square, cross, diamond, triangle_up, triangle_down, triangle_right, triangle_left. May be defined for each series of data with csv
symbolsNoFill: if true symbol will be without fill (only stroke),
symbolsStroke: if "x" symbol is used or option "symbolsNoFill" symbol stroke width, default 2.5
--Pietrasagh (Diskussion) 18:53, 26. Jun. 2020 (CEST)Beantworten

Compatibility with Listeria[Quelltext bearbeiten]

To make this work with d:Template:Wikidata list (Listeria) on Wikidata, I added a lowercase variable names on Wikidata [1]. You might want to include that here too.

d:Template:Wikidata_list#Charts has an explanation on how to use it. Sample chart at d:Wikidata:Lists/COVID-19 deaths/numbers/chart. --Jura1 (Diskussion) 10:03, 26. Apr. 2020 (CEST)Beantworten

xAxisFormat gives English dates[Quelltext bearbeiten]

If you use dates in the format YYYY/MM/DD in combination with xAxisFormat, the output is date labels in the English language irrespective of the language of the wiki. Maybe it can be changed so the locale of the wiki will be used. Here an example in the Dutch language. Behanzane (Diskussion) 12:06, 29. Apr. 2020 (CEST)Beantworten

Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert.

This template is using mw:Extension:Graph and developers are working on this problem since 2015. It's going quite slow. For details see [2] --Pietrasagh (Diskussion) 18:05, 21. Jun. 2020 (CEST)Beantworten
A workaround is to show the date labels in numbers with xAxisFormat = %m/%Y or in this case xAxisFormat = %d/%m:
Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert.
The RedBurn (ϕ) 00:11, 10. Sep. 2020 (CEST)Beantworten

Offene Sichtung? (Bitte um Sichtung)[Quelltext bearbeiten]

Hallo, könnte es sein, dass es im Modul eine Änderung gegeben hat, die dazu führt, dass andere Artikel als nicht vollständig gesichtet gelten?

  • Vorlagen- und Dateiänderungen dieser Version sind noch nicht markiert. Die gesichtete Version wurde am 27. Juni 2020 markiert.
  • Vorlagen/Dateien wurden aktualisiert (nicht markierte Seiten sind in fett gekennzeichnet): Modul:Graph

Oder sehe ich das falsch? (Im Artikel sehen ich keine ungesichteten Änderung.)

Viele Grüße --Molgreen (Diskussion) 18:48, 27. Jun. 2020 (CEST)Beantworten

Common WorldMap-iso2.json for all wikis on Commons[Quelltext bearbeiten]

Hi,

We're having problems to create a Module:Graph/WorldMap-iso2.json on :fr because the Module namespace is normally for Lua instead of JSON.
Wouldn't it be possible to use a WorldMap-iso2.json on Commons instead of a local one on each wiki? This would also make it easier to keep it up to date. The RedBurn (ϕ) 13:09, 27. Aug. 2020 (CEST)Beantworten

Loading spinner bug[Quelltext bearbeiten]

On mobile, the loading spinner appears from behind graphs drawn with this module when horizontally scrolling on them. I've filed a bug report [3], but maybe this can be solved directly in the module? Somnifuguist (Diskussion) 04:33, 13. Jul. 2021 (CEST)Beantworten

Line color for pie charts[Quelltext bearbeiten]

Hi! I have added an option for the line color (called linecolor, to match linewidth) of a pie chart to the sandbox: Special:Diff/215633154.

You can see it in action at s:en:Template:Progress_pie_chart, where some pie charts may have a "missing" section. Hopefully it can be added upstream here to keep it in sync. Inductiveload (Diskussion) 15:50, 16. Sep. 2021 (CEST)Beantworten

y1 mishandles missing values[Quelltext bearbeiten]

so, it seems that when marking missing data points for y1 by commas, the templates (module) "trims" them, and shift the non-empty values leftward: this graph shows y1 values on the wrong stacks. (|y1 = 100,,,, 100,140,70) this does not happen in a similar fashion with y2: Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert.

same graph, transposing y1 and y2:

Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert.

a quick workaround can be filling those with zeroes, however, zeroes are not good friends with showValues, as the zeroes are written with no corresponding "rect". i think it's worth fixing.

(addition): see cols "two" and "four" below, when filling the gaps with zeroes: Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert. peace - קיפודנחש (Diskussion) 02:44, 20. Mär. 2022 (CET)Beantworten

Y-Achse rechts — Right-side y-axis[Quelltext bearbeiten]

Click [Ausklappen] for English text. Kopie des ursprünglichen Vorschlags: en:Module talk:Graph#Right-side y-axis.

(toggle English)

I'd like to propose an enhancement to allow a second y-Axis. It's frequently the case that one might want to plot line graphs (or scatterplots) of two sets of numerical data that follow roughly similar patterns but where the data values of one set are roughly twice the other (or 3x, or 10x or whatever; e.g., slowly increasing backlogs of articles in two areas, where one set of numbers is triple the other). Here's an example of a time-series graph with two curves where y-axis is article count: curve 1 (blue) is a count of articles with 0 in-links (i.e. en:WP:Orphans; y-vals around 1200-1600) belonging to a particular WikiProject, and curve 2 (gold) is articles with 1 in-link (values around 4800-5200): I've hacked this below, by scaling down the 1-link values by 0.3, as follows (all data prior to April are fake; the last two datapoints are real, see quarry:63580):

Ich möchte eine Verbesserung vorschlagen, um eine zweite y-Achse zu ermöglichen. Es kommt häufig vor, dass man Liniendiagramme (oder Streudiagramme) von zwei numerischen Datensätzen erstellen möchte, die ungefähr ähnlichen Mustern folgen, aber bei denen die Datenwerte des einen Satzes ungefähr doppelt so hoch sind wie die des anderen (oder 3x, oder 10x oder was auch immer; z.B. langsam ansteigende Rückstände von Artikeln in zwei Bereichen, bei denen ein Satz von Zahlen das Dreifache des anderen beträgt). Hier ist ein Beispiel für ein Zeitseriendiagramm mit zwei Kurven, wobei die y-Achse die Anzahl der Artikel ist: Kurve 1 (blau) ist die Anzahl der Artikel mit 0 In-Links (d.h. "Waisen"; y-Werte um 1200-1600), die zu einem bestimmten WikiProjekt gehören, und Kurve 2 (gold) sind Artikel mit 1 In-Link (Werte um 4800-5200): Ich habe dies unten gehackt, indem ich die 1-Link-Werte um 0,3 herunterskaliert habe, wie folgt (alle Daten vor April sind gefälscht; die letzten beiden Datenpunkte sind echt, siehe quarry:63580):

Die Darstellung von Grafiken ist aktuell auf Grund eines Sicherheitsproblems deaktiviert.

Was ich gerne sehen würde, wäre eine zweite y-Achse auf der rechten Seite, skaliert von etwa 4400-5800, möglicherweise mit dem Zusatz dieser Parameter:

What I'd like to see would be a second y-axis on the right, scaled from roughly 4400-5800, possibly with the addition of these parameters:
  • |yAxis2Max=5800
  • |yAxis2Min=4200
  • |yAxis2Title=Anzahl der Artikel – count of articles
  • |yAxis2Format
  • |yAxis2Angle
  • |yGrid2

(toggle English)

The important ones are the first two, which ought to be optional and default to a calculation based on min y2 value and max y2 value, and but overridable for fine tuning. A scale factor should be derived for biasing y2 values up or down the y-axis according to the right-side y-axis; sort of what I did with my hacky use of {{#expr:val}} on the gold curve above. The other params are cosmetic. Naturally, this only makes sense for numerical yType like integer, not date or string, etc. The last param is about deciding how to align the grid lines; default to lined up with major 'tick marks' on the left y-axis, but if |yGrid2=1, then align with right-side tick marks. Maybe |yGrid2=2 means, 'every 2nd major tick mark', to make the grid sparser. (Or maybe lines both left and right, in separate styles such as dashed or dotted?)



Die wichtigsten sind die ersten beiden, die optional sein sollten und standardmäßig auf einer Berechnung basierend auf dem minimalen y2-Wert und dem maximalen y2-Wert basieren sollten, aber für eine Feinabstimmung überschrieben werden können. Ein Skalierungsfaktor sollte abgeleitet werden, um die y2-Werte auf der y-Achse entsprechend der rechten y-Achse nach oben oder unten zu verzerren; in etwa so, wie ich es mit meiner hackende Verwendung von {{#expr:Wert}}auf der goldenen Kurve oben gemacht habe. Die anderen Parameter sind kosmetisch. Natürlich ist dies nur für numerische yType wie integer sinnvoll, nicht für date oder string, etc. Der letzte Parameter legt fest, wie die Rasterlinien ausgerichtet werden sollen; standardmäßig werden sie an den großen Teilstriche auf der linken y-Achse ausgerichtet, aber wenn |yGrid2=1 ist, dann werden sie an den Teilstriche auf der rechten Seite ausgerichtet. Vielleicht bedeutet |yGrid2=2 "jede 2. Haupt-Teilstriche, um das Gitter spärlicher zu machen. (Oder vielleicht Linien links und rechts in separaten Stilen wie gestrichelt oder gepunktet?)

Vielen Dank im Voraus. Mathglot (Diskussion) 23:29, 1. Sep. 2022 (CEST)Beantworten

Add a 'title' setting?[Quelltext bearbeiten]

Would it be possible to add a title setup? Similar to Template:Graph:Lines perhaps. Thank you for consideration - and apologies for posting in English. --Varnent (Diskussion) 18:22, 4. Nov. 2022 (CET)Beantworten

Date formatting[Quelltext bearbeiten]

I have noticed that when using bar type of a chart, the formatting of the date doesn't work. It is possible to be seen down below where is the chart three times with same data however it's a different type of a chart every time. At an x axis, the formatting of the years using %Y etc. (but it also affects regular dates like 2022-02-02). Instead, an Unix number is displayed. Is there anybody able to fix it, please?

Example mentioned above: Vorlage:GraphChart

Vorlage:GraphChart

Vorlage:GraphChart --Bilykralik16 (Diskussion) 23:38, 27. Dez. 2022 (CET)Beantworten

Synchronizer[Quelltext bearbeiten]

Hi! I thought you may find this interesting: https://www.mediawiki.org/w/index.php?title=Multilingual_Templates_and_Modules&withJS=MediaWiki:Synchronizer.js#synchronizer-Modul:Graph

Perhaps the relatively large number of Forked wikis is because many copied from enwiki? Just guessing. Cheers! --Sophivorus (Diskussion) 01:52, 30. Jan. 2023 (CET)Beantworten

Vega 5[Quelltext bearbeiten]

Does anyone else is working on update of modules for graphs to Vega 5? I'm doing my best here https://en.wikipedia.beta.wmflabs.org/wiki/Module:Graph/sandbox but progress is very slow (see here https://en.wikipedia.beta.wmflabs.org/wiki/Template:Graph:Chart/sandbox). For details please see here mw:Extension_talk:Graph#Assistance_in_migrating_Module:Graph_on_Beta_Labs --Pietrasagh (Diskussion) 16:36, 2. Sep. 2023 (CEST)Beantworten