Template:Graph:Saint Petersburg Metro expansion

From MOASSpedia
Jump to navigation Jump to search

<graph> {

 //
 // ATTENTION: This code is maintained at https://en.wikipedia.org/wiki/Template:Graph:Saint_Petersburg_Metro_expansion
 //            Please do not modify it anywhere else, as it may get copied and override your changes.
 //            Suggestions can be made at https://en.wikipedia.org/wiki/Template_talk:Graph:Saint_Petersburg_Metro_expansion
 //
 //            This graph uses data from https://en.wikipedia.org/wiki/Template:Graph:Saint_Petersburg_Metro_expansion/Data-json
 //
 "version": 2,
 "width": 1100,
 "height": 400,
 "data": [
   {
     "name": "table",
     "url": "wikiraw://en.wikipedia.org/Template:Graph:Saint Petersburg Metro expansion/Data-json",
     "format": {"type": "json"}
   },
   {
     "name": "stats",
     "source": "table",
     "transform": [
       { "type": "aggregate", "groupby": ["y"], "summarize": {"n": "sum"} },
     ]
   }
 ],
 "scales": [
   {
     "name": "scale_years",
     "type": "linear",
     "domain": {"data": "table", "field": "y"},
     "range": "width",
     "zero": false
   },
   {
     "name": "scale_stations",
     "type": "linear",
     "domain": {"data": "stats", "field": "sum_n"},
     "range": "height"
   },
   {
     "name": "scale_colour",
     "type": "ordinal",
     "domain": [1,2,3,4,5,6],
 "range": [ "#EF161E", "#0000ff", "#008000", "#ffa500", "#540099", "#964b00"]
   }],
 "axes": [
   {
     "type": "x",
     "scale": "scale_years",
     "title": "Year",
     "values": [1955,1965,1975,1985,1995,2005,2015,2025],
     "subdivide": 10,
     "tickSizeMinor": 5,
     "tickSizeEnd": 0,
     "format": "f"
   },
   {
     "type": "y",
     "scale": "scale_stations",
     "title": "Number of stations"
   },
   {
     "type": "y",
     "scale": "scale_stations",
     "title": "Number of stations",
     "orient": "right"
   }
 ],
 "marks": [
   {
     "type": "group",
     "from": {
       "data": "table",
       "transform": [
         {"type": "stack","groupby": "y","sortby":"l", "field": "n"},
         {"type": "facet","groupby": ["l"]}
       ]
     },
     "marks": [
       {
         "type": "area",
         "properties": {
           "enter": {
             "interpolate": {"value": "linear"},
             "x": {"scale": "scale_years","field": "y"},
             "y": {"scale": "scale_stations","field": "layout_start"},
             "y2": {"scale": "scale_stations","field": "layout_end"},
             "fill": {"scale": "scale_colour","field": "l"}
           }
         }
       }
     ]
   }
 ]

}

</graph>