Template talk:Graph:PageViews

Works with subpages
Thanks for the template, it is helping enWS to investigate the readership. At the Wikisources, works are usually/often set as root page with (numerous) subpages. Is there a means to reflect in the use of the template, or a derivation, to capture views for a work and its subpages? The playing by some was said to indicate that just the root page is being counted in this model. This would be helpful to monitor whether users are reading the whole work, looking at specific components, etc. Thanks. — billinghurst  sDrewth  05:32, 22 February 2016 (UTC)
 * pageviews api only gives data about a single page, so the only option really is to insert multiple graphs, one for each subpage. I could design a graph with multiple lines, but you will still need to provide each subpage title individually, and with many subpages it might get crowded. CC: --Yurik (talk) 13:51, 9 March 2016 (UTC)
 * The Wikisources work differently than the Wikipedias, the WSes have collections of pages (root/subpages); multiple subpages while giving the data isn't particularly effective. — billinghurst  sDrewth  13:06, 10 March 2016 (UTC)

Strange graph given the available data
The dataset below is rendered by Graph:PageViews at nowiki and shows up as the graph to the right. But this is (sorry) wrong.

This dataset is a copy of data from.

A closer look reveals that the graph is smoothed over missing data (?), and then truncated (?), which gives a wrong impression. — Jeblad 6. mar. 2016 kl. 00:52 (CET)


 * , yes, this is a limitation of the Vega graphs and/or pageview api - if data is missing, pageview api does not return any values, and graph simply draws the line between all known points - e.g. if there is data on day 1,2, and 8, it will draw two lines: between 1st and 2nd day, and between 2nd and 8th day (smoothing it in the process). Graph does not insert any extra values. There has been some talks about it in the Vega community, so when something like that gets implemented, we can use it. In the mean time, the only thing we can do is ask pageview api to insert 0s, at least (in my example) as day 3 and day 7, thus drawing a line for 0. CC: . --Yurik (talk) 13:47, 9 March 2016 (UTC)
 * Missing data is Imputation (statistics), and it is a large field. Replacing missing data with zero (0) is only a partial solution.
 * My main concern with the graph is not missing data, but that the shown data is actually wrong. In this case there are three values for three consecutive days, with values 12 - 4 - 5. Compare this with the graph and it does not make sense at all. Jeblad (talk) 11:35, 10 March 2016 (UTC)
 * I added interpolation template parameter. Set it to "linear" to disable. --Yurik (talk) 20:12, 5 December 2016 (UTC)

Encoding error
@Yurik: Encoding error when we request a page with  apostrophe (double encoding?). Example: n:ru:Викиновости:Статистика страниц/Men's Health назвал сотню самых сексуальных женщин 2013 года. --sasha (krassotkin) 07:04, 9 March 2016 (UTC)
 * , thanks, tracking. --Yurik (talk) 13:36, 9 March 2016 (UTC)
 * , see following discussion. --Yurik (talk) 20:50, 16 May 2016 (UTC)

Sanitazing bug
Hello,. There is a bug in the template. try "Hello, World!" program. The code works well. The code on the article page, using default, does not work. Could you check this, please? IKhitron (talk) 21:39, 9 May 2016 (UTC)
 * , same bug as above - basically there is no good way right now for the urlencode magic keyword to produce something that is easy to use by the graph. I think we will have to implement a new magic keyword for it. --Yurik (talk) 00:52, 10 May 2016 (UTC)
 * Thank you, . But there is a hope over there. Could you please provide us a patch: A little Lua function code which encodes the default call to magic word exactly as your template needs it? The invocation can be simply added to the template code, in #ifexists-module, if needed. As I can see, all this work will take you about five minutes. Thanks again. IKhitron (talk) 09:26, 10 May 2016 (UTC)
 * ? If you have no time, I can do this. IKhitron (talk) 12:58, 15 May 2016 (UTC)
 * sorry for the delay, have been swamped a bit. The page name should simply be "path-encoded", without any magical HTML symbols like &amps;amps; instead of &apms;. Don't confused with query-encoded which is similar but which does not encode the '/' symbol. For path encoding, the '/' has to be encoded as well. Still, I'm fairly unhappy with requiring a magical module which will have to be copied to all wikis just like the graph itself. We really ought to have a shared template and module system. --Yurik (talk) 01:49, 16 May 2016 (UTC)
 * I can understand your unhappiness, . But while enwiki has say 12 wrong names, our hewiki has thousands. What do you thing about one more procedure to the module which runs your graphs template instead? If it is not there, the encoding will not be done. IKhitron (talk) 08:34, 16 May 2016 (UTC)
 * , please copy Module:Graph to he:%D7%99%D7%97%D7%99%D7%93%D7%94:Graph -- seems like the page is locked for some reason. If you want to change any code, please do it in dewiki and let me know, i will copy it everywhere else. Thanks! --Yurik (talk) 15:15, 16 May 2016 (UTC)
 * Thank you very much, ! It works well. But what about the wikis that have pageviews and do not have module:graph. Don't you need some #ifexists? IKhitron (talk) 17:45, 16 May 2016 (UTC)
 * , I plan to add Module:Graph to all wikis, but the ifexists might also be a good approach. --Yurik (talk) 17:47, 16 May 2016 (UTC)
 * So i believe you should add it now to media wiki pageviews origin, and remove after your plans will be done :-) IKhitron (talk) 17:49, 16 May 2016 (UTC)
 * In process :) --Yurik (talk) 17:51, 16 May 2016 (UTC)

