Template talk:Graph:PageViews

Add topic
From mediawiki.org
Latest comment: 1 year ago by Tacsipacsi in topic Category: Pages with disabled graphs

Works with subpages[edit]

@Yurik: 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)Reply

@Billinghurst: 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: @Milimetric (WMF): --Yurik (talk) 13:51, 9 March 2016 (UTC)Reply
<sad face> 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)Reply

Strange graph given the available data[edit]

Strange graph that isn't whats expected from 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 [1].

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)

	"items": [
			"project": "no.wikipedia",
			"article": "Backbone_Entertainment",
			"granularity": "daily",
			"timestamp": "2016030100",
			"access": "all-access",
			"agent": "all-agents",
			"views": 12
			"project": "no.wikipedia",
			"article": "Backbone_Entertainment",
			"granularity": "daily",
			"timestamp": "2016030200",
			"access": "all-access",
			"agent": "all-agents",
			"views": 4
			"project": "no.wikipedia",
			"article": "Backbone_Entertainment",
			"granularity": "daily",
			"timestamp": "2016030300",
			"access": "all-access",
			"agent": "all-agents",
			"views": 5
Jeblad, 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: Milimetric (WMF). --Yurik (talk) 13:47, 9 March 2016 (UTC)Reply
Missing data is w:en: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)Reply
Jeblad I added interpolation template parameter. Set it to "linear" to disable. --Yurik (talk) 20:12, 5 December 2016 (UTC)Reply

Encoding error[edit]

@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)Reply

krassotkin, thanks, tracking. --Yurik (talk) 13:36, 9 March 2016 (UTC)Reply
krassotkin, see following discussion. --Yurik (talk) 20:50, 16 May 2016 (UTC)Reply

Sanitazing bug[edit]

Hello, Yurik. There is a bug in the template. try w:en:"Hello, World!" program. The code {{PageViews graph|90|"Hello, World!" program}} works well. The code {{PageViews graph|90}} on the article page, using default, does not work. Could you check this, please? IKhitron (talk) 21:39, 9 May 2016 (UTC)Reply

IKhitron, 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)Reply
Thank you, Yurik. 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)Reply
@Yurik: ? If you have no time, I can do this. IKhitron (talk) 12:58, 15 May 2016 (UTC)Reply
@IKhitron: 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)Reply
I can understand your unhappiness, Yurik. 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)Reply
IKhitron, please copy Module:Graph to he:יחידה: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)Reply
Thank you very much, Yurik! 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)Reply
IKhitron, 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)Reply
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)Reply
In process :) --Yurik (talk) 17:51, 16 May 2016 (UTC)Reply

krassotkin, IKhitron, I updated the pageviews graph in en,he,ru wikis to an alternative parsing proposed by Matma Rex. 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)Reply

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. Matma Rex, you are brilliant, as usual. IKhitron (talk) 10:26, 17 May 2016 (UTC)Reply
Thank you for the praise, but I merely read and applied the documentation. :) Matma Rex (talk) 11:18, 17 May 2016 (UTC)Reply

Axes disappear after color inversion[edit]

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 (talkdgaf)  15:23, 3 January 2018 (UTC)Reply

Yes Done, after 3 weeks of unanimous consensus and/or apathy.   ~ Tom.Reding (talkdgaf)  01:31, 24 January 2018 (UTC)Reply

Graphs have disappeared[edit]

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 ?action=purge to the end of the URL and hit Enter — or &action=purge 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)Reply

Reverse curve[edit]

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

It's a result of the interpolation again, as discussed above at #Strange graph given the available data, but worse.
Compare {{Graph:PageViews|Martin Hellinger|365|en.wikipedia.org|interpolate=monotone}}:
with {{Graph:PageViews|Martin Hellinger|365|en.wikipedia.org|interpolate=step-after}}:
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)Reply
@Qwfp: 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)Reply
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 step-after. . 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 — surely not every Wikipedia?? Anybody? Qwfp (talk) 11:39, 10 November 2018 (UTC)Reply
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)Reply
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)Reply

Relevant discussion from elsewhere[edit]

Here's some discussion of this same problem from other forums where it was posted about. - dcljr (talk) 00:19, 11 November 2018 (UTC)Reply

From w:Template talk:Annual readership#Reverse curve in pageviews graph:

I think I see the issue. The article was created on October 10 and Wikipedia had maintenance last week. If you add |days=30, the graph displays correctly. – The Grid (talk) 12:41, 17 October 2018 (UTC)

From w:Wikipedia:Village pump (technical) [Archive 170]:

Redrose64, no idea, but the actual numbers show a lot of 0 in the data. It seems that this graph uses quite a bit of easing and i suspect that those two combined are the cause of this. Not sure if that an error in the module or the graph lib.—TheDJ (talkcontribs) 20:20, 17 October 2018 (UTC)
Yeah, the problems might be from the fact that the article was created very recently (October 10) and the graph shows days before that. SemiHypercube 20:39, 17 October 2018 (UTC)

Multiple pages[edit]

For the purpose of discussion on talk pages, it would sometimes be useful to be able to display multiple lines, in order to make graphs like this. HLHJ (talk) 05:44, 28 April 2020 (UTC)Reply

date range[edit]

Can a date range parameter be added? For example:

{{Graph:PageViews |start=2022-02-03 |end=2022-05-21 | Main Page | en.wikipedia.org }} Shizhao (talk) 02:08, 7 March 2023 (UTC)Reply

Temporarily disabled[edit]

See w:WP:VPT#Graph extension disabled per immediate effect. Mathglot (talk) 10:19, 18 April 2023 (UTC)Reply

Category: Pages with disabled graphs[edit]

Hi. I have translated translatewiki:MediaWiki:Graph-disabled-category/sl, but it has no effect. Can someone please have a look at that? --TadejM (talk) 13:48, 20 April 2023 (UTC)Reply

Ok, I see it has now been fixed locally. Anyway, this is not the preferred method. It should be implemented globally. --TadejM (talk) 14:07, 20 April 2023 (UTC)Reply
Translation updates don’t take effect immediately, but on a weekly schedule: translations made until Monday European morning are installed together with the software updates that week (except for out-of-schedule software updates, which usually don’t contain translation updates), i.e. on Tuesday on a few wikis including mediawiki.org, on Wednesday on most non-Wikipedia wikis, and on Thursday on Wikipedias. So what you translated will arrive on next Wednesday/Tuesday to Slovenian wikis – by which time it will hopefully already be useless. —Tacsipacsi (talk) 02:15, 21 April 2023 (UTC)Reply