Jump to content

Template:Graph:PageViews: Difference between revisions

From mediawiki.org
Content deleted Content added
a few extra params
No edit summary
Line 15: Line 15:
},
},
"transform": [
"transform": [
{{ #if: {{{max|}}}
| { "type": "formula", "field": "views", "expr": "min(datum.views, {{{max}}})" },
}}
{ "type": "formula", "field": "year", "expr": "parseInt(substring(datum.timestamp,0,4))" },
{ "type": "formula", "field": "year", "expr": "parseInt(substring(datum.timestamp,0,4))" },
{ "type": "formula", "field": "month", "expr": "parseInt(substring(datum.timestamp,4,6))" },
{ "type": "formula", "field": "month", "expr": "parseInt(substring(datum.timestamp,4,6))" },
Line 34: Line 31:
{
{
"name": "y",
"name": "y",
"type": "linear",
"type": "{{{scale|linear}}}",
"range": "height",
"range": "height",
"domain": {"data": "pageviews","field": "views"},
"nice": true,
"clamp": true,
{{ #if: {{{max|}}}
{{ #if: {{{max|}}}
| "domain": [0, {{{max}}}]
| "domainMax": {{{max}}},
| "domain": {"data": "pageviews","field": "views"}
}}
}}
"nice": true
}
}
],
],
Line 114: Line 112:
"default": "#00f",
"default": "#00f",
"example": "#f00",
"example": "#f00",
"type": "string"
},
"scale": {
"label": "Graph scale",
"description": "Scaling could be one of these: linear, log, pow, sqrt, quantile, quantize, and threshold",
"default": "linear",
"example": "log",
"type": "string"
"type": "string"
},
},
Line 129: Line 134:
"3",
"3",
"color",
"color",
"scale",
"max"
"max"
],
],

Revision as of 12:45, 18 February 2016


This graph's main version resides at mediawiki Template:Graph:PageViews. Please make all the changes there and copy it everywhere else (until the copying is automated)

{{ Graph:PageViews }}
30 days for the current page (if there is data)
{{ Graph:PageViews | 90 | Main Page | en.wikipedia.org }}
90 days for Main Page on English Wikipedia

Inserts a graph with the page views statistics for the past N days of a page.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Number of days back1

no description

Default
30
Numbersuggested
Page Title2

Title of the page, with namespace, including needed spaces

Default
Name of the current article page (even if on talk page)
Example
Main Page
Page nameoptional
Domain3

no description

Default
Current wiki
Example
en.wikipedia.org
Stringoptional
Graph colorcolor

no description

Default
#00f
Example
#f00
Stringoptional
Graph scalescale

Scaling could be one of these: linear, log, pow, sqrt, quantile, quantize, and threshold

Default
linear
Example
log
Stringoptional
Fix maximum value of the Y axismax

This optional value might be useful to align multiple graphs side-by-side

Default
auto
Example
10000
Numberoptional