,, I updated the pageviews graph in en,he,ru wikis to an alternative parsing proposed by. Please see if it works, and if so, I will close the bug and update all other wikis. Thanks! --Yurik (talk) 03:23, 17 May 2016 (UTC)
 * Yes, it works well. And indeed, it's much better then my version. Even if I still do not understand why does it work ar all., you are brilliant, as usual. IKhitron (talk) 10:26, 17 May 2016 (UTC)
 * Thank you for the praise, but I merely read and applied the documentation. :) Matma Rex (talk) 11:18, 17 May 2016 (UTC)

Axes disappear after color inversion
I use color inversion software with my browser since it's a lot easier (for long periods) to read white on black than black on white (plus it uses less power). The background of the graph gets inverted to black, but the axes and the axes labels are not affected, so they effectively disappear. Is there another way of drawing them so that they are included in the inversion? If not, can they be made some shade of grey, or some other color, that appears nicely on both white and black backgrounds? ~ Tom.Reding (talk ⋅dgaf) 15:23, 3 January 2018 (UTC)


 * ✅, after 3 weeks of unanimous consensus and/or apathy.  ~ Tom.Reding (talk ⋅dgaf)  01:31, 24 January 2018 (UTC)

Graphs have disappeared
For some reason, just now I was seeing broken/missing image placeholders instead of graphs on some pages that use this template. Purging the cache on each page individually worked to resurrect the graphs. Although the problem is fixed on this wiki, it still exists (and is much more widespread) on the English Wikipedia (and maybe elsehwere?), so if anyone comes here to report the same problem, purging the cache is the solution. To do that "manually", you can append the string  to the end of the URL and hit Enter — or   if the URL already contains a query string prefaced by. There are also some gadgets that provide a purge option through the interface. - dcljr (talk) 18:27, 25 September 2018 (UTC)

Reverse curve
At w:en:Talk:Martin Hellinger the pageviews graph (see accompanying screenshot) is showing a curve that reverses along the x-axis; moreover, where it returns to the correct direction, there is a loop in the curve. This is mathematically impossible. --Redrose64 (talk; at English Wikipedia) 08:07, 17 October 2018 (UTC)
 * It's a result of the interpolation again, as discussed above at, but worse.


 * Compare :
 * with :
 * The latter is clearly preferable and should be the default (speaking as a statistician). I'm not clear what "monotone" interpolation is meant to be but it appears to be badly broken. In any case, there's no reason for using any type of interpolation here. -- Qwfp (talk) 21:00, 30 October 2018‎ (UTC)
 * Agreed; I don't suppose that you're in a position to fix it? Preferably globally, I can't imagine that individual wikis would want to keep the incorrect interpolation. --Redrose64 (talk; at English Wikipedia) 10:45, 10 November 2018 (UTC)
 * As no-one has expressed any contrary views after a decent wait, I've just edited the template here to change the default interpolation method to . . I note the documentation says "Please make all the changes [here] and copy it everywhere else (until the copying is automated)", but I don't know where "everywhere else" is &mdash; surely not every Wikipedia?? Anybody? Qwfp (talk) 11:39, 10 November 2018 (UTC)
 * ISTM the preferable approach would be to simply change the interpolation method on the individual graphs that actually look wrong, not every single graph generated by this template (those that don't specify the interpolation method, anyway). BTW, "everywhere else" does indeed mean every individual wiki where this template exists, since templates cannot be used across different wikis. But this advice has not been followed up to this point, so there are already different versions of this template across the various wikis that have it. - dcljr (talk) 23:33, 10 November 2018 (UTC)
 * As for what "monotone" means (asked by Qwfp above), I would guess there is something like monotone cubic interpolation being applied, but I wouldn't think that would result in the kind of graph seen above. The problem seems (to me) to be caused by treating the first zero (or missing data value) on Sep 02 as the first point to be fit rather than the last zero (missing value) before the data begins at Oct 10. If this is the cause of the problem, it seems like it could be fixed relatively easily (by someone familiar with the code). - dcljr (talk) 00:09, 11 November 2018 (UTC)
 * ISTM the preferable approach would be to simply change the interpolation method on the individual graphs that actually look wrong, not every single graph generated by this template (those that don't specify the interpolation method, anyway). BTW, "everywhere else" does indeed mean every individual wiki where this template exists, since templates cannot be used across different wikis. But this advice has not been followed up to this point, so there are already different versions of this template across the various wikis that have it. - dcljr (talk) 23:33, 10 November 2018 (UTC)
 * As for what "monotone" means (asked by Qwfp above), I would guess there is something like monotone cubic interpolation being applied, but I wouldn't think that would result in the kind of graph seen above. The problem seems (to me) to be caused by treating the first zero (or missing data value) on Sep 02 as the first point to be fit rather than the last zero (missing value) before the data begins at Oct 10. If this is the cause of the problem, it seems like it could be fixed relatively easily (by someone familiar with the code). - dcljr (talk) 00:09, 11 November 2018 (UTC)