# Vega visualization Kibana fields

**URL:** <https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948>\
**Category:** Kibana\
**Created:** [April 5, 2018, 2:20pm UTC](https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948 "2018-04-05T14:20:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sneijky](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sneijky](https://discuss.elastic.co/u/Sneijky)\
**Post date:** [April 5, 2018, 2:20pm UTC](https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948/1 "2018-04-05T14:20:28Z")

</div>

Hello.

I'm trying to obtain a visualization in Kibana using Vega. For this visualization I'm using Kibana getting started guide with the bank data with some added fields. The data goes like this:

{"index":{"\_id":"6"}}  
{"account\_number":6,"balance":5686,"balanceAvailable":5000,"limit":1000,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol [Street","employer":"Netagy","email":"hattiebond@netagy.com](mailto:Street%22,%22employer%22:%22Netagy%22,%22email%22:%22hattiebond@netagy.com)","city":"Dante","state":"TN"}  
{"index":{"\_id":"13"}}  
{"account\_number":13,"balance":32838,"balanceAvailable":32838,"limit":1000,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison [Street","employer":"Quility","email":"nanettebates@quility.com](mailto:Street%22,%22employer%22:%22Quility%22,%22email%22:%22nanettebates@quility.com)","city":"Nogal","state":"VA"}  
{"index":{"\_id":"18"}}  
{"account\_number":18,"balance":4180,"balanceAvailable":32838,"limit":1000,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson [Court","employer":"Boink","email":"daleadams@boink.com](mailto:Court%22,%22employer%22:%22Boink%22,%22email%22:%22daleadams@boink.com)","city":"Orick","state":"MD"}

So far I have this in Vega:

```
{
  "$schema": "https://vega.github.io/schema/vega/v3.json",
  "width": 400,
  "height": 200,
  "padding": 5,

  "data": [
    {
      "name": "table",
      "values": [
        {"category": "Balance", "amount": 5686},
        {"category": "BalanceAvailable", "amount":686},
        {"category": "limit", "amount": 1000},
      ]
    }
  ],

  "signals": [
    {
      "name": "tooltip",
      "value": {},
      "on": [
        {"events": "rect:mouseover", "update": "datum"},
        {"events": "rect:mouseout", "update": "{}"}
      ]
    }
  ],

  "scales": [
    {
      "name": "xscale",
      "type": "band",
      "domain": {"data": "table", "field": "category"},
      "range": "width",
      "padding": 0.05,
      "round": true
    },
    {
      "name": "yscale",
      "domain": {"data": "table", "field": "amount"},
      "nice": true,
      "range": "height"
    }
  ],

  "axes": [
    { "orient": "bottom", "scale": "xscale" },
    { "orient": "left", "scale": "yscale" }
  ],

  "marks": [
    {
      "type": "rect",
      "from": {"data":"table"},
      "encode": {
        "enter": {
          "x": {"scale": "xscale", "field": "category"},
          "width": {"scale": "xscale", "band": 1},
          "y": {"scale": "yscale", "field": "amount"},
          "y2": {"scale": "yscale", "value": 0}
        },
        "update": {
          "fill": {"value": "steelblue"}
        },
        "hover": {
          "fill": {"value": "red"}
        }
      }
    },
    {
      "type": "text",
      "encode": {
        "enter": {
          "align": {"value": "center"},
          "baseline": {"value": "bottom"},
          "fill": {"value": "#333"}
        },
        "update": {
          "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
          "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
          "text": {"signal": "tooltip.amount"},
          "fillOpacity": [
            {"test": "datum === tooltip", "value": 0},
            {"value": 1}
          ]
        }
      }
    }
  ]
}

```

 ![example](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1b3fc695183060e098181d32e95183276d7871e5.png)

What i'm trying to do is to replace the hardcoded values in data with the ones in the index, so I can have real time analysis. I know that might not be possible to select the exact values I want, I just want to be able to select the fields so later I can have a filter with the bank account.  
Any suggestion?Thanks

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [April 5, 2018, 3:06pm UTC](https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948/2 "2018-04-05T15:06:22Z")

</div>

cc @nyuriks might take a look at this when he gets some time.

Cheers  
Rashmi

---

<div class="post-metadata">

**Author:** ![emil.mirzayev](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@emil.mirzayev](https://discuss.elastic.co/u/emil.mirzayev)\
**Post date:** [April 9, 2018, 7:50am UTC](https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948/3 "2018-04-09T07:50:54Z")

</div>

Hi @Sneijky, what exactly you want to visualize? The data you show from Elastic is a bit unclear to me.  
There is [this](https://www.youtube.com/watch?v=4xAO01xCBpQ) Youtube guide by @timroes where he shows how to make a scatterplot on Vega using Elastic data. Also, [this blog](https://nyurik.github.io/Vega-Trends-Graph-for-Kibana/) is about more advanced usage. I would advice you to use first Vega-lite as it is higher level and easier to deal with.

---

<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 7, 2018, 7:51am UTC](https://discuss.elastic.co/t/vega-visualization-kibana-fields/126948/4 "2018-05-07T07:51:01Z")

</div>

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