I'm trying to build a word cloud using Vega and running into an issue where I can't seem to get at the data that I know is loaded. I'm not sure what value I use for the "field" references, I may also need a transform in my data section. Any suggestions would be greatly welcomed.
EDIT: I played around with my data using a bar chart and got data to display - so I've adjusted my field names accordingly, and updated my config. However, I still get nothing to display on the word cloud.
I've attached a screenshot of the javascript console showing data is in VEGA_DEBUG.
Vega Word Cloud example: https://vega.github.io/vega/examples/word-cloud/
Config:
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"title": "Twitter Word Cloud",
data: [
{
"name": "table",
url:
{
"%context%": true,
"%timefield%": "@timestamp",
"index": "twitter-cleaned-reporters-*",
"body": {
"size":0,
"aggs": {
"wordcloud": {
"terms": {
"field": "text",
"size": 50,
"exclude": ["https","the","a","t.co","of","in","and","is","on","for","that","this","it","with","i","at","was","to","be","he","his","as","but","from","are","about","has","you","have","by","an","who","what","me","says","had","our","or","no","so","if","not","new","one","we","out","just","my","said","will","up","would","news","more","they","amp","after","than","there","their","been","when","say","people","him","some","her","how","like","think","did","get","do","most","were","could","can","going","last","all","first","back","it's","here","via","also","year","your","which","because","into","next","wide","over","years","asked","she","only","rep","them","robert","story","know","it’s","other","day","make","way","being","read","great","want","should","very","those","any","still","may"]
}
}
}
}
},
"transform": [
{
"type": "formula", "as": "angle",
"expr": "[-45, 0, 45][~~(random() * 3)]"
},
{
"type": "formula", "as": "weight",
"expr": "if(datum.text=='VEGA', 600, 300)"
}
]
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "table", "field": "doc_count"},
"range": ["#d5a928", "#652c90", "#939597"]
}
],
"marks": [
{
"type": "text",
"from": {"data": "table"},
"encode": {
"enter": {
"text": {"field": "key"},
"align": {"value": "center"},
"baseline": {"value": "alphabetic"},
"fill": {"scale": "color", "field": "key"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fillOpacity": {"value": 0.5}
}
},
"transform": [
{
"type": "wordcloud",
"size": [800, 400],
"text": {"field": "key"},
"rotate": {"field": "datum.angle"},
"font": "Helvetica Neue, Arial",
"fontSize": {"field": "doc_count"},
"fontWeight": {"field": "datum.weight"},
"fontSizeRange": [12, 56],
"padding": 2
}
]
}
]
}