User:Yair rand/Wiki readership map

{ "version": 2, "width": 1250, "height": 670, "padding": 12, "background": "#edf1f7", "data": [ {     "name": "map", "url": "wikiraw:///Extension:Graph/Demo/RawData:WorldMap-iso2-json", "format": {"type": "topojson","feature": "countries"}, "transform": [ {         "type": "geopath", "value": "data", "scale": 180, "center": [-180,125], "translate": [0,0], "projection": "equirectangular" }     ]    },    {      "name": "spu", "url": "tabular:///Pageviews-by-country-monthly-2020-01.tab", "format":{ "":"wiki_db,country,count", "type":"json","property":"data" },     "transform":[ {     		"type":"filter", "test":"1||(test(/wiki$/,datum.wiki_db) && indexof(['commonswiki','metawiki','mediawikiwiki','wikidatawiki'],datum.wiki_db) == -1)" }     ]    },    {      "name": "spup", "source":"spu", "transform": [ {         "type": "aggregate", "groupby": ["wiki_db"], "summarize":{"count":"sum"} },       {        	"type":"sort", "by":["-sum_count"] },       {        	"type":"rank", "field":"sum-count" }     ]    },    {      "name": "spup2", "source":"spup", "transform": [ {     		"type":"filter", "_test":"indexof(['enwiki','frwiki','dewiki','jawiki','eswiki'],datum.wiki_db)!=-1", "test":"datum.rank < 48" }     ]    },    {      "name": "spug", "source":"spu", "transform": [ {         "type": "aggregate", "groupby": ["country"], "summarize":{"count":"sum"} }     ]    },    {      "name": "spuzz", "source":"spu", "transform": [ {       	"type":"lookup", "on":"spup", "onKey":"wiki_db", "keys":["wiki_db"], "as":["db_count"] },       {        	"":"wiki_db,country,count", "type": "facet", "groupby": ["country"], "transform":[ {	       	"type":"sort", "by":"-db_count.sum_count" },         	{"type":"pie","field":"count"}, {	     		"type":"filter", "description":"For performance...", "test":"datum.count > 100" }     	  ]        }      ]    },    {      "name":"bo", "url":"wikidatasparql:///?query=SELECT%20%3Fcode%20%3Fcoords%20WHERE%20%7B%0A%20%20%3Fq%20wdt%3AP297%20%3Fcode%3B%0A%20%20%20%20%20wdt%3AP625%20%3Fcoords%20.%0A%7D", "transform": [ {         "type": "geo", "projection": "equirectangular", "scale": 180, "center": [-180,125], "translate": [0,0], "lon": "coords[0]", "lat": "coords[1]" }     ]    },    {    	"name":"mo", "source":"spuzz", "transform":[ {	       	"type":"lookup", "on":"bo", "onKey":"code", "keys":["country"], "as":["objq"] },	       {	        	"type":"lookup", "on":"spug", "onKey":"country", "keys":["country"], "as":["big"] },	       {	        	"type":"filter", "test":"datum.objq" },	       {	        	"type":"sort", "by":"-big.sum_count" }		]   }  ],

"signals": [ {     "name": "tooltip", "init": {}, "streams": [ {         "type": "arc:mouseover", "expr": "{'count':format(',',datum.count),wiki_db:datum.wiki_db,tc:format('.1%',datum.count/parent.big.sum_count),'pp':format('.1%',datum.count/datum.db_count.sum_count),'country':datum.country}" },       {          "type": "@bee:mouseover", "expr": "{'wiki_db':datum.wiki_db,'count':format(',',datum.sum_count)}", "_expr": "{'wiki_db':'viwiki'}", "_":",'wiki_db_':datum.label" },       {"type": "arc:mouseout", "expr": "{}"}, {"type": "@bee:mouseout", "expr": "{}"} ]   }  ],  "scales":[ {     "name": "color", "type": "ordinal", "_domain": {"data": "spu", "field": "wiki_db"}, "_sort":{"field":"wiki_db"}, "range": "category20", "_range":["orange","blue","red","green"] },   {      "name": "psize", "type": "sqrt", "domain": {"data": "spug", "field": "sum_count"}, "_domain": [0,4000000], "range": [0,50] },   {      "name": "legb", "type": "ordinal", "domain": { "data": "spup2", "field": "wiki_db","sort":{"field":"sum_count","op":"median"} },     "reverse":true, "range": [0,700] } ],  "marks": [ {     "name": "map", "type": "path", "from": {"data": "map"}, "properties": { "enter": { "fill": {"value": "grey"}, "path": {"field": "layout_path"} }     }    },    {      "name": "circle5", "type": "group", "from": { "data": "mo" },     "properties": { "enter": { "x": {"field": "objq.layout_x"}, "y": {"field": "objq.layout_y"} }     },      "marks":[ {	     "type": "text", "properties": { "enter": { "__text": {"field":{"parent":"code"}}, "text": {"field":"wiki_db"}, "_text": {"value":"O"}, "fill":{"value":"transparent"} }	     }	    },	    {	      "type": "arc", "properties": { "enter": { "startAngle": {"field": "layout_start"}, "endAngle": {"field": "layout_end"}, "outerRadius": {"field": {"parent":"big.sum_count"},"scale":"psize"}, "stroke": {"value": "#fff"}, "fill": {"field": "wiki_db","scale":"color"} },	       "hover":{ "strokeWidth":{"value":1} },	       "update":{ "strokeWidth":[ { "test": "tooltip.wiki_db && tooltip.wiki_db == datum.wiki_db && datum.count == 1", "value": 10 },	           { "test": "tooltip.wiki_db && tooltip.wiki_db == datum.wiki_db", "value": 0.5 },	           {"value":0.25}], "opacity": [ { "test": "tooltip.wiki_db && tooltip.wiki_db != datum.wiki_db", "value": 0.1 },	           {"value": 1} ]	       }	      }	    }      ]    },    {      "type":"group", "properties":{ "enter":{ "x":{"value":25}, "y":{"value":0}, "fill":{"value":"white"}, "width":{"value":110}, "height":{"value":700} }     },      "marks":[ {     	  "type":"text", "properties":{ "enter":{ "text": {"value":"Wikis:"}, "fontWeight":{"value":"bold"}, "fill":{"value":"black"}, "x":{"value":5}, "y":{"value":15} }     	  }      	}	  ]    },    {      "from": { "data": "spup2" },     "name":"bee", "type": "rect", "properties": { "enter": { "fill": {"field": "wiki_db","scale":"color"}, "_width":{"value":"10"}, "height":[ {"test":"datum._id<1000","value":0},{"value":"10"}], "x":{"value":30}, "x2":{"value":40}, "y": {"scale":"legb","field": "wiki_db","offset":5} },	   "update":{ "opacity": [ {             "test": "tooltip.wiki_db && tooltip.wiki_db != datum.wiki_db", "value": 0.25 },           {"value": 1} ]       }      }    },    {      "from": { "data": "spup2" },"name":"bee", "type": "text", "properties": { "enter": { "_text": {"field":{"parent":"wiki_db"}}, "text": {"field":"wiki_db"}, "__text": {"value":"O"}, "fill":{"value":"black"}, "_fill":{"scale":"color","field": "wiki_db"}, "fontSize":{"value":10}, "x":{"value":43}, "y2": {"scale":"legb","field": "wiki_db","offset":13} },	   "update":{ "opacity": [ {             "test": "tooltip.wiki_db && tooltip.wiki_db != datum.wiki_db", "value": 0.25 },           {"value": 1} ]       }      }    },    {      "type":"text", "properties":{ "update":{ "_text":{"value":"ta"}, "text": [ {"test":"tooltip.tc","template": "\u007b{tooltip.wiki_db}}: \u007b{tooltip.count}},000 views, \u007b{tooltip.tc}} of country (\u007b{tooltip.country}}), \u007b{tooltip.pp}} of \u007b{tooltip.wiki_db}}"}, {"template": "\u007b{tooltip.wiki_db}}: \u007b{tooltip.count}},000 views (all countries)"} ],         "fill":{"value":"black"}, "x":{"value":155}, "y":{"value":125}, "opacity": [ {           "test": "!tooltip.wiki_db", "value": 0 },           {"value": 1} ]       }      }    }  ] }