Template:Graph:Moscow Metro expansion
{
"version": 2, "width": 1100, "height": 400,
"data": [
{
"name": "series_fields_names",
"values": [ "l01","l02","l03","l04","l05","l06","l07","l08","l13","l09","l10","l11","l12" ],
"transform": [
{"type": "formula", "field": "orderSrc", "expr": "datum._id"},
]
},
{
"name": "chart",
"url": "tabular:///moscow subway station counts.tab",
"format": {"type": "json"
, "property": "data"
}, "transform": [
{"type": "formula", "field": "_xfield", "expr":
"datetime(datum.year, 0, 1)"
},
{"type": "sort", "by": ["_xfield"]},
{"type": "fold", "fields": ["l01","l02","l03","l04","l05","l06","l07","l08","l13","l09","l10","l11","l12"]},
{"type": "lookup", "on": "series_fields_names", "onKey": "data", "keys": ["key"], "as": ["keyItem"]},
{"type": "formula", "field": "keyOrder", "expr": "datum.keyItem.orderSrc"},
{
"type": "impute",
"groupby": ["key"],
"orderby": ["_xfield"],
"field": "value",
"method": "value",
"value": 0
},
]
},
{
"name": "labels",
"url": "tabular:///moscow subway station counts.tab",
"format": {"type": "json", "property": "fields"},
"transform": [
] },
{
"name": "stats",
"source": "chart",
"transform": [{
"type": "aggregate",
"groupby": ["_xfield"],
"summarize": [{"field": "value", "ops": ["sum"]}]
}]
}
],
"scales": [
{
"name": "x",
"type": "time",
"domain": {"data": "chart", "field": "_xfield"},
"range": "width",
},
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "stats", "field": "sum_value"},
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "chart", "field": "key"},
"range":
["#D92B2C", "#4DC6F4", "#2C75C4", "#4DBE52", "#85412E", "#F07025", "#89339E", "#80D4C9", "#80D4C9", "#FBC81E", "#9F9F9F", "#A8D92D", "#B0BFE7"],
},
{
"name": "labels",
"type": "ordinal",
"domain": {"data": "labels", "field": "name"},
"range": {"data": "labels", "field": "title"},
}
],
"legends": [{
"fill": "color", "stroke": "color",
"title": "Line", "properties": { "labels": { "text": {"scale": "labels", "field": "data"} } }
}],
"axes": [
{
"scale": "x", "type": "x", "tickSizeEnd": 0,
"ticks": 7,
"properties": {
"labels": {
}
},
},
{
"scale": "y", "type": "y", "tickSizeEnd": 0,
"title": "Number of stations",
"grid": true,
"properties": {
"labels": {
}
},
}
],
"marks": [
{
"type": "group",
"from": {
"data": "chart",
"transform": [
{"type": "stack", "groupby": ["_xfield"], "sortby": ["-keyOrder"], "field": "value"},
{"type": "facet", "groupby": ["key"]}
]
},
"marks": [
{
"type": "area",
"properties": {
"hover": {
"fill": {"value": "red"}
},
"update": {
"fill": {"scale": "color", "field": "key"}
},
"enter": {
"x": {"scale": "x", "field": "_xfield"},
"y": {"scale": "y", "field": "layout_start"},
"y2": {"scale": "y", "field": "layout_end"},
"fill": {"scale": "color", "field": "key"},
"interpolate": {"value": "monotone"}
}
}
}
],
},
{
"type": "text",
"properties": {
"enter": {
"y": {"value": -15},
"x": {"signal": "width", "mult": 0.5, "offset": 30 },
"text": {"value": "Moscow subway growth"},
"fontWeight": {"value": "bold"},
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#000"}
}
}
}
]
} </graph>
| This template uses TemplateStyles: |
You can find the data for this template at c:Data:Moscow_subway_station_counts.tab.
Graph for the Moscow Metro station count over the years. Stations are grouped by lines. Lines are colour-coded.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| 1 | 1 | graph width
| Number | suggested |
| 2 | 2 | graph height
| Number | suggested |