<graph mode=interactive>
{
"version": 2,
"width": 5001,
"height": 2601,
"paddingdata": 12,[
"background": "#edf1f7",
"data": [
{
"name": "countryNames",
"url": "wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fid%20%3Fvalue%20WHERE%20%7B%0A%20%20%20%7B%20SELECT%20DISTINCT%20%3Fid%20%20WHERE%20%7B%0A%20%20%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%20%20%20%7D%20%7D%0A%20%20%20%3Fid%20wdt%3AP299%20%3Fcode%20.%0A%20%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cen%22%20.%0A%20%20%20%20%20%3Fid%20rdfs%3Alabel%20%3Fvalue%0A%20%20%20%7D%0A%7D%0A",
"format": { "type": "json" }
},
{
"name": "countryPopulation",
"url": "wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fid%20%3Fvalue%20WHERE%20%7B%0A%20%20%20%7B%20SELECT%20DISTINCT%20%3Fid%20%20WHERE%20%7B%0A%20%20%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%20%20%20%7D%20%7D%0A%20%20%20%3Fid%20wdt%3AP299%20%3Fcode%20.%0A%20%20%20%3Fid%20wdt%3AP1082%20%3Fvalue%20.%0A%7D%0A",
"format": { "type": "json" }
},
{
"name": "museumCounts",
"url":"wikidatasparql:///?query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20DISTINCT%20%3Fid%20(count(*)%20as%20%3Fvalue)%20WHERE%20%7B%0A%20%20%20%3Fplace%20wdt%3AP31%2Fwdt%3AP279*%20wd%3AQ33506%20.%0A%20%20%20%3Fplace%20wdt%3AP17%20%3Fid%20.%0A%7D%0A%0AGROUP%20BY%20%3Fid",
"format": { "type": "json" }
},
{
"name": "map",
"url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-json",
"format": {"type": "topojson","feature": "countries"},
"transform": [
{
"typename": "geopathhighlights",
"values": [{"id":"US","v":"blue"},{"id":"AU","v":"purple"},{"id":"CN","v":"red"},{"id":"BR","v":"pink"},{"id":"DZ","v":"green"}]
"value": "data",
"scale": 80,
"center": [-180,125],
"translate": [0,0],
"projection": "equirectangular"
},
{
"typename": "lookupcountries",
"keysurl": ["idwikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json"],
"format": {"type": "topojson", "onfeature": "countryNamescountries"},
"onKeytransform": "id",[
"as": ["name"], {
"default": {"value": { "valuetype": "???geopath"} },
} "value": "data",
{ "type": "formula", "field": "name", "exprscale": "datum.name.value" }80,
"translate":[0,0],
"projection": "equirectangular"
},
{
"type": "lookup",
"keys": [ "id" ],
"on": "highlights",
"onKey": "id",
"as": [ "zipped" ],
"default": {
"v": "#C0C0C0"
}
}
]
}
],
"marks": [
{
"type": "lookuppath",
"keysfrom": ["id"],{
"ondata": "countryPopulationcountries",
"onKey": "id",
"as": ["population"],
"default": {"value": {"value": 0} }
},
{ "type": "formula", "field": "population", "expr": "datum.population.value" },
{
"type": "lookup",
"keys": ["id"],
"on": "museumCounts",
"onKey": "id",
"as": ["museums"],
"default": {"value": {"value": 0} }
},
{ "type": "formula", "field": "museums", "expr": "datum.museums.value" },
{
"type": "formula",
"field": "rate",
"expr": "datum.population > 0 && datum.museums > 0 ? (datum.museums / datum.population) : 0.000000001"
}
]
}
],
"signals": [
{
"name": "tooltipSignal",
"init": {"expr": "{x: 0, y: 0, datum: {name:'', population:'', museums:''} }"},
"streams": [
{
"type": "@map:mouseover",
"expr": "{x: eventX(), y: eventY(), datum: eventItem().datum}"
},
{
"type": "@map:mouseout",
"expr": "{x: 0, y: 0, datum: {name:'', population:'', museums:''} }"
}
]
}
],
"scales": [
{
"name": "color",
"type": "log",
"domain": {"data": "map","field": "rate"},
"zero": false,
"range": ["#FFEDBC", "#f83600"]
}
],
"marks": [
{
"type": "text",
"properties": {
"enter": {
"text": {"value": "Museums"},
"x": {"value": 0},
"y": {"value": 25},
"fontSize": {"value": 32},
"fontWeight": {"value": "bold"},
"fill": {"value": "steelblue"}
}
}
},
{
"name": "map",
"type": "path",
"from": {"data": "map"},
"properties": {
"enter": {"path": {"field": "layout_path"} },
"update": {
"fill": [
{
"test": "datum.rate !== null",
"scale": "color",
"field": "rate"
},
{"valueproperties": "grey"}{
] "enter": {
}, "path": {
"hover": {"fill": { "valuefield": "#989898layout_path"} }
}
},
"update": {
{
"typefill": "text",{
"propertiesfield": {"zipped.v"
"enter": { }
"x": {"value": 500 },
"y": { "valuehover": 10},{
"align": { "valuefill": "right"},{
"fontSize": { "value": 17},"#989898"
"fill": {"value": "black" }
},
"update": { }
"text": {"template": "\u007b{tooltipSignal.datum.name}\u007d \u007b{tooltipSignal.datum.museums}\u007d"}
}
}
}
],
"legends": [
{
"fill": "color",
"title": "Per Capita",
"offset": -300,
"properties": {
"labels": {
"text": {"value": ""}
},
"gradient": {
"stroke": {"value": "transparent"}
},
"title": {
"fontSize": {"value": 14}
},
"legend": {
"x": {"value": 0},
"y": {"value": 180}
}
}]
}
]
}
</graph>
|