User:Mathglot/Charts replacement project
This page is about brainstorming ideas to replace the charts and graphs that were disabled in 2022, and among other things, caused the {{Annual readership}} template to stop displaying a graph of page views of an article.
Input
[edit]The input for the project is the output of the download function of the Toolforge page views tool, copied to an article subpage with subpagename /pageviews. As an example, the first ten rows of Talk:Liberation of France/pageviews are:
Date,"Liberation of France" 2024-06-01,533 2024-06-02,767 2024-06-03,825 2024-06-04,1049 2024-06-05,2133 2024-06-06,6184 2024-06-07,3233 2024-06-08,1751 2024-06-09,1345
Data structures
[edit]I've been thinking of various data structures, and they might be different for the mockup and the module, at least the envelope for it. Some structures I've been thinking of are month based. One, following your general design for example, might be
- ["2024-01"] = 500, 750, 1000,500, -, 650, ..., 850, 900, ... (up to 31 data points)
but in the end, if/when it is designed as a bot it would be up to the bot writer as far as what the best structure would be (although I would like to be part of that discussion).
However, for the mockup, rather than building my own parsing to analyze a lua structure (which I could do) I plan to reuse off-the-shelf stuff as much as possible, since the mockup would be a throwaway, so I thought that an easy data structure for a mockup could be simply a template written as a big #switch: whose parameters I could grab, either by month, or whatever way. Following the previous example, one would grab January like this:
{{pageviews get|year=2024|month=1}}
and the page data structure would either have a csv structure similar to the one above, and grab the items with {{Array}}. Another way, is that the data page itself would be coded as template calls (to a template that needn't even exist) and we could grab the values of them using {{template parameter value}}:
Example of using Tmpv to grab page data
|
---|
|
At the outset, the bot would emit the data in mockup style, but have hooks to switch easily to Lua style. (Or possibly it could emit both styles on the page from the start: the mockup would see only what it needs, and likewise for the module, making the transition seamless.)
As far as bot frequency, whether it is daily, weekly, or something else will depend, I imagine, on performance considerations, how expensive it is, and how many pages need it. Currently there are 52,886 transclusions of {{annual readership}}. If we did them weekly, we could run 7555 per day. I'm thinking that once we have a mockup and a bot, if all looks good, we just redirect {{annual readership}} to the mockup, and then at some point, a Module would replace the mockup, and then down the road at some point, hopefully, Module:Graph:Chart will be back.
Data
[edit]- Talk:Liberation of France/pageviews, max=6184 count=98
- Talk:World War II/pageviews max=59424 count=185
- Talk:Cleopatra/pageviews max=199068 count=367
- Talk:House of the Dragon max=329685 count=367
- Talk:Liberation of France Pageviews summary: size=76, age=133, days=75, min=218, max=456, latest=301
- Talk:House of the Dragon Pageviews summary: size=102, age=226, days=75, min=20477, max=329685, latest=20788
- Talk:Algeria
- Talk:Cleopatra Pageviews summary: size=93, age=181, days=75, min=129504, max=154599, latest=141200
- Talk:Saturday Night Live Pageviews summary: size=92, age=224, days=75, min=3069, max=11409, latest=3407
- Talk:Economy of Tamil Nadu Pageviews summary: size=92, age=224, days=75, min=298, max=654, latest=470
- Talk:2024 Atlantic hurricane season Pageviews summary: size=92, age=224, days=75, min=2737, max=41514, latest=3742
Try these
- French colonial empire
- Regency of Algiers
- Talk:Marie Curie
- Wikipedia talk:WikiProject Catalonia
Design
[edit]Patterns
[edit]Some needed patterns:
.202%d%-%d%d%-%d%d
– replace a date in the form 'yyyy-mm-dd' preceded by newline with null (remove dates and newlines):- {{#invoke:String|replace|source={{<pageviews subpage>}}|pattern=.202%d%-%d%d%-%d%d|replace=|plain=false}}
^Date,"[^"]+"
- strip first line column headers:- {{#invoke:String|replace|source={{<pageviews subpage>}}|pattern=^Date,"[^"]+"|replace=|plain=false}}
.?(202%d%-%d%d%-%d%d)%,(%d+)
– create comma-sep date:views items after stripping col headers- {{#invoke:String|replace|source={{#invoke:String|replace|source={{Talk:Liberation of France/pageviews}}|pattern=^Date,"[^"]+"|replace=|plain=false}}|pattern=.?(202%d%-%d%d%-%d%d)%,(%d+)|replace=%1:%2,|plain=false}}
Templates
[edit]- {{Xreadership}}, tmbox for placement on article talk pages; calls Xviews.
- {{xviews}}, page views charting template; entry point and user param handling.
- {{xviews/age}}, return the age in days of the given pageviews file
- {{xviews/xvmain}}, main loop: calls item_bar in a loop to generate the chart.
- {{xviews/item bar}}, Emits one progress bar-style graphic corresponding to a given line number of a page views download file created by the pageviews tool
- {{xviews/vbar}}, generates a single page views bar, currently horizontal only
- {{xviews/vbar/styles.css}}, TemplateStyles
- {{xviews/max views}}, return the maximum value from downloaded pageviews data.
- {{xviews/view count}}, return the count of page view statistics in downloaded pageviews data
- {{xviews/nth view}}, returns the nth view item (date:value) from downloaded pageviews data.
- {{xviews/xlabel}}, returns a normalized form of the date for bar id currently, just drops year and bolds day 1.
- {{xviews/x-axis}}, generates an x-axis legend with labeled tick marks for a horizontal page views chart
Pseudo-globals:
- {{Xviews/gAGING}} –
- {{Xviews/gCOUNT}} –
- {{Xviews/gSTALE}} –
Categories
[edit]- Category:Pages with experimental page views chart enabled –
- Category:Pages with stale experimental page views chart –
Examples
[edit]The pageviews file Talk:Liberation of France/pageviews is more than 30 days old; please see § Update instructions.
See also
[edit]- wmcloud pageviews tool
- Wikipedia:Templates for discussion/Log/2024 August 25#Template:Annual readership
- Advanced searches:
- 52,886 transclusions of nnual readership.
- Talk: hastemplate:Annual_readership -hastemplate:Talk_header = 28,225 articles having annual readership, but no Talk page header