# Y axis not rendering for Vega text table

**URL:** https://discuss.elastic.co/t/y-axis-not-rendering-for-vega-text-table/126832
**Category:** Kibana
**Created:** [April 5, 2018, 3:23am UTC](https://discuss.elastic.co/t/y-axis-not-rendering-for-vega-text-table/126832 "2018-04-05T03:23:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Steven\_Ensslen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steven_ensslen/32/26984_2.png) [@Steven\_Ensslen](https://discuss.elastic.co/u/Steven_Ensslen)
#### Post date: [April 5, 2018, 3:23am UTC](https://discuss.elastic.co/t/y-axis-not-rendering-for-vega-text-table/126832/1 "2018-04-05T03:23:34Z")

</div>

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](https://vega.github.io/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.

---

<div class="post-metadata">

### Author: ![Steven\_Ensslen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steven_ensslen/32/26984_2.png) [@Steven\_Ensslen](https://discuss.elastic.co/u/Steven_Ensslen)
#### Post date: [April 8, 2018, 3:04am UTC](https://discuss.elastic.co/t/y-axis-not-rendering-for-vega-text-table/126832/2 "2018-04-08T03:04:34Z")

</div>

I have this working now. I've switched to full Vega from Vega-lite. Some of this is from [a Google Group Post](https://groups.google.com/forum/#!topic/vega-js/t1KW3AcfXeU) 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"}
    }
  }
  }
  ]
}
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 6, 2018, 3:05am UTC](https://discuss.elastic.co/t/y-axis-not-rendering-for-vega-text-table/126832/3 "2018-05-06T03:05:10Z")

</div>

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