# Use static data in Vega Visualisation

**URL:** https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955
**Category:** Kibana
**Created:** [July 6, 2020, 4:43am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955 "2020-07-06T04:43:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![biplabd67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/biplabd67/32/71653_2.png) [@biplabd67](https://discuss.elastic.co/u/biplabd67)
#### Post date: [July 6, 2020, 4:43am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955/1 "2020-07-06T04:43:29Z")

</div>

I would like to use a static set of data instead of a url query to evaluate a Vega code I am trying to design.  
Somehow I am not able to use the static data , any help or assistance pointer would be appreciated.

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [July 6, 2020, 7:00am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955/2 "2020-07-06T07:00:37Z")

</div>

Can you show what you tried? Vega offers different ways to specify data, with directly specifying the `values` being the simplest one - e.g. this example grabbed from the vega home page:

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "description": "A basic bar chart example, with value labels shown upon mouse hover.",
  "width": 400,
  "height": 200,
  "padding": 5,

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

  "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: ![biplabd67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/biplabd67/32/71653_2.png) [@biplabd67](https://discuss.elastic.co/u/biplabd67)
#### Post date: [July 10, 2020, 5:50am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955/3 "2020-07-10T05:50:51Z")

</div>

Hi Joe,

Basically I was trying to work with the example from Vega "[https://vega.github.io/vega/examples/force-directed-layout/](https://vega.github.io/vega/examples/force-directed-layout/)" , but using local data.  
I am frankly lost.  
Once I make this work , I would move on to do a "url" based live query.

Regards

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [July 10, 2020, 6:37am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955/4 "2020-07-10T06:37:28Z")

</div>

See my example above - you can just inline the data as “values” in the spec

---

<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: [August 7, 2020, 6:37am UTC](https://discuss.elastic.co/t/use-static-data-in-vega-visualisation/239955/5 "2020-08-07T06:37:29Z")

</div>

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