משתמש: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
| type=year
| xField=year
| series="age_16_24", "age_25_34", "age_35_44", "age_45_54"
| yZero=false
| title=Gender pay gap in the United States
| xAxis=Year
| yAxis=Percentage
| legend=Age group
}}

תבנית:Tzafrir

This graph draws one or more independent numeric data series as lines. The data must be stored on Commons' Data namespace.

פרמטרים של תבניות

פרמטרתיאורסוגמצב
Datadata

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

מחרוזתדרוש
Typetype

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)

ערך התחלתי
year
מחרוזתמוצע
XFieldxField

Id of the data column that contains values for the X axis. If type=year, xField is also "year" by default.

מחרוזתדרוש
Seriesseries

List of the data columns to show as lines. Must be listed by field IDs: "field1", "field2", "field3".

מחרוזתדרוש
XZeroxZero

Force to start or not to start X axis with zero. Can be either true or false

מחרוזתלא דרוש
YZeroyZero

Force to start or not to start Y axis with zero. Can be either true or false

מחרוזתלא דרוש
XAxisxAxis

Title of the X axis

מחרוזתלא דרוש
YAxisyAxis

Title of the Y axis

מחרוזתלא דרוש
Titletitle

Title of the whole graph

מחרוזתלא דרוש
Legendlegend

Title of the legend

מחרוזתלא דרוש
Widthwidth

אין תיאור

מספרלא דרוש
Heightheight

אין תיאור

מספרלא דרוש
Debugdebug

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>