模板:Graph:PageViews/doc
| File:Edit-copy green.svg | 此页面是Template:Graph:PageViews的模板文档。 此页面可能包含了模板的使用说明、分类和其他内容。 |
| File:Stop hand nuvola.svg | Template:Graph:PageViews/doc已停用。(2023年5月12日) |
| File:Lua-Logo.svg | 此模板使用Lua语言: |
图表主版本位于mediawiki Template:Graph:PageViews。请转那里做出更改,然后到处复制新版。(在复制过程自动化之前)
如要在讨论页表示条目的浏览量,请使用{{Annual readership}}。
{{Graph:PageViews}}本页30日数据(有数据的话) |
|---|
| <graph>
{ // // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:PageViews // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:PageViews // The graph uses PageViews API https://wikitech.wikimedia.org/wiki/Analytics/PageviewAPI // "version": 2, "width": 570, "height": 200, // The data for this graph comes from the PageView API. The request is made for N days back up to now.
"data": [
{
"name": "pageviews",
"url": "wikirest://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/arolstar52-zhtest.hf.space/all-access/user/Template%3AGraph%3APageViews%2Fdoc/daily/2026052500/2026062400",
"format": {
"type": "json",
"property": "items"
},
// The response is parsed here, converting date strings of form "20160223" into date 2016-02-23
"transform": [
{ "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": "day", "expr": "parseInt(substring(datum.timestamp,6,8))" },
{ "type": "formula", "field": "date", "expr": "datetime(datum.year,datum.month-1,datum.day)" }
]
}
],
"scales": [
// The dates are scaled to the "x" axis - the width of the graph
{
"name": "x",
"type": "time",
"range": "width",
"domain": {"data": "pageviews","field": "date"}
},
// The pageviews are scaled to the "y" axis - the height of the graph
// Optional scale parameter can change "linear" to other scales like log
// Optional max parameter can fix the upper bound of the graph
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "pageviews","field": "views"},
"clamp": true,
"nice": true } ], // Simple axis with horizontal grid lines
"axes": [
{
"type": "x",
"scale": "x",
"ticks": 5,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
},
{
"type": "y",
"scale": "y",
"ticks": 5,
"grid": true,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"grid": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
}
],
// The graph is drawn with two elements a thick line at the top, and a semi-transparent area below
"marks": [
{
"type": "line",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","field": "views"},
"stroke": {"value": "#00f"},
"strokeWidth": {"value": 3},
"interpolate": {"value": "monotone"}
}
}
},
{
"type": "area",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","value": 0},
"y2": {"scale": "y","field": "views"},
"fill": {"value": "#00f"},
"fillOpacity": {"value": 0.35},
"interpolate": {"value": "monotone"}
}
}
}
]
} </graph> |
{{Graph:PageViews|90|Wikipedia:首页|zh.wikipedia.org}}中文维基首页90日数据 |
| <graph>
{ // // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:PageViews // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:PageViews // The graph uses PageViews API https://wikitech.wikimedia.org/wiki/Analytics/PageviewAPI // "version": 2, "width": 570, "height": 200, // The data for this graph comes from the PageView API. The request is made for N days back up to now.
"data": [
{
"name": "pageviews",
"url": "wikirest://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/zh.wikipedia.org/all-access/user/wikipedia%3A%E9%A6%96%E9%A1%B5/daily/2026032600/2026062400",
"format": {
"type": "json",
"property": "items"
},
// The response is parsed here, converting date strings of form "20160223" into date 2016-02-23
"transform": [
{ "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": "day", "expr": "parseInt(substring(datum.timestamp,6,8))" },
{ "type": "formula", "field": "date", "expr": "datetime(datum.year,datum.month-1,datum.day)" }
]
}
],
"scales": [
// The dates are scaled to the "x" axis - the width of the graph
{
"name": "x",
"type": "time",
"range": "width",
"domain": {"data": "pageviews","field": "date"}
},
// The pageviews are scaled to the "y" axis - the height of the graph
// Optional scale parameter can change "linear" to other scales like log
// Optional max parameter can fix the upper bound of the graph
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "pageviews","field": "views"},
"clamp": true,
"nice": true } ], // Simple axis with horizontal grid lines
"axes": [
{
"type": "x",
"scale": "x",
"ticks": 5,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
},
{
"type": "y",
"scale": "y",
"ticks": 5,
"grid": true,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"grid": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
}
],
// The graph is drawn with two elements a thick line at the top, and a semi-transparent area below
"marks": [
{
"type": "line",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","field": "views"},
"stroke": {"value": "#00f"},
"strokeWidth": {"value": 3},
"interpolate": {"value": "monotone"}
}
}
},
{
"type": "area",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","value": 0},
"y2": {"scale": "y","field": "views"},
"fill": {"value": "#00f"},
"fillOpacity": {"value": 0.35},
"interpolate": {"value": "monotone"}
}
}
}
]
} </graph> |
{{Graph:PageViews|180|_}}每月的当前维基的总访问量数据(最近6个月) |
| <graph>
{ // // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:PageViews // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:PageViews // The graph uses PageViews API https://wikitech.wikimedia.org/wiki/Analytics/PageviewAPI // "version": 2, "width": 570, "height": 200, // The data for this graph comes from the PageView API. The request is made for N days back up to now.
"data": [
{
"name": "pageviews",
"url": "wikirest://wikimedia.org/api/rest_v1/metrics/pageviews/aggregate/arolstar52-zhtest.hf.space/all-access/user/monthly/2025122600/2026062400",
"format": {
"type": "json",
"property": "items"
},
// The response is parsed here, converting date strings of form "20160223" into date 2016-02-23
"transform": [
{ "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": "day", "expr": "parseInt(substring(datum.timestamp,6,8))" },
{ "type": "formula", "field": "date", "expr": "datetime(datum.year,datum.month-1,datum.day)" }
]
}
],
"scales": [
// The dates are scaled to the "x" axis - the width of the graph
{
"name": "x",
"type": "time",
"range": "width",
"domain": {"data": "pageviews","field": "date"}
},
// The pageviews are scaled to the "y" axis - the height of the graph
// Optional scale parameter can change "linear" to other scales like log
// Optional max parameter can fix the upper bound of the graph
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "pageviews","field": "views"},
"clamp": true,
"nice": true } ], // Simple axis with horizontal grid lines
"axes": [
{
"type": "x",
"scale": "x",
"ticks": 5,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
},
{
"type": "y",
"scale": "y",
"ticks": 5,
"grid": true,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"grid": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
}
],
// The graph is drawn with two elements a thick line at the top, and a semi-transparent area below
"marks": [
{
"type": "line",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","field": "views"},
"stroke": {"value": "#00f"},
"strokeWidth": {"value": 3},
"interpolate": {"value": "monotone"}
}
}
},
{
"type": "area",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","value": 0},
"y2": {"scale": "y","field": "views"},
"fill": {"value": "#00f"},
"fillOpacity": {"value": 0.35},
"interpolate": {"value": "monotone"}
}
}
}
]
} </graph> |
{{Graph:PageViews| 180| _| all-projects| granularity = daily}}每日所有维基媒体计划的总访问量数据(最近6个月) |
| <graph>
{ // // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:PageViews // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:PageViews // The graph uses PageViews API https://wikitech.wikimedia.org/wiki/Analytics/PageviewAPI // "version": 2, "width": 570, "height": 200, // The data for this graph comes from the PageView API. The request is made for N days back up to now.
"data": [
{
"name": "pageviews",
"url": "wikirest://wikimedia.org/api/rest_v1/metrics/pageviews/aggregate/all-projects/all-access/user/monthly/2025122600/2026062400",
"format": {
"type": "json",
"property": "items"
},
// The response is parsed here, converting date strings of form "20160223" into date 2016-02-23
"transform": [
{ "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": "day", "expr": "parseInt(substring(datum.timestamp,6,8))" },
{ "type": "formula", "field": "date", "expr": "datetime(datum.year,datum.month-1,datum.day)" }
]
}
],
"scales": [
// The dates are scaled to the "x" axis - the width of the graph
{
"name": "x",
"type": "time",
"range": "width",
"domain": {"data": "pageviews","field": "date"}
},
// The pageviews are scaled to the "y" axis - the height of the graph
// Optional scale parameter can change "linear" to other scales like log
// Optional max parameter can fix the upper bound of the graph
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "pageviews","field": "views"},
"clamp": true,
"nice": true } ], // Simple axis with horizontal grid lines
"axes": [
{
"type": "x",
"scale": "x",
"ticks": 5,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
},
{
"type": "y",
"scale": "y",
"ticks": 5,
"grid": true,
"properties": {
"ticks": {"stroke": {"value": "#666666"} },
"labels": {"fill": {"value": "#666666"} },
"grid": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} },
"axis": {"stroke": {"value": "#666666"}, "strokeWidth": {"value": 2} }
}
}
],
// The graph is drawn with two elements a thick line at the top, and a semi-transparent area below
"marks": [
{
"type": "line",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","field": "views"},
"stroke": {"value": "#00f"},
"strokeWidth": {"value": 3},
"interpolate": {"value": "monotone"}
}
}
},
{
"type": "area",
"from": {"data": "pageviews"},
"properties": {
"enter": {
"x": {"scale": "x","field": "date"},
"y": {"scale": "y","value": 0},
"y2": {"scale": "y","field": "views"},
"fill": {"value": "#00f"},
"fillOpacity": {"value": 0.35},
"interpolate": {"value": "monotone"}
}
}
}
]
} </graph> |
<templatedata> { "params": { "1": { "type": "number", "default": "30", "suggested": true, "label": "统计天数", "description": "图表中统计的天数" }, "2": { "label": "页面标题", "description": "页面标题,带有名字空间,包括所需的空格。设置为'_' ,则显示整个网站的总浏览量。", "type": "wiki-page-name", "default": "当前页面的名称(即使在讨论页上)", "example": "Wikipedia:首页" }, "3": { "label": "域名", "default": "当前的维基媒体计划", "example": "en.wikipedia.org", "type": "string", "description": "从中查找给定标题的页面浏览量的域名(如果不在此维基媒体计划上)。如果参数2设置为 '_',则可在此处填入 'all-projects'所有维基媒体计划网站的浏览量" }, "color": { "label": "图标颜色", "default": "#00f", "example": "#f00", "type": "string", "description": "用于突出显示图表中数据的阴影。" }, "scale": { "label": "图表比例", "description": "缩放比例可以是以下之一:linear, log, pow, sqrt, quantile, quantize, and threshold", "default": "linear", "example": "log", "type": "string" }, "max": { "label": "Y轴最大值", "description": "此可选值可能有助于并排对齐多个图形。", "default": "auto", "example": "10000", "type": "number" }, "width": { "label": "宽度", "description": "图表的宽度(以像素为单位)(如果与默认值不同)。", "type": "number", "default": "800" }, "height": { "label": "高度", "description": "图表的高度(以像素为单位)(如果与默认值不同)。", "type": "number", "default": "200" }, "granularity": { "label": "粒度", "description": "如果第二个参数是 '_'(显示整个网站的统计信息),请设置数据粒度为monthly,daily或hourly", "type": "string", "default": "monthly" } }, "paramOrder": [ "1", "2", "3", "color", "scale", "max", "width", "height", "granularity" ], "format": "inline", "description": "该模板为页面插入过去N天(X轴)的每日综合浏览量统计图(Y轴)。" } </templatedata>