משתמש:Tzafrir/Graph:Lines
המידע מטה מוצג מתוך הדף משתמש:Tzafrir/Graph:Lines/תיעוד.
This graph's main version resides at Template:Graph:Lines. Please make or suggest all the changes there, and copy it everywhere else (until the copying is automated)
{{Tzafrir | data=Earnings/US Women's weekly earnings as a percent of men's by age, annual averages.tab |
---|
תבנית:Tzafrir |
This graph draws one or more independent numeric data series as lines. The data must be stored on Commons' Data namespace.
פרמטר | תיאור | סוג | מצב | |
---|---|---|---|---|
data | data | Data page name on Commons, without the Data: prefix. The table should contain xField column, like year or date, and one or more series columns to plot | מחרוזת | דרוש |
type | type | Type of the x axis - time (e.g. "2015-10" or "2013-03-08), year (integer, but treated as a year), linear (numbers), ordinal (anything)
| מחרוזת | מוצע |
xField | xField | Id of the data column that contains values for the X axis. If type=year, xField is also "year" by default. | מחרוזת | דרוש |
series | series | List of the data columns to show as lines. Must be listed by field IDs: "field1", "field2", "field3". | מחרוזת | דרוש |
xZero | xZero | Force to start or not to start X axis with zero. Can be either true or false | מחרוזת | לא חובה |
yZero | yZero | Force to start or not to start Y axis with zero. Can be either true or false | מחרוזת | לא חובה |
xAxis | xAxis | Title of the X axis | מחרוזת | לא חובה |
yAxis | yAxis | Title of the Y axis | מחרוזת | לא חובה |
title | title | Title of the whole graph | מחרוזת | לא חובה |
legend | legend | Title of the legend | מחרוזת | לא חובה |
width | width | אין תיאור | מספר | לא חובה |
height | height | אין תיאור | מספר | לא חובה |
debug | debug | if set, will show graph as raw JSON | מחרוזת | לא חובה |
<graph>
{
//
// ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Lines
// 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:Lines
//
"version": 2,
"width": 300,
"height": 200,
"data": [{
"name": "chart",
"url": "tabular:///Earnings/US Women's weekly earnings as a percent of men's by age, annual averages.tab",
"format": {"type": "json", "property": "data"
},
"transform": [
// Convert xField parameter into a field "_xfield"
{"type": "formula", "field": "_xfield", "expr":
"datetime(datum.year, 0, 1)"
},
{"type": "fold", "fields": ["age_16_24", "age_25_34", "age_35_44", "age_45_54"]}
]
},
{
"name": "labels",
"url": "tabular:///Earnings/US Women's weekly earnings as a percent of men's by age, annual averages.tab",
"format": {"type": "json", "property": "schema.fields"}
}],
"scales": [
{
"name": "x",
"type": "time",
"domain": {"data": "chart", "field": "_xfield"},
"range": "width",
},
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "chart", "field": "value"},
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "chart", "field": "key"},
"range": "category10"
},
{
"name": "labels",
"type": "ordinal",
"domain": {"data": "labels", "field": "name"},
"range": {"data": "labels", "field": "title"},
}
]
"axes": [
{"scale": "x", "type": "x", "ticks": 7
},
{"scale": "y", "type": "y"
}
],
"marks": [
// Group data by the "key", and draw lines, one line per key
{
"type": "group",
"from": {
"data": "chart",
"transform": [{"groupby": ["key"], "type": "facet"}]
},
"marks": [
{
"type": "line",
"properties": {
"enter": {
"y": {"scale": "y", "field": "value"},
"x": {"scale": "x", "field": "_xfield"},
"stroke": {"scale": "color", "field": "key"},
"interpolate": {"value": "monotone"},
"strokeWidth": {"value": 2.5}
}
}
}
],
}
]
}
</graph>