# Vega vertical bar chart: Inline data vs elasticsearch index url data

**URL:** <https://discuss.elastic.co/t/vega-vertical-bar-chart-inline-data-vs-elasticsearch-index-url-data/171546>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 8, 2019, 7:07pm UTC](https://discuss.elastic.co/t/vega-vertical-bar-chart-inline-data-vs-elasticsearch-index-url-data/171546 "2019-03-08T19:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgolubov55](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mgolubov55](https://discuss.elastic.co/u/mgolubov55)\
**Post date:** [March 8, 2019, 7:07pm UTC](https://discuss.elastic.co/t/vega-vertical-bar-chart-inline-data-vs-elasticsearch-index-url-data/171546/1 "2019-03-08T19:07:50Z")

</div>

I created a simple index:

 ![IndexCreate](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c21d1bf280965f313af603feef2d105dc3b66f59.jpeg)

1. Testing vs inline data - the following works:  

2. The following does not work - Why? - complete source code will follow the illustration.  

Here is the complete source code:  
{  
"$schema": "[https://vega.github.io/schema/vega/v3.json](https://vega.github.io/schema/vega/v3.json)",  
"width": 400,  
"height": 200,  
"padding": 5,  
"autosize": "pad",

"data": [  
{  
"name": "table",

```
  /* "values": [
    {"category": "A", "amount": 28},
    {"category": "B", "amount": 55},
    {"category": "C", "amount": 43},
    {"category": "D", "amount": 91},
    {"category": "E", "amount": 81},
    {"category": "F", "amount": 53},
    {"category": "G", "amount": 19},
    {"category": "H", "amount": 87}
  ] */
  
  "url": { 
  // %context%: true
  // %timefield%: @timestamp
  index: my_newindex
  body: {
    size: 1000
    _source: ["category", "amount"]
    } 
  }
  
}

```

],

"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}  
]  
}  
}  
}  
]  
}

---

<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:** [March 8, 2019, 7:18pm UTC](https://discuss.elastic.co/t/vega-vertical-bar-chart-inline-data-vs-elasticsearch-index-url-data/171546/2 "2019-03-08T19:18:48Z")

</div>

@nyuricks can you please take a stab at it ?

Thanks  
Rashmi

---

<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:** [April 5, 2019, 7:33pm UTC](https://discuss.elastic.co/t/vega-vertical-bar-chart-inline-data-vs-elasticsearch-index-url-data/171546/3 "2019-04-05T19:33:18Z")

</div>

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