Skip to main content

Scaling nodes

Let's scale nodes based on their degree.

Visualization

NetPanorama specification


{
"data": [
{
"name": "players",
"format": {"type": "csv"},
"url": "/data/tulip/chess.candidates.1948.1990.csv",
"transform": [
{"type": "addIndex", "as": "id"},
{"type": "geocode", "locationField": "Birth Place" }
]
},
{
"name": "games",
"format": {"type": "csv"},
"url": "/data/tulip/wcc.games.1948.1990.csv"
}
],

"networks": [
{
"name": "net",
"nodes": "players",
"links": "games",
"directed": false,
"source_node": [ "Name", "Player 1" ],
"target_node": [ "Name", "Player 2" ],

"transform": [
{"type": "filterNodes", "expression": "datum.Status == '2' "},

Calculate the degree for each node.


{"type": "metric", "metric": "degree"}


]
}
],



"maps": [
{
"name": "my_map",
"tiles": "Stamen_TerrainBackground",
"zoomLevel": 3,
"center": [51.5062, -0.1263]
}
],

"layouts": [
{
"name": "net-layout",
"network": "net",

"map": "my_map",
"lat": {"field": "lat"},
"lng": {"field": "lon"}
}

],

Define a scale to map degree to node area...


"scales": [
{
"name": "area",
"type": "sqrt",
"range": [40, 1000],
"domain": [0, 6]
}
],



"vis": [
{
"entries": "net.links",
"layout": "net-layout",
"mark": {
"type": "linkpath",
"start": "source",
"end": "target"
}
},
{
"entries": "net.nodes",
"layout": "net-layout",
"mark": {
"type": "circle",

...and use this to set the area of each node


"area": {"field": "degree", "scale": "area"},


"fill": "steelblue",
"tooltip": { "expression": "datum.Name + ' (degree ' + datum.degree + ')' " }
}
},


{

"mark":{
"type": "map",
"map": "my_map"
},

},

]

}