Content deleted Content added
→Category: Re |
|||
(48 intermediate revisions by 15 users not shown) | |||
Line 192:
: 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 ==
Line 259 ⟶ 260:
''—[[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. ==
Line 423 ⟶ 431:
{{abot}}
== Non-printable characters being inserted into
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)
|