How to print multiple text rows with vega

Hi, all

I am pretty new to the Vega world inside Kibana and was wondering if there is some easy way to simply print text fields in rows. I know that Vega is not designed to output text, nevertheless, someone knows maybe a simple solution to this?

My problem is not how to get the data from my Elastic-Search Index within Vega, but how to display the data via Scales, Axes, Marks, etc. The challenge is that my data is dynamic in terms of size inside the returned array "articles" (sometimes I have 2 titles to print and sometimes I have around 10 to print)

So what I would need would be sth. like several text sections in curly brackets inside the marks section (as in the picture below), but their number and text content has to be determined dynamically regarding the returned article titles. Has someone any idea?

I have also seen this vega word-cloud example with a transform inside the marks section. This is close to what I need
Is there something like this, but with the text displayed one below the other in a row?

Thanks!
David

Though I just checked this script in vega-editor v5, this sample may help you.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values":[
      {
        "_source":{
          "articles":[
            {"title": "a"},
            {"title": "b"}
          ]
        }
      },
      {
        "_source":{
          "articles":[
            {"title": "c"},
            {"title": "d"}
          ]
        }
      }
    ]
  },
  "transform":[
    {
      "flatten":["[_source][articles]"],
      "as":["article"]
    },
    {
     "window": [{"op":"row_number"}]
    }
  ],
  "mark":"text",
  "encoding": {
    "text":{"field":"article.title", "type": "nominal"},
    "y":{"field":"row_number","axis":null}
  }
}

image

Big thanks. That helped me a lot! :+1: :+1:

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.