Y axis not rendering for Vega text table

I'm trying to create a table of data based on an aggregation. Vega is getting me part way, but when I try to format the output as a table I'm seeing different behavior from Vega in Kibana than elsewhere.

This works in the online Vega editor but when shown in Kibana it displays everything at the same point on the Y axis, without any Y axis labels.
{
"data": {
"values": [
{"a": "A","b": 1,"c":"Apple"},
{"a": "B","b": 2,"c":"Banana"},
{"a": "C","b": 3,"c":"Coconut"}
]
},
"encoding": {
"y": {"field": "a", "type": "ordinal"}
},
"layer": [ {
"mark": {
"type": "text",
"align": "right",
"baseline": "middle",
"dx": 0
},
"encoding": {
"text": {"field": "b", "type": "quantitative"}
}
},
{
"mark": {
"type": "text",
"align": "right",
"baseline": "middle",
"dx": 100
},
"encoding": {
"text": {"field": "c", "type": "ordinal"}
}
}]
}

Of course, I started with an Elasticsearch query but have removed that for simplicity.

Any help would be greatly appreciated.

I have this working now. I've switched to full Vega from Vega-lite. Some of this is from a Google Group Post and I'm still not sure how much of it is required, but this works:

{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"config": {"title": {"offset": 20, "fontSize": 16}},
"title": {"text": "Outstanding Balances"},
"padding": 10,
"autosize": {"type": "pad"},
"data": [
 {
  "name": "esHavingQuery",
  "url": {
    "%context%": true,
    "%timefield%": "@timestamp",
    "index": "transaction*",
    "body": {
      "size": 0,
      "aggregations": {
        "perCart": {
          "terms": {"script": {"source": "doc['cart_id'].value.substring(0,8).toUpperCase();"}},
          "aggregations": {
            "net": {"sum": {"field": "ticket.after_fees_price"}},
            "balance_owing": {
              "bucket_selector": {
                "buckets_path": {"NetOwing": "net"},
                "script": "params.NetOwing > 0"
              }
            }
          }
        }
      }
    }
  },
  "format": {"property": "aggregations.perCart.buckets"},
  "transform": [
    {"type": "formula", "as": "x_position", "expr": "width * 1 / 3"},
    {"type": "formula", "as": "line_height", "expr": "20"},
    {"type": "formula", "as": "outstanding_balance", "expr": "format(datum.net.value,'$.2f')"},
    {"type": "stack", "groupby": ["x_position"], "field": "line_height", "as": ["y0", "y1"]}
  ]
},
{"name": "Header", "values": [{"column1": "Cart Number", "column2": "Balance"}]}
],
"marks": [
 {
  "type": "text",
  "from": {"data": "Header"},
  "encode": {
    "enter": {
      "x": 0,
      "y": {"field": "y0"},
      "align": {"value": "left"},
      "text": {"field": "column1"},
      "fontSize": {"value": 14}
    }
  }
},
{
  "type": "text",
  "from": {"data": "Header"},
  "encode": {
    "enter": {
      "x": {"offset": 200},
      "y": {"field": "y0"},
      "align": {"value": "right"},
      "text": {"field": "column2"},
      "fontSize": {"value": 14}
    }
  }
},
{
  "type": "text",
  "from": {"data": "esHavingQuery"},
  "encode": {
    "enter": {
      "x": 0,
      "y": {"field": "y0", "offset": 25},
      "align": {"value": "left"},
      "text": {"field": "key"}
    }
  }
},
{
  "type": "text",
  "from": {"data": "esHavingQuery"},
  "encode": {
    "enter": {
      "x": {"offset": 200},
      "y": {"field": "y0", "offset": 25},
      "align": {"value": "right"},
      "text": {"field": "outstanding_balance"}
    }
  }
  }
  ]
}
1 Like

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