Changes
Extension:Graph/Demo/MapTemplate (view source)
Revision as of 07:56, 29 January 2016
, 07:56, 29 January 2016switched to wikiraw://
{{#tag:graph|
{
"version": 2,
"width": {{{width|1}}},
"height": {{{height|1}}},
"data": [
{
"name": "highlights",
"url": "wikiraw:///Extension:Graph/Demo/RawData:PopulationByCountryHistoric-csv",
"format": {"type": "csv"},
"transform": [
{
"type": "formula",
"field": "v",
"expr": "parseInt(datum['2010'])"
}
]
},
{
"name": "countries",
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json",
"format": {"type": "topojson", "feature": "countries"},
"transform": [
{
"type": "geopath",
"value": "data",
"scale": {{{scale|100}}},
"translate":[0,0],
"projection": "equirectangular"
},
{
"type": "lookup",
"keys": ["id"],
"on": "highlights",
"onKey": "id",
"as": ["zipped"],
"default": { "v": 0 }
}
]
}
],
"scales": [
{
"name": "color",
"type": "{{{type|quantize}}}",
"domain": {"data": "highlights", "field": "v"},
"zero": true,
"range": {{{colors|"category20"}}}
}
],
"legends": [
{
"fill": "color",
"offset":-300,
"title": "{{{legend|Legend}}}",
"properties": {
"gradient": {
"stroke": {"value": "transparent"}
},
"title": {
"fontSize": {"value": 14}
},
}
}
],
"marks": [
{
"type": "path",
"from": {
"data": "countries"
},
"properties": {
"enter": {
"path": {
"field": "layout_path"
}
},
"update": { "fill": {"scale":"color", "field":"zipped.v"} },
"hover": {
"fill": {
"value": "#989898"
}
}
}
}
]
}
}}<noinclude>
params:
# source data (default = <nowiki>{{#invoke:Graph:Utils|parseCsv|Extension:Graph/Demo/RawData:PopulationByCountryHistoric-csv|2010}}</nowiki>)
#: The data source must contain two columns: 'id' and 'v'
Optional params:
* type: linear, log, pow, sqrt, quantile, quantize, or threshold
* colors: list of colors, e.g. ["#F2F2AB","#F1E9A4","#F0E09D",...]
* width (1 by default)
* height (1 by default)
* scale (100 by default)
</noinclude>
{
"version": 2,
"width": {{{width|1}}},
"height": {{{height|1}}},
"data": [
{
"name": "highlights",
"url": "wikiraw:///Extension:Graph/Demo/RawData:PopulationByCountryHistoric-csv",
"format": {"type": "csv"},
"transform": [
{
"type": "formula",
"field": "v",
"expr": "parseInt(datum['2010'])"
}
]
},
{
"name": "countries",
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json",
"format": {"type": "topojson", "feature": "countries"},
"transform": [
{
"type": "geopath",
"value": "data",
"scale": {{{scale|100}}},
"translate":[0,0],
"projection": "equirectangular"
},
{
"type": "lookup",
"keys": ["id"],
"on": "highlights",
"onKey": "id",
"as": ["zipped"],
"default": { "v": 0 }
}
]
}
],
"scales": [
{
"name": "color",
"type": "{{{type|quantize}}}",
"domain": {"data": "highlights", "field": "v"},
"zero": true,
"range": {{{colors|"category20"}}}
}
],
"legends": [
{
"fill": "color",
"offset":-300,
"title": "{{{legend|Legend}}}",
"properties": {
"gradient": {
"stroke": {"value": "transparent"}
},
"title": {
"fontSize": {"value": 14}
},
}
}
],
"marks": [
{
"type": "path",
"from": {
"data": "countries"
},
"properties": {
"enter": {
"path": {
"field": "layout_path"
}
},
"update": { "fill": {"scale":"color", "field":"zipped.v"} },
"hover": {
"fill": {
"value": "#989898"
}
}
}
}
]
}
}}<noinclude>
params:
# source data (default = <nowiki>{{#invoke:Graph:Utils|parseCsv|Extension:Graph/Demo/RawData:PopulationByCountryHistoric-csv|2010}}</nowiki>)
#: The data source must contain two columns: 'id' and 'v'
Optional params:
* type: linear, log, pow, sqrt, quantile, quantize, or threshold
* colors: list of colors, e.g. ["#F2F2AB","#F1E9A4","#F0E09D",...]
* width (1 by default)
* height (1 by default)
* scale (100 by default)
</noinclude>