Created
May 22, 2020 19:03
-
-
Save ficolo/9d9f6fb7c2b737f697fe6c3c3d6bf88e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v5.json", | |
"width": 900, | |
"height": 500, | |
"autosize": "none", | |
"signals": [ | |
{ | |
"name": "hover", | |
"value": null, | |
"on": [ | |
{ | |
"events": "@cell:mouseover", | |
"update": "datum" | |
}, | |
{ | |
"events": "@cell:mouseout", | |
"update": "null" | |
} | |
] | |
}, | |
{ | |
"name": "title", | |
"value": "CovidIP - Collaborators Network", | |
"update": "hover ? hover.name : 'CovidIP - Collaborators Network'" | |
}, | |
{ | |
"name": "tx", | |
"update": "width / 2" | |
}, | |
{ | |
"name": "ty", | |
"update": "height / 2" | |
}, | |
{ | |
"name": "scale", | |
"value": 150, | |
"on": [ | |
{ | |
"events": { | |
"type": "wheel", | |
"consume": true | |
}, | |
"update": "clamp(scale * pow(1.0005, -event.deltaY * pow(16, event.deltaMode)), 150, 3000)" | |
} | |
] | |
}, | |
{ | |
"name": "angles", | |
"value": [ | |
0, | |
0 | |
], | |
"on": [ | |
{ | |
"events": "mousedown", | |
"update": "[rotateX, centerY]" | |
} | |
] | |
}, | |
{ | |
"name": "cloned", | |
"value": null, | |
"on": [ | |
{ | |
"events": "mousedown", | |
"update": "copy('projection')" | |
} | |
] | |
}, | |
{ | |
"name": "start", | |
"value": null, | |
"on": [ | |
{ | |
"events": "mousedown", | |
"update": "invert(cloned, xy())" | |
} | |
] | |
}, | |
{ | |
"name": "drag", | |
"value": null, | |
"on": [ | |
{ | |
"events": "[mousedown, window:mouseup] > window:mousemove", | |
"update": "invert(cloned, xy())" | |
} | |
] | |
}, | |
{ | |
"name": "delta", | |
"value": null, | |
"on": [ | |
{ | |
"events": { | |
"signal": "drag" | |
}, | |
"update": "[drag[0] - start[0], start[1] - drag[1]]" | |
} | |
] | |
}, | |
{ | |
"name": "rotateX", | |
"value": 0, | |
"on": [ | |
{ | |
"events": { | |
"signal": "delta" | |
}, | |
"update": "angles[0] + delta[0]" | |
} | |
] | |
}, | |
{ | |
"name": "centerY", | |
"value": 0, | |
"on": [ | |
{ | |
"events": { | |
"signal": "delta" | |
}, | |
"update": "clamp(angles[1] + delta[1], -60, 60)" | |
} | |
] | |
} | |
], | |
"projections": [ | |
{ | |
"name": "projection", | |
"type": "mercator", | |
"scale": { | |
"signal": "scale" | |
}, | |
"rotate": [ | |
{ | |
"signal": "rotateX" | |
}, | |
0, | |
0 | |
], | |
"center": [ | |
0, | |
{ | |
"signal": "centerY" | |
} | |
], | |
"translate": [ | |
{ | |
"signal": "tx" | |
}, | |
{ | |
"signal": "ty" | |
} | |
] | |
} | |
], | |
"data": [ | |
{ | |
"name": "colors", | |
"url": "https://docs.google.com/spreadsheets/d/e/2PACX-1vTT7qlilT0ltZNRpjvMAE2Iag8PcCqG2iPWmYc_ZHx8rXpIL58qCYYJw5rIrISzCNz9670WEvvpFlp0/pub?gid=1135472517&single=true&output=csv", | |
"format": { | |
"type": "csv", | |
"delimiter": "," | |
} | |
}, | |
{ | |
"name": "world", | |
"url": "https://raw.githubusercontent.com/vega/vega/master/docs/data/world-110m.json", | |
"format": { | |
"type": "topojson", | |
"feature": "countries" | |
}, | |
"transform": [ | |
{ | |
"type": "formula", | |
"as": "color", | |
"expr": "'map'" | |
}, | |
{ | |
"type": "lookup", | |
"from": "colors", | |
"key": "type", | |
"fields": [ | |
"color" | |
], | |
"values": [ | |
"color" | |
], | |
"as": [ | |
"color" | |
] | |
} | |
] | |
}, | |
{ | |
"name": "nodes", | |
"transform": [ | |
{ | |
"type": "filter", | |
"expr": "datum.latitude != '' && datum.longitude != ''" | |
}, | |
{ | |
"type": "lookup", | |
"from": "colors", | |
"key": "type", | |
"fields": [ | |
"type" | |
], | |
"values": [ | |
"color" | |
], | |
"as": [ | |
"color" | |
] | |
}, | |
{ | |
"type": "geopoint", | |
"projection": "projection", | |
"fields": [ | |
"longitude", | |
"latitude" | |
] | |
}, | |
{ | |
"type": "voronoi", | |
"x": "x", | |
"y": "y" | |
}, | |
{ | |
"type": "collect", | |
"sort": { | |
"field": "size", | |
"order": "descending" | |
} | |
} | |
], | |
"format": { | |
"type": "csv", | |
"delimiter": "," | |
}, | |
"url": "https://docs.google.com/spreadsheets/d/e/2PACX-1vTT7qlilT0ltZNRpjvMAE2Iag8PcCqG2iPWmYc_ZHx8rXpIL58qCYYJw5rIrISzCNz9670WEvvpFlp0/pub?gid=396281426&single=true&output=csv" | |
}, | |
{ | |
"name": "links", | |
"transform": [ | |
{ | |
"type": "formula", | |
"as": "institutionArray", | |
"expr": "split(datum.institutions, ',')" | |
}, | |
{ | |
"type": "flatten", | |
"fields": [ | |
"institutionArray" | |
], | |
"as": [ | |
"institution" | |
] | |
}, | |
{ | |
"type": "project", | |
"fields": [ | |
"origin", | |
"institution" | |
], | |
"as": [ | |
"src", | |
"tgt" | |
] | |
}, | |
{ | |
"type": "filter", | |
"expr": "hover && (hover.id == datum.src || hover.id == datum.tgt)" | |
}, | |
{ | |
"type": "lookup", | |
"from": "nodes", | |
"key": "id", | |
"fields": [ | |
"src", | |
"tgt" | |
], | |
"as": [ | |
"source", | |
"target" | |
] | |
}, | |
{ | |
"type": "filter", | |
"expr": "datum.source && datum.target" | |
}, | |
{ | |
"type": "geopoint", | |
"projection": "projection", | |
"fields": [ | |
"source.longitude", | |
"target.latitude" | |
] | |
}, | |
{ | |
"type": "linkpath", | |
"shape": "curve" | |
} | |
], | |
"url": "https://docs.google.com/spreadsheets/d/e/2PACX-1vTT7qlilT0ltZNRpjvMAE2Iag8PcCqG2iPWmYc_ZHx8rXpIL58qCYYJw5rIrISzCNz9670WEvvpFlp0/pub?gid=231154972&single=true&output=csv", | |
"format": { | |
"type": "csv", | |
"delimiter": "," | |
} | |
} | |
], | |
"scales": [ | |
{ | |
"name": "size", | |
"type": "linear", | |
"domain": { | |
"data": "nodes", | |
"field": "count" | |
}, | |
"range": [ | |
16, | |
256 | |
] | |
} | |
], | |
"marks": [ | |
{ | |
"type": "shape", | |
"from": { | |
"data": "world" | |
}, | |
"encode": { | |
"enter": { | |
"strokeWidth": { | |
"value": 0.5 | |
}, | |
"stroke": { | |
"value": "#FFF" | |
}, | |
"fill": { | |
"field": "color" | |
} | |
} | |
}, | |
"transform": [ | |
{ | |
"type": "geoshape", | |
"projection": "projection" | |
} | |
] | |
}, | |
{ | |
"type": "symbol", | |
"from": { | |
"data": "nodes" | |
}, | |
"encode": { | |
"enter": { | |
"size": { | |
"scale": "size", | |
"field": "count" | |
}, | |
"fill": { | |
"field": "color" | |
}, | |
"fillOpacity": { | |
"value": 0.8 | |
}, | |
"stroke": { | |
"value": "white" | |
}, | |
"strokeWidth": { | |
"value": 1.5 | |
} | |
}, | |
"update": { | |
"x": { | |
"field": "x" | |
}, | |
"y": { | |
"field": "y" | |
} | |
} | |
} | |
}, | |
{ | |
"type": "path", | |
"name": "cell", | |
"from": { | |
"data": "nodes" | |
}, | |
"encode": { | |
"enter": { | |
"fill": { | |
"value": "transparent" | |
} | |
}, | |
"update": { | |
"path": { | |
"field": "path" | |
} | |
} | |
} | |
}, | |
{ | |
"type": "path", | |
"interactive": false, | |
"from": { | |
"data": "links" | |
}, | |
"encode": { | |
"enter": { | |
"path": { | |
"field": "path" | |
}, | |
"stroke": { | |
"value": "black" | |
}, | |
"strokeOpacity": { | |
"value": 1 | |
} | |
}, | |
"update": { | |
"path": { | |
"field": "path" | |
} | |
} | |
} | |
}, | |
{ | |
"type": "text", | |
"interactive": false, | |
"encode": { | |
"enter": { | |
"x": { | |
"signal": "width", | |
"offset": -5 | |
}, | |
"y": { | |
"signal": "height", | |
"offset": -5 | |
}, | |
"fill": { | |
"value": "#c35042" | |
}, | |
"fontSize": { | |
"value": 30 | |
}, | |
"align": { | |
"value": "right" | |
}, | |
"stroke": { | |
"value": "white" | |
}, | |
"strokeWidth": { | |
"value": 0.5 | |
} | |
}, | |
"update": { | |
"text": { | |
"signal": "title" | |
} | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment