Wikiup Diskussion:Lua/Modul/Graph
Fehler in Modul?
<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"Jahreszahl ???","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":2000},{"y":188306,"series":"y","x":2001},{"y":91471,"series":"y","x":2002},{"y":67848,"series":"y","x":2003},{"y":50152,"series":"y","x":2004},{"y":42908,"series":"y","x":2005},{"y":30100,"series":"y","x":2006},{"y":30303,"series":"y","x":2007},{"y":28018,"series":"y","x":2008},{"y":33033,"series":"y","x":2009},{"y":48589,"series":"y","x":2010},{"y":53347,"series":"y","x":2011},{"y":77651,"series":"y","x":2012},{"y":127023,"series":"y","x":2013}]}],"width":500}</graph> <graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"area","properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"interpolate":{"value":"monotone"},"y2":{"scale":"y","value":0},"x":{"scale":"x","field":"x"},"fill":{"scale":"color","field":"series"}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"Jahreszahl ???","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":2000},{"y":188306,"series":"y","x":2001},{"y":91471,"series":"y","x":2002},{"y":67848,"series":"y","x":2003},{"y":50152,"series":"y","x":2004},{"y":42908,"series":"y","x":2005},{"y":30100,"series":"y","x":2006},{"y":30303,"series":"y","x":2007},{"y":28018,"series":"y","x":2008},{"y":33033,"series":"y","x":2009},{"y":48589,"series":"y","x":2010},{"y":53347,"series":"y","x":2011},{"y":77651,"series":"y","x":2012},{"y":127023,"series":"y","x":2013}]}],"width":500}</graph> <graph>{"legends":[],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"padding":0.2,"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"rect","properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","value":0},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"Jahreszahl","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":2000},{"y":188306,"series":"y","x":2001},{"y":91471,"series":"y","x":2002},{"y":67848,"series":"y","x":2003},{"y":50152,"series":"y","x":2004},{"y":42908,"series":"y","x":2005},{"y":30100,"series":"y","x":2006},{"y":30303,"series":"y","x":2007},{"y":28018,"series":"y","x":2008},{"y":33033,"series":"y","x":2009},{"y":48589,"series":"y","x":2010},{"y":53347,"series":"y","x":2011},{"y":77651,"series":"y","x":2012},{"y":127023,"series":"y","x":2013}]}],"width":500}</graph>
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)
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)
- 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)
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:
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)
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="//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)
- 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)
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: <graph>{"legends":[{"properties":{"legend":{"y":{"value":-100}},"title":{"fill":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"stroke":"color","title":"Sehr lange Legende\nüber zwei Zeilen","fill":"color"}],"scales":[{"domain":{"data":"chart","field":"x"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"arc","properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"x"}},"enter":{"endAngle":{"field":"layout_end"},"innerRadius":{"value":0},"outerRadius":{"value":100},"startAngle":{"field":"layout_start"},"stroke":{"value":"white"},"fill":{"scale":"color","field":"x"},"strokeWidth":{"value":1}}},"from":{"data":"chart","transform":[{"type":"pie","field":"y"}]}}],"height":100,"axes":[],"data":[{"format":{"parse":{"y":"integer","x":"string"},"type":"json"},"name":"chart","values":[{"y":2,"x":"a"},{"y":3,"x":"b"},{"y":4,"x":"c"}]}],"width":100}</graph> Kann das möglicherweise leicht repariert werden? Das wäre schön. --dingensfünf 14:36, 19. Jul. 2019 (CEST)
- 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)
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))
- 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)
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). <graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["#ff0000"]},{"type":"ordinal","name":"transparency","range":["0.25098039215686"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"strokeOpacity":{"scale":"transparency"},"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}},{"type":"symbol","properties":{"enter":{"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":0},"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"strokeOpacity":{"scale":"transparency","field":"series"},"size":{"value":50},"fillOpacity":{"scale":"transparency","field":"series"},"shape":{"value":"circle"},"fill":{"scale":"color","field":"series"}}},"from":{"data":"chart"}}],"height":150,"axes":[{"type":"x","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":10,"series":"y","x":1},{"y":12,"series":"y","x":2},{"y":6,"series":"y","x":3},{"y":14,"series":"y","x":4},{"y":2,"series":"y","x":5},{"y":10,"series":"y","x":6},{"y":7,"series":"y","x":7},{"y":9,"series":"y","x":8}]}],"width":400}</graph> Alex 21 (Diskussion) 11:41, 22. Sep. 2019 (CEST)
- Any thoughts? Alex 21 (Diskussion) 04:10, 4. Okt. 2019 (CEST)
- 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)
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)
<graph>{"legends":[],"scales":[{"type":"ordinal","name":"x","domain":{"data":"chart","field":"x"},"padding":0.2,"range":"width","zero":false},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"rect","properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","value":0},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"type=rect -> Jahreszahl als Integer???","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"date"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":"2000"},{"y":188306,"series":"y","x":"2001"},{"y":91471,"series":"y","x":"2002"},{"y":67848,"series":"y","x":"2003"},{"y":50152,"series":"y","x":"2004"},{"y":42908,"series":"y","x":"2005"},{"y":30100,"series":"y","x":"2006"},{"y":30303,"series":"y","x":"2007"},{"y":28018,"series":"y","x":"2008"},{"y":33033,"series":"y","x":"2009"},{"y":48589,"series":"y","x":"2010"},{"y":53347,"series":"y","x":"2011"},{"y":77651,"series":"y","x":"2012"},{"y":127023,"series":"y","x":"2013"}]}],"width":500}</graph> <graph>{"legends":[],"scales":[{"type":"time","name":"x","domain":{"data":"chart","field":"x"},"range":"width","zero":false},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"type=line -> Jahreszahl wie sie sein soll","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"date"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":"2000"},{"y":188306,"series":"y","x":"2001"},{"y":91471,"series":"y","x":"2002"},{"y":67848,"series":"y","x":"2003"},{"y":50152,"series":"y","x":"2004"},{"y":42908,"series":"y","x":"2005"},{"y":30100,"series":"y","x":"2006"},{"y":30303,"series":"y","x":"2007"},{"y":28018,"series":"y","x":"2008"},{"y":33033,"series":"y","x":"2009"},{"y":48589,"series":"y","x":"2010"},{"y":53347,"series":"y","x":"2011"},{"y":77651,"series":"y","x":"2012"},{"y":127023,"series":"y","x":"2013"}]}],"width":500}</graph>
- 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) - <graph>{"legends":[],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"padding":0.2,"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":"category10"}],"version":2,"marks":[{"type":"rect","properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","value":0},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"type=rect -> Jahreszahl als String","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":117648,"series":"y","x":2000},{"y":188306,"series":"y","x":2001},{"y":91471,"series":"y","x":2002},{"y":67848,"series":"y","x":2003},{"y":50152,"series":"y","x":2004},{"y":42908,"series":"y","x":2005},{"y":30100,"series":"y","x":2006},{"y":30303,"series":"y","x":2007},{"y":28018,"series":"y","x":2008},{"y":33033,"series":"y","x":2009},{"y":48589,"series":"y","x":2010},{"y":53347,"series":"y","x":2011},{"y":77651,"series":"y","x":2012},{"y":127023,"series":"y","x":2013}]}],"width":500}</graph>
- 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)
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)
- 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)
- I agree too. Toohool (Diskussion) 00:12, 8. Apr. 2020 (CEST)
- I agree. --Birger (Diskussion) 07:05, 8. Apr. 2020 (CEST)
- Same here, cc0 is fine )) --Yurik (Diskussion) 06:33, 17. Apr. 2020 (CEST)
- I agree. Tom.Reding (Diskussion) 13:29, 17. Apr. 2020 (CEST)
- I agree. -- Leoncastro (Diskussion) 14:54, 17. Apr. 2020 (CEST)
- 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)
- 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)
- I agree to CC0. Toohool (Diskussion) 22:53, 19. Apr. 2020 (CEST)
- 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)
- I agree with you, but an admin on enwikinews doesn't, and wanted to be sure --DannyS712 (Diskussion) 00:32, 20. Apr. 2020 (CEST)
- Leoncastro just to be clear, you agree to CC0? --DannyS712 (Diskussion) 12:10, 20. Apr. 2020 (CEST)
- @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)
- I agree to CC0. Tom.Reding (Diskussion) 11:35, 20. Apr. 2020 (CEST)
- I agree to CC0. --Yair rand (Diskussion) 05:23, 27. Apr. 2020 (CEST)
- I agree to CC0. --Mps、かみまみたDisk. 15:48, 3. Mai 2020 (CEST)
- I agree to CC0. --Birger (Diskussion) 08:44, 9. Jun. 2020 (CEST)
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)
- 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)
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)
- I added them at diff. Please update Modul:Graph.--Jura1 (Diskussion) 15:55, 7. Jun. 2020 (CEST)
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)
<graph>{"legends":[],"scales":[{"type":"time","name":"x","domain":{"data":"chart","field":"x"},"range":"width","zero":false},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"Datum","scale":"x","format":"%e %B","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":true},{"type":"y","title":"Nieuwe besmettingen per dag","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":true}],"data":[{"format":{"parse":{"y":"integer","x":"date"},"type":"json"},"name":"chart","values":[{"y":3,"series":"y","x":"2020/02/27"},{"y":4,"series":"y","x":"2020/02/28"},{"y":12,"series":"y","x":"2020/02/29"},{"y":13,"series":"y","x":"2020/03/01"},{"y":48,"series":"y","x":"2020/03/02"},{"y":40,"series":"y","x":"2020/03/03"},{"y":41,"series":"y","x":"2020/03/04"},{"y":41,"series":"y","x":"2020/03/05"},{"y":33,"series":"y","x":"2020/03/06"},{"y":45,"series":"y","x":"2020/03/07"},{"y":71,"series":"y","x":"2020/03/08"},{"y":77,"series":"y","x":"2020/03/09"},{"y":137,"series":"y","x":"2020/03/10"},{"y":172,"series":"y","x":"2020/03/11"},{"y":183,"series":"y","x":"2020/03/12"},{"y":218,"series":"y","x":"2020/03/13"},{"y":221,"series":"y","x":"2020/03/14"},{"y":233,"series":"y","x":"2020/03/15"},{"y":272,"series":"y","x":"2020/03/16"},{"y":375,"series":"y","x":"2020/03/17"},{"y":459,"series":"y","x":"2020/03/18"},{"y":515,"series":"y","x":"2020/03/19"},{"y":700,"series":"y","x":"2020/03/20"},{"y":667,"series":"y","x":"2020/03/21"},{"y":542,"series":"y","x":"2020/03/22"},{"y":622,"series":"y","x":"2020/03/23"},{"y":1128,"series":"y","x":"2020/03/24"},{"y":1053,"series":"y","x":"2020/03/25"},{"y":1056,"series":"y","x":"2020/03/26"},{"y":1193,"series":"y","x":"2020/03/27"},{"y":992,"series":"y","x":"2020/03/28"},{"y":748,"series":"y","x":"2020/03/29"},{"y":807,"series":"y","x":"2020/03/30"},{"y":1132,"series":"y","x":"2020/03/31"},{"y":1044,"series":"y","x":"2020/04/01"},{"y":1034,"series":"y","x":"2020/04/02"},{"y":1230,"series":"y","x":"2020/04/03"},{"y":1098,"series":"y","x":"2020/04/04"},{"y":855,"series":"y","x":"2020/04/05"},{"y":775,"series":"y","x":"2020/04/06"},{"y":1089,"series":"y","x":"2020/04/07"},{"y":1351,"series":"y","x":"2020/04/08"},{"y":1315,"series":"y","x":"2020/04/09"},{"y":1392,"series":"y","x":"2020/04/10"},{"y":1048,"series":"y","x":"2020/04/11"},{"y":823,"series":"y","x":"2020/04/12"},{"y":755,"series":"y","x":"2020/04/13"},{"y":807,"series":"y","x":"2020/04/14"},{"y":1105,"series":"y","x":"2020/04/15"},{"y":1163,"series":"y","x":"2020/04/16"},{"y":1266,"series":"y","x":"2020/04/17"},{"y":986,"series":"y","x":"2020/04/18"},{"y":615,"series":"y","x":"2020/04/19"},{"y":593,"series":"y","x":"2020/04/20"},{"y":707,"series":"y","x":"2020/04/21"},{"y":967,"series":"y","x":"2020/04/22"},{"y":793,"series":"y","x":"2020/04/23"},{"y":651,"series":"y","x":"2020/04/24"},{"y":569,"series":"y","x":"2020/04/25"},{"y":364,"series":"y","x":"2020/04/26"},{"y":150,"series":"y","x":"2020/04/27"},{"y":18,"series":"y","x":"2020/04/28"}]}],"width":800}</graph>
- 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)
- A workaround is to show the date labels in numbers with
xAxisFormat = %m/%Y
or in this casexAxisFormat = %d/%m
:
- A workaround is to show the date labels in numbers with
- <graph>{"legends":[],"scales":[{"type":"time","name":"x","domain":{"data":"chart","field":"x"},"range":"width","zero":false},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2}}},"from":{"data":"chart"}}],"height":200,"axes":[{"type":"x","title":"Datum","scale":"x","format":"%d/%m","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":true},{"type":"y","title":"Nieuwe besmettingen per dag","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":true}],"data":[{"format":{"parse":{"y":"integer","x":"date"},"type":"json"},"name":"chart","values":[{"y":3,"series":"y","x":"2020/02/27"},{"y":4,"series":"y","x":"2020/02/28"},{"y":12,"series":"y","x":"2020/02/29"},{"y":13,"series":"y","x":"2020/03/01"},{"y":48,"series":"y","x":"2020/03/02"},{"y":40,"series":"y","x":"2020/03/03"},{"y":41,"series":"y","x":"2020/03/04"},{"y":41,"series":"y","x":"2020/03/05"},{"y":33,"series":"y","x":"2020/03/06"},{"y":45,"series":"y","x":"2020/03/07"},{"y":71,"series":"y","x":"2020/03/08"},{"y":77,"series":"y","x":"2020/03/09"},{"y":137,"series":"y","x":"2020/03/10"},{"y":172,"series":"y","x":"2020/03/11"},{"y":183,"series":"y","x":"2020/03/12"},{"y":218,"series":"y","x":"2020/03/13"},{"y":221,"series":"y","x":"2020/03/14"},{"y":233,"series":"y","x":"2020/03/15"},{"y":272,"series":"y","x":"2020/03/16"},{"y":375,"series":"y","x":"2020/03/17"},{"y":459,"series":"y","x":"2020/03/18"},{"y":515,"series":"y","x":"2020/03/19"},{"y":700,"series":"y","x":"2020/03/20"},{"y":667,"series":"y","x":"2020/03/21"},{"y":542,"series":"y","x":"2020/03/22"},{"y":622,"series":"y","x":"2020/03/23"},{"y":1128,"series":"y","x":"2020/03/24"},{"y":1053,"series":"y","x":"2020/03/25"},{"y":1056,"series":"y","x":"2020/03/26"},{"y":1193,"series":"y","x":"2020/03/27"},{"y":992,"series":"y","x":"2020/03/28"},{"y":748,"series":"y","x":"2020/03/29"},{"y":807,"series":"y","x":"2020/03/30"},{"y":1132,"series":"y","x":"2020/03/31"},{"y":1044,"series":"y","x":"2020/04/01"},{"y":1034,"series":"y","x":"2020/04/02"},{"y":1230,"series":"y","x":"2020/04/03"},{"y":1098,"series":"y","x":"2020/04/04"},{"y":855,"series":"y","x":"2020/04/05"},{"y":775,"series":"y","x":"2020/04/06"},{"y":1089,"series":"y","x":"2020/04/07"},{"y":1351,"series":"y","x":"2020/04/08"},{"y":1315,"series":"y","x":"2020/04/09"},{"y":1392,"series":"y","x":"2020/04/10"},{"y":1048,"series":"y","x":"2020/04/11"},{"y":823,"series":"y","x":"2020/04/12"},{"y":755,"series":"y","x":"2020/04/13"},{"y":807,"series":"y","x":"2020/04/14"},{"y":1105,"series":"y","x":"2020/04/15"},{"y":1163,"series":"y","x":"2020/04/16"},{"y":1266,"series":"y","x":"2020/04/17"},{"y":986,"series":"y","x":"2020/04/18"},{"y":615,"series":"y","x":"2020/04/19"},{"y":593,"series":"y","x":"2020/04/20"},{"y":707,"series":"y","x":"2020/04/21"},{"y":967,"series":"y","x":"2020/04/22"},{"y":793,"series":"y","x":"2020/04/23"},{"y":651,"series":"y","x":"2020/04/24"},{"y":569,"series":"y","x":"2020/04/25"},{"y":364,"series":"y","x":"2020/04/26"},{"y":150,"series":"y","x":"2020/04/27"},{"y":18,"series":"y","x":"2020/04/28"}]}],"width":800}</graph>
- The RedBurn (ϕ) 00:11, 10. Sep. 2020 (CEST)
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)
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)
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)
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)
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:
<graph>{"legends":[{"properties":{"title":{"fill":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"stroke":"color","title":"legend","fill":"color"}],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"stats","field":"sum_y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["orange","green","blue"]}],"version":2,"marks":[{"type":"group","marks":[{"properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"layout_start"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","field":"layout_end"},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"type":"rect"}],"from":{"data":"chart","transform":[{"field":"y","type":"stack","sortby":["-_id"],"groupby":["x"]},{"groupby":["series"],"type":"facet"}]}}],"height":100,"axes":[{"type":"x","title":"crews","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"budget","scale":"y","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"number","x":"string"},"type":"json"},"name":"chart","values":[{"y":100,"series":"bribes","x":"one"},{"y":100,"series":"bribes","x":"five"},{"y":140,"series":"bribes","x":"six"},{"y":70,"series":"bribes","x":"seven"},{"y":95,"series":"labor","x":"one"},{"y":245.1,"series":"labor","x":"two"},{"y":336,"series":"labor","x":"three"},{"y":180,"series":"labor","x":"four"},{"y":180,"series":"labor","x":"five"},{"y":180,"series":"labor","x":"six"},{"y":202,"series":"labor","x":"seven"},{"y":152,"series":"materials","x":"one"},{"y":265.5,"series":"materials","x":"two"},{"y":376,"series":"materials","x":"three"},{"y":253,"series":"materials","x":"four"},{"y":253,"series":"materials","x":"five"},{"y":253,"series":"materials","x":"six"},{"y":353,"series":"materials","x":"seven"}]},{"transform":[{"type":"aggregate","summarize":{"y":"sum"},"groupby":["x"]}],"name":"stats","source":"chart"}],"width":300}</graph>
same graph, transposing y1 and y2:
<graph>{"legends":[{"properties":{"title":{"fill":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"stroke":"color","title":"legend","fill":"color"}],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"stats","field":"sum_y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green","orange","blue"]}],"version":2,"marks":[{"type":"group","marks":[{"properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"layout_start"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","field":"layout_end"},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"type":"rect"}],"from":{"data":"chart","transform":[{"field":"y","type":"stack","sortby":["-_id"],"groupby":["x"]},{"groupby":["series"],"type":"facet"}]}}],"height":100,"axes":[{"type":"x","title":"crews","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"budget","scale":"y","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"number","x":"string"},"type":"json"},"name":"chart","values":[{"y":95,"series":"labor","x":"one"},{"y":245.1,"series":"labor","x":"two"},{"y":336,"series":"labor","x":"three"},{"y":180,"series":"labor","x":"four"},{"y":180,"series":"labor","x":"five"},{"y":180,"series":"labor","x":"six"},{"y":202,"series":"labor","x":"seven"},{"y":100,"series":"bribes","x":"one"},{"y":100,"series":"bribes","x":"five"},{"y":140,"series":"bribes","x":"six"},{"y":70,"series":"bribes","x":"seven"},{"y":152,"series":"materials","x":"one"},{"y":265.5,"series":"materials","x":"two"},{"y":376,"series":"materials","x":"three"},{"y":253,"series":"materials","x":"four"},{"y":253,"series":"materials","x":"five"},{"y":253,"series":"materials","x":"six"},{"y":353,"series":"materials","x":"seven"}]},{"transform":[{"type":"aggregate","summarize":{"y":"sum"},"groupby":["x"]}],"name":"stats","source":"chart"}],"width":300}</graph>
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: <graph>{"legends":[{"properties":{"title":{"fill":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"stroke":"color","title":"legend","fill":"color"}],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"stats","field":"sum_y"},"zero":true,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["orange","green","blue"]}],"version":2,"marks":[{"type":"group","marks":[{"properties":{"hover":{"fill":{"value":"red"}},"update":{"fill":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"layout_start"},"x":{"scale":"x","field":"x"},"y2":{"scale":"y","field":"layout_end"},"width":{"scale":"x","offset":-1,"band":true},"fill":{"scale":"color","field":"series"}}},"type":"rect"},{"properties":{"enter":{"baseline":{"value":"middle"},"align":{"value":"left"},"text":{"field":"y"},"y":{"scale":"y","offset":-5,"field":"layout_start"},"dy":{"scale":"x","mult":0.5,"band":true},"x":{"scale":"x","field":"x"},"angle":{"value":-90},"fontSize":{"value":11},"fill":{"value":"black"}}},"type":"text"}],"from":{"data":"chart","transform":[{"field":"y","type":"stack","sortby":["-_id"],"groupby":["x"]},{"groupby":["series"],"type":"facet"}]}}],"height":100,"axes":[{"type":"x","title":"crews","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"budget","scale":"y","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"number","x":"string"},"type":"json"},"name":"chart","values":[{"y":100,"series":"bribes","x":"one"},{"y":0,"series":"bribes","x":"two"},{"y":0,"series":"bribes","x":"three"},{"y":0,"series":"bribes","x":"four"},{"y":0,"series":"bribes","x":"five"},{"y":100,"series":"bribes","x":"six"},{"y":140,"series":"bribes","x":"seven"},{"y":95,"series":"labor","x":"one"},{"y":45,"series":"labor","x":"two"},{"y":336,"series":"labor","x":"three"},{"y":57,"series":"labor","x":"four"},{"y":180,"series":"labor","x":"five"},{"y":180,"series":"labor","x":"six"},{"y":202,"series":"labor","x":"seven"},{"y":152,"series":"materials","x":"one"},{"y":265.5,"series":"materials","x":"two"},{"y":376,"series":"materials","x":"three"},{"y":253,"series":"materials","x":"four"},{"y":253,"series":"materials","x":"five"},{"y":253,"series":"materials","x":"six"},{"y":353,"series":"materials","x":"seven"}]},{"transform":[{"type":"aggregate","summarize":{"y":"sum"},"groupby":["x"]}],"name":"stats","source":"chart"}],"width":300}</graph> peace - קיפודנחש (Diskussion) 02:44, 20. Mär. 2022 (CET)
Y-Achse rechts — Right-side y-axis
- Click [Ausklappen] for English text. Kopie des ursprünglichen Vorschlags: en:Module talk:Graph#Right-side y-axis.
(toggle English)
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):
- <graph>{"legends":[{"properties":{"title":{"fill":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"stroke":"color","title":"Legend","fill":"color"}],"scales":[{"type":"ordinal","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"points":true,"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["#0000aa","#ff8000"]},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"symSize","range":[34]}],"version":2,"marks":[{"type":"group","marks":[{"properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"type":"line"},{"properties":{"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"size":{"scale":"symSize","field":"series"},"fill":{"scale":"color","field":"series"},"stroke":{"scale":"color","field":"series"},"shape":{"value":"circle"},"strokeWidth":{"value":0}}},"type":"symbol"}],"from":{"data":"chart","transform":[{"groupby":["series"],"type":"facet"}]}}],"height":200,"axes":[{"type":"x","title":"","scale":"x","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"align":{"value":"left"},"angle":{"value":45},"fill":{"value":"#54595d"}}},"grid":true},{"type":"y","title":"Anzahl der Artikel – count of articles","scale":"y","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":true}],"data":[{"format":{"parse":{"y":"number","x":"string"},"type":"json"},"name":"chart","values":[{"y":1310,"series":"Waisen – Orphans","x":"May 2021"},{"y":1360,"series":"Waisen – Orphans","x":"Jun"},{"y":1400,"series":"Waisen – Orphans","x":"Jul"},{"y":1390,"series":"Waisen – Orphans","x":"Aug"},{"y":1440,"series":"Waisen – Orphans","x":"Sep"},{"y":1410,"series":"Waisen – Orphans","x":"Oct"},{"y":1420,"series":"Waisen – Orphans","x":"Nov"},{"y":1500,"series":"Waisen – Orphans","x":"Dec"},{"y":1480,"series":"Waisen – Orphans","x":"Jan 2022"},{"y":1520,"series":"Waisen – Orphans","x":"Feb"},{"y":1500,"series":"Waisen – Orphans","x":"Mar"},{"y":1541,"series":"Waisen – Orphans","x":"Apr"},{"y":1455,"series":"1 In-link * 0.3","x":"May 2021"},{"y":1470,"series":"1 In-link * 0.3","x":"Jun"},{"y":1485,"series":"1 In-link * 0.3","x":"Jul"},{"y":1492.5,"series":"1 In-link * 0.3","x":"Aug"},{"y":1515,"series":"1 In-link * 0.3","x":"Sep"},{"y":1530,"series":"1 In-link * 0.3","x":"Oct"},{"y":1575,"series":"1 In-link * 0.3","x":"Nov"},{"y":1584,"series":"1 In-link * 0.3","x":"Dec"},{"y":1590,"series":"1 In-link * 0.3","x":"Jan 2022"},{"y":1650,"series":"1 In-link * 0.3","x":"Feb"},{"y":1656,"series":"1 In-link * 0.3","x":"Mar"},{"y":1662,"series":"1 In-link * 0.3","x":"Apr"}]}],"width":400}</graph>
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:
|yAxis2Max=5800
|yAxis2Min=4200
|yAxis2Title=Anzahl der Artikel – count of articles
|yAxis2Format
|yAxis2Angle
|yGrid2
(toggle English)
{{#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)