Content deleted Content added
→Category: Re |
|||
(182 intermediate revisions by 46 users not shown) | |||
Line 2:
|from= Module:Chart
|from_oldid= 548706161
|to= Module:
|to_diff=548746976
|to_oldid=548745217
}}
{{Copied
|from= Module:Chart
|from_oldid= 548706161
|to= Module:
|to_diff=548770077
|to_oldid=548758346
}}
== Population graph ==
Line 86 ⟶ 91:
{{ Image frame
| content =
<div style="
{{ #invoke:Chart | bar chart
| height = 200
| width = 250
| stack = 1
| tooltip value accumulation = 1
| hide group legends = 1
| group 1 = 40000 : 50000 : 60000 : 20000 : 30000 : 35000
| group 2 = 20000 : 60000 : 12000 : 44000 : 12000 : 20000
Line 102 ⟶ 107:
| x legends = Before : During : After : Post mortem : Blah : Bloh
}}
</div>
| caption = {{nowrap|{{color box|Green|{{Spaces|6}}}} Apple}} {{nowrap|{{color box|Yellow|{{Spaces|6}}}} Banana}} {{nowrap|{{color box|Orange|{{Spaces|6}}}} Orange}}
Line 111 ⟶ 115:
:::::::That, sir, is magnificent. I was just going to give it a border, but {{tlx|Image frame}} is perfect. Thanks for all the help. I've already got the individual chart templates set up, and they transclude data from a data template page, by section, so all I need do is copy the chart templates to '''Template name(s) thumbnail''' and add the formatting. Happy now. Great module, by the way, ideal for this job, in which there will probably be some pies too. Cheers. <span style="font-family:Arial;font-weight:bold;color:#000;">[[User:Begoon|<span style="color:#0645AD;">Begoon</span>]] [[User talk:Begoon|<span style="color:gray;"><sup>talk</sup></span>]]</span> 17:19, 27 June 2013 (UTC)
::::::::maybe it would be better not to copy the data, but rather make the "height" and "width" parameters to your template, and then you can just use it (inside the envelope that thumbinize it) instead of copying the whole thing and tweaking just 2 fields. of course, it is very much possible i just did not fully understand what you said, and this is what you are doing anyway... maybe i just got hooked up on the fact you used the word "copy". peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 18:41, 27 June 2013 (UTC)
:::::::::Yes, I realised that last night after typing that. No point at all in trying to maintain 2 sets of template code, I was thinking (badly) out loud...{{P|4}} Thanks again. <span style="font-family:Arial;font-weight:bold;color:#000;">[[User:Begoon|<span style="color:#0645AD;">Begoon</span>]] [[User talk:Begoon|<span style="color:gray;"><sup>talk</sup></span>]]</span> 04:06, 28 June 2013 (UTC)
::::::::::so i taught chart 2 new tricks: "tooltip value accumulation": this has effect only with "stack", and will cause the tooltip value to display the accumulation of all the block up to the current (including), and "hide group legends" which prevent displaying the group legends below the chart (the 2nd one works for pie chart also). peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 21:30, 28 June 2013 (UTC)
::::::::{{od|2}}Excellent - that's really cool. Both of those were things I was "working around", and now I don't need to. You can take a look at [[User:Begoon/sandbox/casualties]], and the templates it uses if you're interested - but now, thanks to your hard work, I can simplify them a bit. Thanks for letting me know, and thanks for all of your work with [[Module:Chart]] which I think is a great addition to the wiki. Cheers. <span style="font-family:Arial;font-weight:bold;color:#000;">[[User:Begoon|<span style="color:#0645AD;">Begoon</span>]] [[User talk:Begoon|<span style="color:gray;"><sup>talk</sup></span>]]</span> 01:51, 29 June 2013 (UTC)
::::::::@ {{U|קיפודנחש|קיפודנחש}}: One small problem, I think. I'm trying to use {{green|<nowiki>|hide group legends = {{#if:{{{hide group legends|}}}|{{{hide group legends}}}|false}}</nowiki>}}, and I'm pretty sure I'm passing true/false correctly - but it seems once you even specify the parameter at all it evaluates as true, and hides them, even if blank or false ? Or, I'm screwing up and tested it wrong, which is equally possible...
::::::::<small>(tooltip value accumulation seems to behave the same, now I look - didn't notice that because I always pass 'true' to that)</small> <span style="font-family:Arial;font-weight:bold;color:#000;">[[User:Begoon|<span style="color:#0645AD;">Begoon</span>]] [[User talk:Begoon|<span style="color:gray;"><sup>talk</sup></span>]]</span> 05:04, 29 June 2013 (UTC)
'''See this:'''
{|
|-
|
{{ #invoke:Chart | bar chart
| height = 250
| width = 300
| stack = 1
| group 1 = 40 : 50 : 60 : 20
| group 2 = 20 : 60 : 12 : 44
| group 3 = 55 : 14 : 33 : 5
| colors = green : yellow : orange
| group names = Apple : Banana : Orange
| units suffix = Kg
| x legends = Before : During : After : Post mortem
| hide group legends =
| tooltip value accumulation =
}}
|<pre>
{{ #invoke:Chart | bar chart
| height = 250
| width = 300
| stack = 1
| group 1 = 40 : 50 : 60 : 20
| group 2 = 20 : 60 : 12 : 44
| group 3 = 55 : 14 : 33 : 5
| colors = green : yellow : orange
| group names = Apple : Banana : Orange
| units suffix = Kg
| x legends = Before : During : After : Post mortem
| hide group legends =
| tooltip value accumulation =
}}
</pre>
|}
::::::::::you are absolutely correct when you note that the template does not care if you give it a value of "true", "false", "17" or "bla bla bla" - giving these parameters any value at all means "yes". originally, it was "param exists/param does not exist" logic, and did not pay special attention to test for "blank" value, which meant that blank was also treated as "true".
::::::::::this was silly of me, because it makes controlling the bahavior through a parameter to the calling template much more complicated (i am not even sure it it's possible). so i tamed it a little bit to take a blank as "no". i also odified the test above, to demonstrate. any non-blank value still neams "yes", even if it's "false" or "no". peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 13:44, 29 June 2013 (UTC)
:::::::::::That works great - thanks again! Passing a blank for "false" is no problem, and does the job perfectly well. The added functionality to do this tooltip accumulation saves a lot of pre-calculation, or maths in the chart template, and means I can use the default groupname:value tooltips instead of building them and passing them through - very useful. Cheers. {{P}} <span style="font-family:Arial;font-weight:bold;color:#000;">[[User:Begoon|<span style="color:#0645AD;">Begoon</span>]] [[User talk:Begoon|<span style="color:gray;"><sup>talk</sup></span>]]</span> 15:33, 29 June 2013 (UTC)
* Please add an option for this. It's silly to have percentages sum to 150 like [https://en.wikipedia.org/w/index.php?title=DVD&oldid=586047235#Use_as_backup_medium here]. [[User:Someone not using his real name|Someone not using his real name]] ([[User talk:Someone not using his real name|talk]]) 14:34, 14 December 2013 (UTC)
* Also, the option to display the legend as a gradient (instead of bits all over the place) would also be nice. [[User:Someone not using his real name|Someone not using his real name]] ([[User talk:Someone not using his real name|talk]]) 14:37, 14 December 2013 (UTC)
== Units in the chart ==
Hi. Currently the module visualizes units only as tool-tips. is it possible to show the units in the chart (e.g. Y axis in case of the bar chart)? --[[User:Haithams|Haithams]] ([[User talk:Haithams|talk]]) 00:51, 7 November 2013 (UTC)
:there are 2 answers here: the first is that the source for this module is free, and anyone who wishes to improve it can do so. however, the darker side is the fact that some 6 months or so after i created the module, a whooping number of 9 articles use it, so the motivation of investing much more time and effort in this module is not huge. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 04:11, 7 November 2013 (UTC)
:In fact, I'm surprised to know that such a nice module is not as widely used as it should be. FYI, I copied it to metawiki, and I'm starting some efforts to encourage people use it in their reports ... etc [[m:Grants:Learning patterns/Charts on Wiki pages|please see here]]. I would love to improve on the it, but unfortunately I don't have yet enough lua experience to deal with such a complicated module. Perhaps some hints might help! --[[User:Haithams|Haithams]] ([[User talk:Haithams|talk]]) 22:03, 7 November 2013 (UTC)
== Discussion regarding this module ==
There is a discussion involving this module at [[Wikipedia:Village pump (technical)/Archive 121#New column graphs on WP:Wikipedia with dislocated axis labels]], regarding a difficulty with its use on our article about [[Wikipedia]]. – '''[[User:PartTimeGnome|PartTimeGnome]]''' <span style="font-size:79%">([[User talk:PartTimeGnome|talk]] | [[Special:Contributions/PartTimeGnome|contribs]])</span> 01:16, 29 December 2013 (UTC)
==Group name key==
The first entry in the group key is not aligned to the others. On the example shown here "Apple" is higher up than the others. [[User:MRSC|MRSC]] ([[User talk:MRSC|talk]]) 17:30, 24 February 2014 (UTC)
:{{re|MRSC}} i believe this has to do with the way the browser displays lists in columns. i would venture a guess you are using google chrome (try to see if same problem exists with ff, ie or opera)... i think there is a problem in the list columns rendering in this browser. i will try to file in a bug report for google chrome. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 18:00, 24 February 2014 (UTC)
::Bingo! Yes. It renders fine in IE11. Not switching from Chrome, though. Thanks. [[User:MRSC|MRSC]] ([[User talk:MRSC|talk]]) 18:12, 24 February 2014 (UTC)
== [[Module:Plotter/DefaultColors]] ==
Shouldn't this (sub)module be loaded using [[mw:Extension:Scribunto/Lua_reference_manual#mw.loadData|<code>mw.loadData</code>]] instead of <code>require</code>? [[User:Helder.wiki|Helder.wiki]] 15:38, 28 April 2014 (UTC)
:in principle, i think yes. in practice, it doesn't really matter. this module have been there for years, and is used in < 30 articles, and i did not find an article containing more than one chart (did not go through *all* 22 articles using it). feel free to make the modification, though. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 00:23, 29 April 2014 (UTC)
== Line chart option ==
Hi,
I'm wondering if there is any chance of adding a line chart option to this script.
Thanks in advance.
[[Special:Contributions/41.138.237.169|41.138.237.169]] ([[User talk:41.138.237.169|talk]]) 08:21, 19 September 2014 (UTC)
: is there something wrong with [[Template:Line chart]]? [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 14:01, 20 September 2014 (UTC)
::{{re|Frietjes}} unfortunately, yes. this template is very impressive, but the limitations of templating system makes it difficult to use: specifically having to pass the parameters as "S12V37 = 44" makes it not editor-friendly. Lua can help alleviate this difficulty - see how more convenient it is to fill in the values for this module ( 44 : 46 : 48 : 12 vs. "S02V01 = 44 | S02V02 = 46 | S02V03 = 48 | S02V04 = 12") the module even lets you copy values ''almost'' directly from a spreadsheet (you'll need to "export" it to [[Comma-separated values|CSV]] format), simply by setting the "delimiter" to comma. please see [[Wikipedia:Lua requests#overhaul Module:Chart]]. also, the template code is so complex that it's practically unmaintainable - for instance, see [[Special:diff/585979493|this attempt]], while the module doesn't really care: the same code handles a single data series with 3 values, or 57 series with 82 values each. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 23:02, 22 September 2014 (UTC)
::Now there is: it was killed. Fortunately survived by {{tl|Graph}}, which does line charts too. [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 01:03, 20 May 2021 (UTC)
== Legend ==
These are really great functions. But I do have a problem with the legend area:
* for pie chart, the whole legend area is limited to the size of the pie, and changing it is only possible through {{para|radius}}. In addition, long texts don't wrap well. Take a look [https://en.wikipedia.org/w/index.php?title=Batuan,_Bohol&oldid=632013743#Barangays here] – the text is at 88% size, and the radius is increased to 110 from normal 105. Or [https://en.wikipedia.org/w/index.php?title=Sikatuna,_Bohol&oldid=631737446#Barangays here] where it's normal size but wraps. Wraps badly. Is there any possibility of parameterising the legend area, or forming it into a table?
* for (stacked) bar chart, there is a lot of white space to the left of the y-axis, and between the x-axis and the actual legend. [https://en.wikipedia.org/w/index.php?title=Bantayan_Island&oldid=632411265 see here]. Can something be done about that? Also, the graphic is tight against the right edge of its container, and doesn't seem to want to shift.
[[:en:User:Unbuttered Parsnip|<span style="color:slategray">Unbuttered parsnip</span>]] ([[:en:User talk:Unbuttered Parsnip|talk]]) mytime= Tue 21:04, wikitime= 13:04, 4 November 2014 (UTC)
: the gap between the chart and the legend, comes from the <code>chartHeight</code>, which in that case is set to be 80 less than the height. some positive value is needed here to prevent the xaxis labels from overlapping the legend, but it could probably be variable. I put a simple hack in the sandbox which allows for some variability. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 19:43, 4 November 2014 (UTC)
::the reason for the large gap (same goes for the one to the left of the Y axis) is that the legend can wrap, and the module does not really know if it will or won't, so i left (if i remember correctly) about 3 lines worth of gap for wrapping. similarly, the module has hard time calculating how many pixels do the Y-legends occupy.
::it makes sense to allow this to be fed in as optional parameters, but some caution should be used, as this may be browser dependent, so the editor may be perfectly happy with the result, but it will still like crap for some readers, possibly having x-axis legends overlap the group legends, or y-axis legends either overflow to the left, or get its significant part truncated (so "1,000,000", "1,500,000" and "2,000,000" all get truncated to "00,000").
::this is an in-built weakness of this way of plotting charts - the module has to use "absolute" positioning of various things (such as the bars, the axes, and the legends), but does not have the intelligence (or knowledge) the browser has regarding physical sizes of text strings.
::i think the idea behind this module is a good one, but i'm not too happy with the implementation: it would have been better to consume the parameters in a similar way to this module, which i think is more convenient and natural than most "chart" templates, and then translate it to [[mw:Extension:EasyTimeline|Extension:EasyTimeline]] construct. this may not be feasible for the piechart (easytimeline does not support piechart, even though the plotting software behind it does), but at least for bar chart i think easytimeline is better choice than the way the chart is built currently. see [[Wikipedia:Lua requests#overhaul Module:Chart]]. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 20:40, 4 November 2014 (UTC)
== Help needed: pie chart doesn't work in Wikidata ==
I have tried to import this module and import it in Wikidata, but somehow, the pie chart does not work in Wikidata. See [[:d:User:Zolo/Wikipedia content]]. When previewed in en.wikipedia, the page shows correctly, but on Wikidata, the pie pieces are wrongly sized. Can that be a CSS issue or something ? --[[User:Zolo|Zolo]] ([[User talk:Zolo|talk]]) 10:20, 2 June 2015 (UTC)
:There is a new tool at [[:mw:Extension:Graph]] that can generate attractive graphs—it should be already available at Wikidata. I'm just letting you know about the extension because it has great potential, but I think you would need to produce about 100 graphs to make figuring out how to use it worthwhile. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 12:00, 2 June 2015 (UTC)
::Ok thanks, I'll try to have a look at it. Actually, as far as my immediate issue is concerned it was just because it needed the "transborder" class, I could have look better before asking.. --[[User:Zolo|Zolo]] ([[User talk:Zolo|talk]]) 12:33, 2 June 2015 (UTC)
:::{{Reply to|Zolo}} using the graph tag is probably the better course of action, but in the meantime, i looked in [[:d:User:Zolo/Wikipedia content]], and did not understand the problem. what do you mean "pie pieces are wrongly sized"? what do you expect to see, and what do you see? peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 17:36, 3 June 2015 (UTC)
::::{{Reply to|קיפודנחש}} without the "transborder" class in the CSS, pie charts were odd-shaped, with broken lines. It works now, thanks. --[[User:Zolo|Zolo]] ([[User talk:Zolo|talk]]) 10:57, 8 June 2015 (UTC)
== Mobile wikipedia bar chart presentation terrible ==
I've used the bar chart version to nice effect (after careful sizing of width and height). But quite some time later I was horrified to see the dreadful presentation on mobile Wikipedia in a high usage article, [https://en.m.wikipedia.org/w/index.php?title=Jeremy_Corbyn&oldid=731595817#Growth_in_the_Labour_Party see here]. The x legends are presented vertically rather than horiz, and overlap the article text - so the legend is unreadable and the article text messed up. Can anyone suggest a fix? Otherwise I think I will have no choice but to go back to less flexible .png charts. Thanks. [[User:Rwendland|Rwendland]] ([[User talk:Rwendland|talk]]) 16:02, 26 July 2016 (UTC)
: [[User:Rwendland|Rwendland]], try asking at [[WP:VPT]]. there are some CSS experts who could probably help. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 15:04, 9 September 2016 (UTC)
::This is discussed at [[Wikipedia:Village pump (technical)##invole:Chart looks terrible in mobile Wikipedia]]. By the way, "Should be exatly" should be "Should be exactly". [[User:PrimeHunter|PrimeHunter]] ([[User talk:PrimeHunter|talk]]) 11:39, 17 May 2017 (UTC)
== Adding wikicode/links to "x legends" ==
In the docs, it says "x legends" supports wikicode such as links to internal pages. But when I use a legend like "User:AbdealiJK/some/page" it things the color character ":" means that the next legend has started. And this gives me a lisp error saying: X legends expect N values only. How do I add links with a colon ? I tried escaping it with \ and also surrounding the wikicode with double quotes, neither worked.
--[[User:AbdealiJK|AbdealiJK]] ([[User talk:AbdealiJK|talk]]) 11:18, 11 August 2016 (UTC)
:# this module was created long before the graph extension was added to WP. i strongly recommend to switch from using this module to the more "modern" use of the graph extension. there are several modules and templates that help using it, such that it's as easy, if not easier, to create graphs and charts than with this module, and it's "the right thing to do" (tm).
:# however, this module solves this specific problem by allowing you to use an alternative delimiter: pass a "delimiter" parameter which does not appear in any of the values. it can be as simple as :: instead of : , or practically anything else - you can use &, *, #, the word "DELIM", the Arabic letter ث, the Khmer character ឃ - whatever your heart desires.
: HTH. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 18:05, 11 August 2016 (UTC)
== Dot plot ==
I was looking at [[Ariane 5#Statistics]] and thought a [[Dot plot (statistics)|dot plot]]-like graph would be more appropriate (very few units). — [[User:Dispenser|Dispenser]] 01:13, 2 February 2017 (UTC)
== Accessibility ==
The bar graphs should include a border. This would make it work with the Firefox extension [https://addons.mozilla.org/en-US/firefox/addon/blank-your-monitor-easy-readin/ Blank Your Monitor] and improve printing where <code>background-color</code> is removed (lots of websites were white-on-black 20 years ago). — [[User:Dispenser|Dispenser]] 01:20, 2 February 2017 (UTC)
: Firefox/Pale Moon will override authored colors when using High Contrast themes. [https://support.mozilla.org/en-US/kb/change-fonts-and-colors-websites-use#w_change-font-color Colors options dialogue]. — [[User:Dispenser|Dispenser]] 16:05, 29 June 2017 (UTC)
== Drop shadows ==
Could we get rid of the drop shadows? They make the charts look so Microsoft Excel 95. [[User:Kaldari|Kaldari]] ([[User talk:Kaldari|talk]]) 07:16, 23 February 2017 (UTC)
:{{re|Kaldari}} K. also, feel free tomake any other changes you see fit. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 15:33, 24 February 2017 (UTC)
:: I've reverted it since it made the [[#Accessibility|bad printing situation]] (browser hide background colors to save ink) even worse. — [[User:Dispenser|Dispenser]] 03:08, 4 March 2017 (UTC)
::: I've added a 1px border (should help with accessibility) and force background-color printing on Safari/Chrome. — [[User:Dispenser|Dispenser]] 19:56, 4 March 2017 (UTC)
::::Thanks for adding the border. It looks like that alleviates the need for the drop shadow. Also, I tried various charts under Blank Your Monitor and it looks like the drop shadow is invisible when the monitor is blanked via BYM anyway (and unfortunately all the color data is lost). One other issue I noticed with the drop shadows is that the renderer creates a drop shadow even when there isn't a bar (i.e. the value is 0), so it's just a shadow of nothing. See [[Exploration of Mars#Yearly statistics]] for example. [[User:Kaldari|Kaldari]] ([[User talk:Kaldari|talk]]) 09:11, 11 March 2017 (UTC)
== Y scale ==
Feature request: influencing the Y scale.
See [[List of Proton launches]]. The chart is an integer count of rocket launches, but the Y scale puts tick marks and labels at a useless “2.5” interval. It would be nice to have any way at all to influence the Y scale, by setting some factor. For example, any one of these might be helpful:
* y interval
* y no. of subdivisions
* y no. secondary subdivisions (tick marks without a label)
* y max
* y integers only
''—[[User:Mzajac |Michael]] [[User talk:Mzajac |Z.]] <small>2017-03-30 15:07 z</small>''
:+1 for this request, especially forcing integers. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 00:51, 19 August 2017 (UTC)
:: {{U|Mzajac}}, try {{para|y tick marks|5}} or some other positive integer value. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 20:06, 5 June 2019 (UTC)
::* "y tick marks" works to avoid decimal intervals (once you know it), but can need changing as the numbers change.
::: Currently the y axis jumps from 10->15, 20->30, and 100->150 as numbers increase. 10->12->15 & 20->24->30 etc would be nice.
::: y_interval would solve most problems and be easier to manage. Otherwise y_integers (rounding interval up ?) would help.
::: - [[User:Rod57|Rod57]] ([[User talk:Rod57|talk]]) 18:07, 3 January 2024 (UTC)
== Stacked Bar Charts with zero values display a single line of colour instead of nothing. ==
See [[List_of_Falcon_9_and_Falcon_Heavy_launches#Launch_statistics]] for an example of this. There seems to be a bug here that displays a single line of colour even when the value input is zero for the given field. This makes the Charts look rather amaturish and unprofessional. Is there an easy fix for this or not? — '''''<small>[[User:Insertcleverphrasehere|Insert]][[Special:Contributions/Insertcleverphrasehere|CleverPhrase]][[User talk:Insertcleverphrasehere|Here]]</small>''''' 07:30, 26 June 2017 (UTC)
:thanks. {{fixed}}. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 23:34, 28 June 2017 (UTC)
::Nice work! — '''''<small>[[User:Insertcleverphrasehere|Insert]][[Special:Contributions/Insertcleverphrasehere|CleverPhrase]][[User talk:Insertcleverphrasehere|Here]]</small>''''' 00:12, 29 June 2017 (UTC)
== Title ==
This chart thing needs a title parameter. There is no way to add a title to the charts!--[[Special:Contributions/200.223.199.146|200.223.199.146]] ([[User talk:200.223.199.146|talk]]) 13:49, 27 June 2017 (UTC)
:there are too many stylistic options/possibilities for title. it's best left to the template invoking this module. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 23:35, 28 June 2017 (UTC)
== Negative values in bar charts ==
Bars are not drawn properly when a chart includes negative values. Example, trying to graph the GDP growth for the [[Economy of Russia]] article:
{{ #invoke:Chart | bar chart
| float = center
| width = 800
| height = 400
| stack = 1
| group 1 = 6.4 : 10.0 : 5.1 : 4.7 : 7.3 : 7.2 : 6.4 : 8.2 : 8.5 : 5.2 : 0 : 4.5 : 4.3 : 3.4 : 1.3 : 0.7 : 0 : 0 : 1.5
| group 2 = 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : -7.8 : 0 : 0 : 0 : 0 : 0 : -3.7 : -0.6 : 0
| colors = ForestGreen : FireBrick
| group names = Growth : Recession
| units suffix = %
| x legends = '99 : 2000 :: 2002 :: 2004 :: 2006 :: 2008 :: 2010 :: 2012 :: 2014 :: 2016 : '17
}}
{{ping|קיפודנחש}} Could you possibly take a look? — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 00:44, 19 August 2017 (UTC)
:{{re|JFG}} sorry. currently this module does not support bar-graphs with base (i.e., y-value of x-axis) other than 0, or negative y-values. i will repeat what i wrote above: this module was written before the "graph" extension was included in wikipedia (maybe even before the extension was written), so it was justified. nowadays, when we have graph extension, i do not see any justification of using it - it is here b/c some articles are using it, but any new graph should use the graph extension (see [[Module:Graph]]). of course, if someone chooses to further enhance this module they are welcome, but i do not think i will do any more work on it, short of fixing clear and blatant bugs. i do not consider this deficiency (not supporting negative values) to qualify.
:it is somewhat unfortunate that the "graph" module documentation is lacking, and has no examples, but it's not enough to justify using this obsolete module. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 19:58, 21 August 2017 (UTC)
::(added later): actually, there are some nice documentation and examples in [[Template:Graph:Chart]], so maybe my criticism of the documentation in the module is not justified. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 20:12, 21 August 2017 (UTC)
:::Well, I've used both, and I much prefer this module to the standard graph extension. The syntax is much simpler to handle for updates, and the output quality is better in my opinion. I'd be glad to help fixing some issues. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 21:04, 21 August 2017 (UTC)
== Whole numbers in bar chart Y axis. ==
See [[List_of_Falcon_9_and_Falcon_Heavy_launches#Launch_statistics]]. It is very odd that the Y axis displays numbers such as 2.5 and 7.5 in the Y axis, when you can't have half of a launch. I have been struggling to find a way to fix this... is there a way to force whole numbers, or else specify the scale on an axis for a bar chart? — '''''<small>[[User:Insertcleverphrasehere|InsertCleverPhraseHere]] <sup>([[User talk:Insertcleverphrasehere|or here]])</sup></small>''''' 10:54, 20 August 2017 (UTC)
:Feature was requested above at [[#Y scale]]. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 13:47, 20 August 2017 (UTC)
:: {{U|Insertcleverphrasehere}} and {{U|JFG}}, try {{para|y tick marks|5}} or some other positive integer value. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 20:05, 5 June 2019 (UTC)
== Add noresize class alongside chart for better mobile support ==
Many of the graphs are larger than the available space on mobile.
To rectify this, we advise adding a noresize class to the element to add horizontal scrolling.
It's not perfect but it will make the chart readable on mobile. Please let me know if you have any further questions.
[[User:Jdlrobson|Jdlrobson]] ([[User talk:Jdlrobson|talk]]) 21:18, 27 November 2017 (UTC)
[[User:Jdlrobson|Jdlrobson]] ([[User talk:Jdlrobson|talk]]) 21:18, 27 November 2017 (UTC)
== Bar width ==
Does this chart offer the option to determine the bar width [[Template:Bar chart|like this one]]? [[User:Gun Powder Ma|Gun Powder Ma]] ([[User talk:Gun Powder Ma|talk]]) 01:50, 15 December 2017 (UTC)
: afaict, the bar width is semi-automatic depending on the number of bars and the overall width of the chart. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 18:34, 15 December 2017 (UTC)
== Vertical bar chart that can go negative==
We need a vertical bar chart that can go negative. <br>
:[[User:Wikideas1|Wikideas1]] ([[User talk:Wikideas1|talk]]) 09:29, 13 February 2018 (UTC)
::sorry, there is no active development of this module at this time. if anyone wants to take over, they are more than welcome, but i, as the original developer, am unlikely to add features in the foreseeable future. sorry. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 23:51, 13 February 2018 (UTC)
== Horizontal rule ==
Hello. I think that, in the case of the bar chart, it would be pretty useful to add the option for drawing an horizontal rule on a specific value. This way, it would be possible to show many values, one for each month of the year, and then add the year's average as a line. Or even add more than one line! --[[User:MisterSanderson|MisterSanderson]] ([[User talk:MisterSanderson|talk]]) 02:58, 2 May 2018 (UTC)
== Working on a new version without all that extra space ==
Hello. I am working on a new version of the module that would solve the problems with the excessive white space. You can check the current progress at [[Module:Sandbox/Ita140188/chart2]]. I would really appreciate some feedback! Thanks! --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 09:47, 27 July 2018 (UTC)
:{{re|Ita140188}} Thank you very much for this initiative. The output looks much better with legends aligned properly and no waste of space. Super happy you used some of my favorite charts at [[List of Falcon 9 and Falcon Heavy launches#Launch statistics]] as examples. {{p}} — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 12:20, 27 July 2018 (UTC)
::Horizontal space was unnecessary, but I think you should leave some "breathing room" as vertical space. Your current version has the charts glued to the text in section headings. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 12:22, 27 July 2018 (UTC)
::The next option that would be really useful is to specify the desired min/max values for the y axis. At least the max value. Also, avoid showing half-values on the y axis when listing only integer values in the data (happens quite often in rocket launch graphs with a small number of launches per year). Could auto-detect (hard) or use a new {{para|integer|yes}} parameter (easy). — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 12:25, 27 July 2018 (UTC)
:::thanks for taking the time to improve this (almost) abandoned module. notice that in one of the charts (many blue thin bars), the legends got smooshed. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 17:28, 27 July 2018 (UTC)
::::Thank you for all the comments and feedback. This is still a work in progress. For now I worked on dynamic sizing of the width of the y axis and the height of x axis so that there is less empty space. Next step is working out the details of alignment etc. Also, for now it only works with one y-axis (since I've noticed the option for multiple axes is rarely used) and there are still problems with some cases such as the thin blue bars chart. I am not planning to work on the pie chart since it already looks ok on this module in my opinion. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 06:58, 28 July 2018 (UTC)
:::::Didn't even notice there was an option to list multiple y-axes. Perhaps check if it's ever used before investing time in that. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 08:26, 28 July 2018 (UTC)
;Update
I solved the main problems with the x-axis labels and made the spacing better. Note that I removed the notch for the x values since most of the time the chart is used with bars that are wide enough to easily understand at which bar the text refers to (this may be added as an automatic feature when bars are too narrow, like in the last example). I also removed the pie chart and the multiple y-axis from the code to keep it simple. Next steps are the possibility of choosing only integers, allowing for negative values, and maybe min/max values. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 10:10, 29 July 2018 (UTC)
:Very nice, thanks. The ticks on x-axis are often useful, see for example [[Timeline of spaceflight]]. Perhaps add ticks only when some x-legends are empty? (They are often skipped for lack of room to display text, and then the tick helps refer to the proper column). — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 10:46, 29 July 2018 (UTC)
::Agree. I am planning to add them as an automatic feature when bars are too narrow (or in any case with skipped values), and also add a parameter to show/hide them manually. I think this is a better solution than making them always appear as there are so many cases where they are not necessary. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 11:13, 29 July 2018 (UTC)
:::Sounds like a good plan. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 07:27, 30 July 2018 (UTC)
::Also, do you know how to add CSS code to a module (without resorting to clumsy <<nowiki/>style> tags in <<nowiki/>body> or javascript? Certain behaviors cannot be specified inline, such as ":hover". --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 11:16, 29 July 2018 (UTC)
:::With the very newly deployed [[WP:TemplateStyles]], one can use a style sheet in a module/template with <code>frame:extensionTag{ name = 'templatestyles', args = { src = '(css sheet name)'} }</code> [[User:Galobtter|Galobtter]] ([[User talk:Galobtter|pingó mió]]) 12:07, 29 July 2018 (UTC)
::::I'd like to see some more options in the legend, to force single column for example. This would avoid issues like you see with the 'launch sites' graph in the examples, where the vandenberg item wraps over to the next line. — '''''<small>[[User:Insertcleverphrasehere|Insertcleverphrasehere]] <sup>([[User talk:Insertcleverphrasehere|or here]])</sup></small>''''' 12:59, 29 July 2018 (UTC)
:::::{{ping|Galobtter}} Thanks a lot. I am not at all familiar with Lua and its integration with Wikipedia (first time I attempt to code in here). I tried to add what you suggested, but nothing really happens, and apparently now the page is in a category "Pages with TemplateStyles errors". Unfortunately I don't know what the error is. I could not make a CSS document as a subpage of the module since it gets interpreted as a Lua module rather than CSS so I had to link [[User:Ita140188/sandbox/styles.css]]. Maybe that's the problem. Anyway, if anybody could help, it would be much appreciated! Thanks!! --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 13:06, 29 July 2018 (UTC)
::::::You need to create the style in a subpage of a template, since only then is would it be created as a "sanitized-css" that {{tag|templatestyles}} can use. Or you can get an admin to make a subpage of the module into a css page. [[User:Galobtter|Galobtter]] ([[User talk:Galobtter|pingó mió]]) 13:11, 29 July 2018 (UTC)
:::::::{{ping|Galobtter}} Thanks. Now it makes sense. Can it be any page in the template namespace, or does it need to be a subpage of the template that is calling it? --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 13:15, 29 July 2018 (UTC)
::::::::Any page that ends in ".css" in the template namespace should work [[User:Galobtter|Galobtter]] ([[User talk:Galobtter|pingó mió]]) 13:17, 29 July 2018 (UTC)
::::::::You can also move a css page created in the template namespace to your userspace and loading that should also work. [[User:Galobtter|Galobtter]] ([[User talk:Galobtter|pingó mió]]) 13:24, 29 July 2018 (UTC)
:::::::::Thanks, apparently they just created a new sandbox for these cases, check [[Wikipedia talk:TemplateStyles#TemplateStyles in Modules]]. Now it works! --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 07:36, 30 July 2018 (UTC)
:::::{{ping|Insertcleverphrasehere}} Forcing 1 column in the legend can be done easily I think. Other more advanced options are in my opinion unnecessary. One could always disable the legend and make it externally. (trying to keep the module simple) --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 13:08, 29 July 2018 (UTC)
; Update September
Hello {{u|Ita140188}}, I've seen your work until August 6, and it looks to me that you completely fixed the spacing issue for legends, and the integer rounding issue. These features look good to go and replace the module in production. However, the tick marks are missing on tight graphs. Could you restore them? See [[Module:Sandbox/Ita140188/chart2#Test case for numerous narrow columns]]. If it's too complex to decide when to place tick marks and when not to, just leave them always on for now, because that's the way those graphs have been displayed for ever; I don't mind losing some vertical pixels for tick marks. When that's done, I think we can publish the update. Then you are apparently still working on some other features (for examples negative vslues or specifying min/max), but those can wait. Let me know what you think. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 10:39, 5 September 2018 (UTC)
:I am very sorry I put the project on hold since I've been very busy lately. I am planning to continue working on it from next month, I should be able to make a working version by October. The real problem with replacing the current module is that right now people went around the white space by wrapping this module in divs with ad hoc margins. This makes it impossible to just update this module without breaking all the charts. I would suggest creating a new module (Module:Chart2 or similar) and recommending it for future use. With time current instances of the module could be migrated. Also the new module should be tested with different browsers/OS etc. to check for potential problems. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 04:50, 11 September 2018 (UTC)
::Thanks for the update. I don't think we should introduce another module name just because of margin workarounds that have been used on some pages. Better look at the articles where this happens and remove the workarounds. I can help with that. There are less than 500 uses in articles, so it's manageable. I could start working on this while you're busy elsewhere, if only you could restore the tick marks first. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 19:48, 19 September 2018 (UTC)
;Latest update
So, over one year late I finally added the x-axis ticks and added back support for pie charts. I think the new version is now ready to replace the current version. Let me know your thoughts. I also came to the idea that adding other more advanced options is a waste of time, since the approach used in this template (working with DIVs) is really not flexible or scalable at all, and [[Module:Graph]] should be used in the future. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 10:21, 12 February 2020 (UTC)
== Log charts? ==
For some articles like, [[solar power]], [[wind power]] and possibly [[Moore's law]] which are about things that are growing exponentially and are likely to update every year, you'd probably prefer bar and line charts to have the option of having at least a log y-axis. But this doesn't seem possible right now. [[User:GliderMaven|GliderMaven]] ([[User_talk:GliderMaven|talk]]) 01:17, 25 August 2018 (UTC)
:cant recall ever seeing a log bar chart. all the log scale graphs i ever saw were line charts, which is not supported by this module. seems like a sensible idea for [[module:graph]], though. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 13:49, 25 August 2018 (UTC)
::Semilog graphs are rarer than linear anyway, but for things like yearly production of electrical power, which will change from year to year without anyone doing anything, and where there is underlying exponential growth, then a log bar chart seems to be the correct tool. Spreadsheets and matlab support this. Line charts should be used when there's an explicit connection between the data points, like installed power. [[User:GliderMaven|GliderMaven]] ([[User_talk:GliderMaven|talk]]) 17:32, 25 August 2018 (UTC)
== Horizontal bar chart ==
I was looking for a template to render a bar chart horizontally. This is sometimes helpful when there are many items to list, so that the chart can be expanded down the page and full item names can be displayed. Unfortunately the available tools are rather poor. I wonder how hard it would be to add a {{para|horizontal|yes}} parameter to this module, which would flip the y and x axes while keeping the compact syntax for input data, and the handy bar stacking feature. {{ping|Ita140188}} What do you think? — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 19:37, 24 October 2018 (UTC)
:this may be a good idea, but the answer the question of "how much work", is, unfortunately, "substantial".
:large potion of the code in this module went into physical arrangement of the chart, and especially placement and display of the legends, without which the graph is not very useful. horizontal presentation would require writing a set of completely new procs to handle arrangement and legends.
:the code used to process the input parameters can be shared (it's shared today between pie and bar), but not much else.
:as the original author of this module, let me repeat what i probably said on this page more than once: with the introduction of [[Template:Graph:Chart]], there is little reason to use this module. i wrote it several years before the "Graph" extension was available, and of course, before [[Module:Graph]] was available, but they do better job at displaying charts than i did, while introducing more types (line, a and area. it's a shame they did not do scatter too - i think it's useful, and of course, it's a shame they did not do horizontal bar graph...)
:peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 15:36, 25 October 2018 (UTC)
== How to change scale of Y axis ==
Someone noted on the editing help page that the scale on [[List of Proton launches (2010%E2%80%93present)]] shouldn't be fractional. While the chart is technically correct, it's potentially confusing, since there will never be a fractional launch. Is there way to force the Y axis to be rounded numbers only? [[User:Timtempleton|<b style="color:#7F007F">TimTempleton</b>]] [[User talk:Timtempleton|<sup style="color:#800080">(talk)</sup>]] [[Special:Contributions/Timtempleton|<sup style="color:#7F007F">(cont)</sup>]] 22:28, 4 June 2019 (UTC)
: {{U|Timtempleton}} try {{para|y tick marks|5}} or some other value. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 20:04, 5 June 2019 (UTC)
::{{U|Frietjes}} 5 worked - there are whole numbers now. Thanks! [[User:Timtempleton|<b style="color:#7F007F">TimTempleton</b>]] [[User talk:Timtempleton|<sup style="color:#800080">(talk)</sup>]] [[Special:Contributions/Timtempleton|<sup style="color:#7F007F">(cont)</sup>]] 20:13, 5 June 2019 (UTC)
== Update this module with the new version? ==
Hello, as discussed in a section above, I have been working on a new version of this module without the extra white space around the chart. You can check the new version at [[Module:Sandbox/Ita140188/chart2]]. Should we replace this module with the new version? Please let me know what you think. Thanks! --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 04:43, 15 February 2020 (UTC)
:{{re|Ita140188}} thank you for the improvements, but now the "Scale per group" functionality does not seem to work (see in doc page). it did work before your changes. if this isn't used anywhere, it should be removed, at least from the docs, and ideally from the code too.
:otherwise (i.e., if it _is_ used), i think you should fix it - it seems that you are the one who broke it... :) peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 19:49, 18 February 2020 (UTC)
::{{ping|קיפודנחש}} Hi, I have never seen the option "scale per group" used in an article, and from previous discussions I understood it was never used. This is why I proceeded to ignore the option when changing the module. As you can see from above, my initial idea was to create another module [[Module:Chart2]] so that charts could be migrated if desirable, while keeping the previous functionality intact. Consensus was to instead replace the code. Unfortunately I have no time to put more work on this. However, I have no strong feelings about this change, so if you want to revert it, please go ahead. As for cleaning up the code, it would be helpful if the code was actively maintained, but given that there will probably be close to zero maintenance/improvements I don't think the extra effort to clean up is justified. As you said in a previous comment, I also agree that [[Module:Graph]] is the way to go in the future. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 07:16, 19 February 2020 (UTC)
:::{{re|Ita140188}} first, there are a few articles that _do_ use "scale per group", and this breaking change left them with borked charts - this needs fixin` (see [[Special:Search/insource:"scale per group"]]), and the onus is on whoever introduced the breaking change.
:::second, the documentation also still speaks of "scale per group": the actual example was purged, but it was done in a half-assed way, and left the section kind of in mutilated state, a senseless sentence, and an invalid section name (section talks about scal per group, and actual content is a chart with dozens of groups, but no "scal per group"). worse yet, the documentation still has this as a valid parameter in the table at the top.
:::and last, but not least: please note that this module has dozens of interwiki. since i originally wrote it on enwiki (though my "natural habitat is hewiki, really), it's a fair assumption that most copied it from here, and some of the maintainers, might want to keep up to date, and take your improvements. it is important, whenever there is a breaking change (and as it turns out, this _was_ a breaking change, even if it was not intentional), to make it clear, in the talkpage and maybe even as a comment in the module itself or the documentation, so each maintainer that considers upgrading, will know to check first that this deprecated parameter is not used on their wiki, or rather, check if it _is_ used, and make an informed decision whether or not to "get latest".
:::don't get me wrong - i do not object to your improvements, but the problem with "legacy code", like this, is that breaking changes need to be done carefully and with serious thought (even "planning", god forbid) - specifically, with more care than it was done here: for instance, this discussion would, ideally, take place _before_ the actual change, not after.
:::peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 22:58, 19 February 2020 (UTC)
::::I completely agree that migration should follow after a wide consensus. As I have no more time to spend fixing the group option, if we decide to migrate, those few examples will likely need to be turned into [[module:graph]] or into another form. Updating the documentation does not seem to be a big problem. In the meanwhile, I reverted to the original version. --[[User:Ita140188|Ita140188]] ([[User talk:Ita140188|talk]]) 02:05, 20 February 2020 (UTC)
::::Apologies for messing up. I tried to get a discussion going on charts and graphs in various places but nobody seemed really interested. In the end I replaced this code as nobody seemed to mind. I only noticed after the fact - when I updated the documentation - that the scale per group feature did not work anymore, so I wrote this into the documentation. I will see if I can find time to learn this language and update this scale per group feature for the new module. It would be a shame if the new version were just lost. [[User:KarlFrei|KarlFrei]] ([[User talk:KarlFrei|talk]]) 12:44, 20 February 2020 (UTC)
== Wishlist - user button for switching semilogy on/off ==
See [[Talk:2020_coronavirus_pandemic_in_Australia#Semilog_graph_option_enabled_for_the_states_graph]]. The main reason is that not only do many people have difficulties reading graphs, but some of those who can read linear graphs are unfamiliar with loglog or semilog graphs, even though the real world varies a lot on orders of magnitude scales, so the sooner they learn, the more informed people will be about the real world (such as pandemics). [[User:Boud|Boud]] ([[User talk:Boud|talk]]) 14:57, 26 March 2020 (UTC)
== X-axis labels flowing into each other ==
With a vertical bar chart (with dates as x values), is there a way to thin out the labelling such that only every n-th item is displayed, or some other way to keep labels from getting printed on top of each other? With large bar charts like [[COVID-19 pandemic in Germany/Statistics#New cases per day|these ones]], label strings currently flow into each other, at least on my screen, in a way that makes the charts practically unreadable. It would be nicer if we could have just one label per week or something like that. [[User:Future Perfect at Sunrise|Fut.Perf.]] [[User talk:Future Perfect at Sunrise|☼]] 16:41, 23 August 2020 (UTC)
:RTFM. search "If there are many values, x legends can be diluted by using delimiters with nothing in between:" for an example. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 22:05, 27 August 2020 (UTC)
::ah, and at 2nd look, the example you link to does not use this module, it uses the Graph extension, so even though my answer is correct, in principle, it's not relevant to the problem (unless you want to convert the graph to use this module). peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 23:05, 27 August 2020 (UTC)
== Requested move 18 September 2020 ==
{{moved from|Module talk:Chart/Default colors|[[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 00:52, 4 October 2020 (UTC)}}
<div class="boilerplate" style="background-color: #efe; margin: 0; padding: 0 10px 0 10px; border: 1px dotted #aaa;"><!-- Template:RM top -->
:''The following is a closed discussion of a [[Wikipedia:Requested moves|requested move]]. <span style="color:red">'''Please do not modify it.'''</span> Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a [[Wikipedia:move review|move review]] after discussing it on the closer's talk page. No further edits should be made to this discussion. ''
The result of the move request was: Consensus to move to Module:Chart/Default colors. I leave the implementation to an editor who knows modules well and won't break anything. {{nac}} ([[User talk:Buidhe|t]] · [[Special:Contributions/Buidhe|c]]) '''[[User:buidhe|<span style="color: black">buidhe</span>]]''' 00:49, 4 October 2020 (UTC)
----
[[:Module:Plotter/DefaultColors]] → {{no redirect|Module:Chart/DefaultColors}} – This submodule is used by [[Module:Chart]] (used on 600 pages) in addition to [[Module:Plotter]] (unused), and so should be a submodule of the more-highly-used page. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 15:01, 18 September 2020 (UTC)
* '''Support''' but change to [[Module:Chart/Default colors]]. --[[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 08:01, 19 September 2020 (UTC)
*: Works for me too. When I file a requested move, I generally focus on one specific problem, and leave it to others to identify any other problems with the name. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 16:22, 19 September 2020 (UTC)
{{abot}}
== Non-printable characters being inserted into bar graph hover text ==
When you mousover this table [[List_of_Falcon_9_and_Falcon_Heavy_launches#Booster_landings]] for any entry that has <nowiki>[i]</nowiki> entries in them, you get gibberish printed. For example mousing over any of the "Ocean Test Failure" entries in the table, you get this as the highlight text <nowiki>"Ocean test failure'"`UNIQ--ref-000000CF-QINU`"':"</nowiki> and yes there are non-printable characters in there as well. Edit this comment to see them. They are Unicode U+007F. [[User:Ergzay|Ergzay]] ([[User talk:Ergzay|talk]]) 15:24, 13 May 2021 (UTC)
:I fixed that. Some group names included a reference which becomes a strip marker ([[WP:UNIQ]]) when passed to a module. The module has a large number of global variables which need to be investigated and fixed another time. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:24, 14 May 2021 (UTC)
::this may be improved in the module, but it's a solvable problem: the module allows defining "tooltip" per bar (see doc), and only when one is not defined, it tries to generate one based on the link or the legend. look for "tooltip" in documentation. not sure why Johnuniq says "The module has a large number of global variables". can you point to a single global variable? not saying there aren't any, but definitely not "large number", and none intended. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 22:33, 14 May 2021 (UTC)
:::The globals are: addRes + addSlice + analyzeParams + asGroups + barChart + calcHeightLimits + calcHeights + calcx + coordsOfAngle + createImageMap + createSlices + drawChart + drawSingle + drawSlice + drawXlegends + drawYScale + drawbar + extractParams + getArg + groupBounds + i + keyword + pieChart + roundup + sliceStr + testone + tooltip + validate. I could start fixing them but if you don't mind I would also replace the spaces used for indents with tabs as that is style used now. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:42, 14 May 2021 (UTC)
{{od|4}}I edited [[Module:Chart/sandbox]], first to use tabs for indents, and second to clean the unintended globals. There is one left that needs fixing, namely <code>sliceStr</code>. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:48, 15 May 2021 (UTC)
:I guess that's pretty obvious: it should be <code>slice</code> but I'll leave it for now. Please fix, check my edits, and update the main module. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:50, 15 May 2021 (UTC)
::tbh, i did not know that nested functions are global. any non-function global in this module is a bug, and i don't think there are too many (unless i have even more holes in my lua-fu - apparently i do not fully grok "scope" in lua). thanks for the education. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 06:02, 15 May 2021 (UTC)
:::The way to think of it is that Lua regards the following as equivalent (it defines the first as the second):
::::<code>function example(x) ... end</code>
::::<code>example = function (x) ... end</code>
:::That is part of <code>example</code> being a [[first-class function]]. The above defines <code>example</code> as a global variable regardless of where the statement occurs. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:43, 15 May 2021 (UTC)
== Could this module be fed data from a wikitable instead of as explicit parameters? ==
That would be real game changer for Wikipedia, as charts would be automatically updated when tables received new data. [[Module:User script table row/data|Here]] is a good example of how to read data from tables. The module could be called with a ''page name'' (if not its own), a ''table id'' (if not the 1st one), and the columns for ''labels'' and ''values'' (if not the 1st and 2nd, respectively). It would certainly break if the table is oddly shaped or malformed, but that could be minimised ignoring header rows. This shouldn't be too hard, as this module already converts parameter values into values on tables. [[Module:Datatable|Here]] is my first crack at it. [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 01:36, 20 May 2021 (UTC)
:There appears to be a trend towards modules reading the content of a page, then trying to parse the wikitext and doing something with the result. That could be reasonable for something like [[Wikipedia:User scripts/Most imported scripts]] (the example given above) but I don't think it's desirable for articles. I have commented on that before and might try to say more but for now I'll just note that IMHO it would be better to have the data stored somewhere (in a module or in Commons structured data) and display the table and the chart from that data. That would be much more efficient and understandable, and would be much less fragile. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:16, 20 May 2021 (UTC)
:I also again iterate that this seems like something that is gonna break at some point. Besides, we already have Lua data tables and the Commons Data namespace. Make a template to turn that into a wikitable instead, seems way more efficient to me. —[[User:TheDJ|Th<span style="color: green">e</span>DJ]] ([[User talk:TheDJ|talk]] • [[Special:Contributions/TheDJ|contribs]]) 07:22, 20 May 2021 (UTC)
::No doubt Wikidata and Commons:Data are the future, but as of now, I don't see data there being updated, do you? Look at [[commons:Data:Bea.gov/GDP by state.tab]], the very first source there on [[Template:Graph:Stacked]]: the data is 5 years stale, whereas the data at the [[List of states and territories of the United States by GDP]] is freshly updated.
::No doubt too that this is a much more fragile solution, yet much more flexible (as is typically the case with... everything in life?). Besides, not every wikitable warrants a database in Wikidata or Commons:Data, yet readers may benefit from seeing its data graphed in the article. [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 08:09, 20 May 2021 (UTC)
:::i do not think it's a good idea to overload this module with data parsing or harvesting. however, it may be a good idea to export functions to be used by other modules. tbh, this is not even necessary - once you have the data structure, just join the series using the delimiter, and serve it to the existing functions. it's a bit of overhead, and also requires camouflaging as a "frame" (basically a table with one item called "args").
:::the main thing is that the this module should not be tasked getting the data, and be limited to the presentation side.
:::write a module to harvest the data, synthesize it with parameters passed by the template(s), package the data series by joining with the delimiter and assign them to appropriate fields in the "args" table, and call this module to produce the chart.
:::something like so: <syntaxhighlight lang="lua">
-- this code is inside your exported function
local args = {}
-- synthesize args to be passed to the chart, from parameters passed to the module and harvested data
-- hack hack hack
-- "args" is ready
return require('Module:Chart').pieChart({ ['args'] = args } ) -- return chart to page
</syntaxhighlight>
:::will be interesting to see something like this in action.
:::if it makes a big diff for you, it will not be too painful to export "for modules only" function which will take the parameters a native lua table through and through. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 00:11, 25 May 2021 (UTC)
::::''Todah'', {{u|קיפודנחש}}. Looks like it'll be a fairly thin wrapper, but... I'm [[Module:Graph table|stuck]] at [[User:Guarapiranga/sandbox/5|{{red|'''Lua error in Module:Graph_table at line 15: attempt to call field 'pieChart' (a nil value).'''}}]]. What am I doing wrong? [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 06:13, 25 May 2021 (UTC)
:::::I fixed [[Module:Graph table]] but now [[User:Guarapiranga/sandbox/5]] has another error. Regardless of this module, I have not seen any support either here or where it was raised at [[WP:VPT]] for the idea of having a module parse the wikitext of a page to extract data from a wikitable. I wouldn't put much effort into that approach. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:34, 25 May 2021 (UTC)
::::::Thanks, {{u|Johnuniq}}. I fixed the regex, as you recommended, and it's pulling the data, but it seems this module needs each data point on a different line(?):{{pre|addSlice( i, mw.ustring.match( slice, '^%(%s*(.-)%s*%)$' ) )}} But what's the deal with ^ and $, if [[mw:Extension:Scribunto/Lua reference manual#string.gmatch|Scribunto manual]] says that {{tq|a '^' at the start of a pattern is not magic, as this would prevent the iteration}}, and that {{tq|it is treated as a literal character}}? Is that why it uses mw.ustring instead? The [[mw:Extension:Scribunto/Lua reference manual#Ustring patterns|ustring patterns section]] doesn't say anything about mw.ustring extending the controls to ^ and $. [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 16:16, 25 May 2021 (UTC)
:::::::Before the <code>addSlice(...)</code> code you posted above is <code>for slice in...</code>. The <code>for</code> loop gets each "<code>(...)</code>" substring (any text in balanced parentheses) and passes it to <code>addSlice</code>. The <code>^</code> and <code>$</code> you mention are redundant as <code>slice</code> will start and end with parentheses. However, they work because it's <code>match</code>, not <code>gmatch</code>. The code uses mw.ustring but it does not need to with the regex that it uses. Following that requires a bit of experience with [[UTF-8]] but, in brief, it's only when you have a regex like <code>[x◆]*</code>, and probably some others, (with a Unicode character) that mw.ustring is needed. Scribunto implements mw.ustring by using Lua to replace the regex library which is a breathtaking accomplishment but which makes it slower than using plain strings. When I've got some time in a few hours I'll look at what's happening, bearing in mind that I still do not think parsing wikitext in Lua is sustainable. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 22:44, 25 May 2021 (UTC)
::::::::Thanks, {{u|Johnuniq}}.
::::::::{{tq|The code uses mw.ustring but it does not need to with the regex that it uses. ... Scribunto implements mw.ustring by using Lua to replace the regex library which is a breathtaking accomplishment but which makes it slower than using plain strings.}}
::::::::So I went ahead and created a copy of [[Module:Chart]] in its sandbox with ''string'' instead of ''mw.ustring''. At least in the doc examples, it doesn't break. Should it be 'downgraded'? [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 23:00, 25 May 2021 (UTC)
:::::::::Testing in [[Module:Graph table]] showed that [[Module:Chart]] requires a proper frame because it calls <code>frame:preprocess(...)</code>. Adding that makes the chart work. The regex does not handle the 6.4e5 notation. Regarding removing mw.ustring from Module:Chart: The problem is that who ever does that is volunteering to maintain the module and I don't want to take that on, however I fixed [[Module:Chart/sandbox]] by using tab indents and removing unintended globals (including a couple of typos) and removing a couple of unused items. I checked the removal of mw.ustring and it is good although the <code>getArg</code> function could fail if it were ever used in a vastly different way from how it is used now. After testing and more thought, it would be ok to update [[Module:Chart]] because I don't want to fix the sandbox again. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:20, 26 May 2021 (UTC)
::::::::::Awesome! ''It lives!!'' That's proof of concept right there. Thanks, {{u|Johnuniq}}.
::::::::::{{tq|Testing in Module:Graph table showed that Module:Chart requires a proper frame because it calls frame:preprocess(...). Adding that makes the chart work.}}
::::::::::No idea what that means. Totally above my pay grade. Would never have guessed it.
::::::::::{{tq|The regex does not handle the 6.4e5 notation.}}
::::::::::Yeah, I expected that. {{Fixed}}
::::::::::{{tq|After testing and more thought, it would be ok to update Module:Chart because I don't want to fix the sandbox again.}}
::::::::::Will do. [[User:Guarapiranga|— 𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] ([[User talk:Guarapiranga|talk]]) 12:43, 26 May 2021 (UTC)
::::::::::{{done}} — [[User:Guarapiranga|𝐆𝐮𝐚𝐫𝐚𝐩𝐢𝐫𝐚𝐧𝐠𝐚]] [[User talk:Guarapiranga|☎]] 04:05, 2 June 2021 (UTC)
== Weird visual glitches with stacked bar charts ==
If you look at bar chart in https://en.wikipedia.org/wiki/History_of_Tesla,_Inc.#Timeline_of_production_and_sales there are two types of visual glitches - one can be seen in Q3 & 4Q 2015 bars, where the grey part of the bar is both too thick (at least in Q3's case since on 6 cars ot of over 11.5k were Model Xs, so the grey part should have been only ~1 pixel thick) and in the wrong place (in looks the be inside the black part instead of on top of it) and in Q4 2018 bar there's a gap between grey and yellow parts.
Or at least it looks like https://i.imgur.com/FMFjYv6.jpg to me on my Android tablet.
== Chart suddenly behaves strange ==
Hello!
Can someone help me with the way the chart [[w:sq:Kategoria:Gabime CS1|here]] is suddenly behaving?
I was guided here after [https://en.wikipedia.org/w/index.php?title=User_talk:Trappist_the_monk&oldid=1049797955#Uhm... this discussion]. - [[User:Klein Muçi|Klein Muçi]] ([[User talk:Klein Muçi|talk]]) 22:34, 13 October 2021 (UTC)
: {{fixed}} via [[Special:Diff/1050400291]] [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 15:57, 17 October 2021 (UTC)
== Excessive whitespace when there is no legend ==
{{Image frame
|content={{ #invoke:Chart | bar chart
| width=300
| height=200
| group 1 = 2263.79 : 2298.27 : 2378.93 : 2443.85 : 2511.09 : 2553.18 : 2504.78 : 2616.24 : 2626.34 : 2660.85 : 2608.18 : 2597.81 : 2558.06 : 2629.82 : 2517.98 : 2346.19 : 2358.86 : 2410.37 : 2441.33 : 2477.30 : 2502.82 : 2562.76
| colors = blue
| group names = Generation (TWh)
| x legends = 1997 : : : 2000 : : : : : 2005 : : : : : 2010 : : : : : 2015 : : :
}}
|caption = Nuclear power generation (TWh)
}}
As you can see in the example at right, the Chart module adds excessive whitespace below the chart when there is no legend. Could someone fix this? [[User:Nosferattus|Nosferattus]] ([[User talk:Nosferattus|talk]]) 01:13, 8 March 2024 (UTC)
== X-axis label==
I've just come across this module via the [[WikiProject]] article. Is there currently a way of adding a label to the x-axis in a line below the x-legends? In the Nuclear power example above, it would probably just say "Year" but it can be useful where the overall meaning of the x-legends is open to interpretation. I couldn't find it in the code but maybe there's currently a way of doing it with a linebreak or something. Thanks --[[User:Northernhenge|Northernhenge]] ([[User talk:Northernhenge|talk]]) 10:07, 4 April 2024 (UTC)
== Legend columns ==
Hard-coding the legend columns width (<code>[[Module:Chart#L-50|column-width:12em]]</code>) is not a great idea and doesn't allow using long group names (like [[United_Nations_High_Commissioner_for_Refugees#2019|here]], where the legend had to be redone manually under the chart), while at the same time producing too few unnecessarily wide columns (like in the [[Module:Chart#Basic|"basic" example]], where it would be much better to show all 3 names in a single row). Please change the columns to automatic or allow overriding the column width or count. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 03:11, 23 June 2024 (UTC)
== dark mode ==
hey, did anyone look at this thing in dark mode?
are there any issues with colors?
i noticed that the frwiki version added some code which i think solves some issues in dark mode, though i am not certain. peace. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 05:08, 22 July 2024 (UTC)
:one thing i noticed is that pie charts are embedded in white square in dark mode.
:this comes from an svg file: [[:File:Circle frame.svg]] (it's the square with a round hole, making the pie chart a pie). it defines its color as #FFF, and the circle color as #000. maybe some dark mode wizard can advise - i hope it's possible to use dark-mode aware svg with the same shape. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 05:51, 22 July 2024 (UTC)
== Errors ==
There seem to be a huge number of errors on articles caused by this module — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 09:09, 20 December 2024 (UTC)
:I suspect that recent edits at {{tl|PH poverty incidence}} by {{u|PH 0447}} have led to problems such as at [[Aborlan#Economy]] which currently shows "Lua error in Module:Chart at line 301: bad argument #7 to 'max' (number expected, got string)." It is sucking in who-knows-what from Wikidata. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:31, 20 December 2024 (UTC)
::The [https://en.wikipedia.org/w/index.php?title=Template:PH_poverty_incidence&oldid=1249587791 pre-PH 0447 version] is also showing a script error — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 09:35, 20 December 2024 (UTC)
:::But it doesn't at Aborlan. That's not conclusive but is a good clue. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:38, 20 December 2024 (UTC)
::::Okay I have reverted PH 0447's edits to that template. Hopefully they can help to sort this out — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 09:41, 20 December 2024 (UTC)
:::::my $.02: the poverty incidents template sucks stuff directly from wikidata and pass it to chart module without any test/sanitation. Edits on wd which do not adhere to what chart expect can trigger "lua errors" pointing to chart module when the real culprit(s) are either wd or the template. One contrived example is like so: the default delimiter this module expects is colon. The template does not override it, takes labels "as is" from wd and passes them to the module. If such label for some wd item contains a colon, the module will interpret it as a delimiter, which may trigger lua error.
:::::Templates which suck data from wd should sanitize it before sending it to this (or any other) module. When they fail to do so and errors pop up, these errors will point to the module, even though it's really innocent, and the blame should be placed elsewhere.
:::::Peace. [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 21:00, 21 December 2024 (UTC)
::::::Whoops. Sorry my bad. I was trying to put a new column since we already have a data for 2023. Apologies to all editors if it causes errors. [[User:PH 0447|PH 0447]] ([[User talk:PH 0447|talk]]) 02:46, 24 December 2024 (UTC)
== Category ==
The past two runs of [[Special:WantedCategories]] have featured a redlinked {{cl|Pages using the Chart extension with rendering errors}} that I cannot recall ever having seen there before — so I don't know if it's a genuinely new thing that this module only recently got coded to start generating, or an old thing that just never showed up because this module never saw errors before. (I suspect the former, because the above discussion does remind me of a ''different'' type of redlinked error category that I used to see frequently but haven't recently, but I don't know enough about the module to be absolutely certain of that.)
But either way, it needs to be created if it's a category you want to exist, or killed off so that it never happens at all if you don't want it to exist, because templates and modules shouldn't be autogenerating redlinked categories. So could you either create it or edit the module to prevent it? Thanks. [[User:Bearcat|Bearcat]] ([[User talk:Bearcat|talk]]) 15:53, 4 July 2025 (UTC)
: Created. This actually comes from [[mw:Extension:Chart]], not the module, but you had no good reason to know that. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 19:11, 7 July 2025 (UTC)
|