Jump to content

Template:Graph:Lines: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
add a line break
No edit summary
Line 46: Line 46:
"range": "width",
"range": "width",
{{#if:{{{xZero|}}}|"zero": {{{xZero}}},}}
{{#if:{{{xZero|}}}|"zero": {{{xZero}}},}}
{{#if:{{{xMin|}}}|"domainMin": {{{xMin}}},}}
{{#if:{{{xMax|}}}|"domainMax": {{{xMax}}},}}
},
},
{
{
Line 53: Line 55:
"domain": {"data": "chart", "field": "value"},
"domain": {"data": "chart", "field": "value"},
{{#if:{{{yZero|}}}|"zero": {{{yZero}}},}}
{{#if:{{{yZero|}}}|"zero": {{{yZero}}},}}
{{#if:{{{yMin|}}}|"domainMin": {{{yMin}}},}}
{{#if:{{{yMax|}}}|"domainMax": {{{yMax}}},}}
},
},
{
{
Line 66: Line 70:
"range": {"data": "labels", "field": "title"},
"range": {"data": "labels", "field": "title"},
}
}
]
],
{{#if:{{{legend|}}}|
{{#if:{{{legend|}}}|
, "legends": [{
"legends": [{
"fill": "color",
"fill": "color",
"stroke": "color",
"stroke": "color",

Revision as of 00:46, 20 December 2016

<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:///bls.gov/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:///bls.gov/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>