{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"height": 410,
"padding": 5,
"autosize": "fit",
"signals": [
{
"name": "Auteurs", "value": 12,
"bind": {"input": "range", "min": 3, "max": 30, "step": 1}
}
],
"title": {
"text": "Aantal publicaties",
"anchor": "start",
"frame": "group"
},
"data": [
{
"name": "source",
"values": [
{"auteur": "Niels Lafleur"},
{"auteur": "Marc Jansen"},
{"auteur": "Rolf Waterman"},
{"auteur": "Jules Verne"},
{"auteur": "J.K. Rowling"},
{"auteur": "Johan Ansink"},
{"auteur": "J.K. Rowling"},
{"auteur": "Johan Ansink"},
{"auteur": "John Doe"},
{"auteur": "TestNaam"},
{"auteur": "John Doe"},
{"auteur": "TestNaam"},
{"auteur": "John Doe"},
{"auteur": "TestNaam"},
{"auteur": "John Doe"},
{"auteur": "TestNaam"},
{"auteur": "Marc Jansen twee"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Marc Jansen de derde"},
{"auteur": "Test 5"},
{"auteur": "Nieuwe medewerker"},
{"auteur": "Marc Jansen de tweede"},
{"auteur": "ttt"},
{"auteur": "testt"},
{"auteur": "Piet Jan"}
]
},
{
"name": "ranks",
"source": "source",
"transform": [
{
"type": "aggregate",
"groupby": ["auteur"],
"as": ["publicaties"]
},
{
"type": "window",
"sort": {"field": "publicaties", "order": "descending"},
"ops": ["row_number"], "as": ["rank"]
}
]
},
{
"name": "authors",
"source": "source",
"transform": [
{
"type": "lookup",
"from": "ranks",
"key": "auteur",
"values": ["rank"],
"fields": ["auteur"]
},
{
"type": "formula",
"as": "name",
"expr": "datum.rank < Auteurs ? datum.auteur : 'All Others'"
},
{
"type": "aggregate",
"groupby": ["name"],
"ops": ["count"],
"fields": ["publicaties"],
"as": ["publicaties"]
},
{"type": "filter", "expr": "datum.name != 'All Others'"}
]
}
],
"marks": [
{
"type": "rect",
"from": {"data": "authors"},
"encode": {
"update": {
"x": {"scale": "x", "value": 0},
"x2": {"scale": "x", "field": "publicaties"},
"y": {"scale": "y", "field": "name"},
"fill":{"scale":"color", "field":"publicaties"},
"height": {"scale": "y", "band": 1},
"tooltip": {"signal": "{'Naam':(datum.name),'Aantal publicaties': (datum.publicaties)}"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {"data": "authors", "field": "publicaties"},
"range": "width",
"nice": true
},
{
"name": "y",
"type": "band",
"domain": {
"data": "authors", "field": "name",
"sort": {"op": "max", "field": "publicaties", "order": "descending"}
},
"range": "height",
"padding": 0.1
},
{
"name": "color",
"type": "linear",
"range": {"scheme": "greenblue"},
"domain": {"data": "authors", "field": "publicaties"}
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"format": "d",
"tickMinStep":1
},
{
"scale": "y",
"orient": "left",
"offset": 5
}
]
}