Zum Inhalt springen

Wikipedia Diskussion:Lua/Modul/Graph

Seiteninhalte werden in anderen Sprachen nicht unterstützt.
aus Wikipedia, der freien Enzyklopädie
Dies ist eine alte Version dieser Seite, zuletzt bearbeitet am 1. September 2022 um 22:37 Uhr durch Mathglot (Diskussion | Beiträge) (Änderung 225827598 von Mathglot rückgängig gemacht; geiirt irgendwo...). Sie kann sich erheblich von der aktuellen Version unterscheiden.

Letzter Kommentar: vor 3 Jahren von קיפודנחש in Abschnitt y1 mishandles missing values

Fehler in Modul?

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

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

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:

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

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.

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="/media/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

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:

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

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

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

showSymbols doesn't respect opacity values

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).

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

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?

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

(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

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.

--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

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

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

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!
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:
Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!
The RedBurn (ϕ) 00:11, 10. Sep. 2020 (CEST)Beantworten

Offene Sichtung? (Bitte um Sichtung)

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

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

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

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

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:

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

same graph, transposing y1 and y2:

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

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:

Hier fehlt eine Grafik, die leider im Moment aus technischen Gründen nicht angezeigt werden kann. Wir arbeiten daran!

peace - קיפודנחש (Diskussion) 02:44, 20. Mär. 2022 (CET)Beantworten