# How to plot (raw) data, Using Vega

**URL:** https://discuss.elastic.co/t/how-to-plot-raw-data-using-vega/238259
**Category:** Kibana
**Created:** [June 23, 2020, 12:43pm UTC](https://discuss.elastic.co/t/how-to-plot-raw-data-using-vega/238259 "2020-06-23T12:43:26Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![defalt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/defalt/32/71379_2.png) [@defalt](https://discuss.elastic.co/u/defalt)
#### Post date: [June 26, 2020, 8:44am UTC](https://discuss.elastic.co/t/how-to-plot-raw-data-using-vega/238259/5 "2020-06-26T08:44:53Z")

</div>

Thanks @timroes for your help yesterday. I tried to change your script so that I can import data from elasticsearch but it doesn't work. Do you know what I did wrong?

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v4.3.json",
  "description": "A basic line chart example.",
  "padding": 5,
  
  data: {
  name:"table"
    url: {
      %context%: true
      %timefield%: timestamp
      index: modbusdata_new
      body: {
        size: 10000,
        _source: ["timestamp", "T107","C106"]
      },
    }
  }
    transform: [
    {
      calculate: "toDate(datum._source['timestamp'])"
      as: "time"
    }
  ],
  
  "scales": [
    {
      "name": "timex", //Changed the scale names so that I wouldnt confuse the y scale with the y value and so on
      "type": "time",
      "range": "width",
      "domain": {"data": "table", "field": "time"}
    },
    {
      "name": "NameT107",
      "type": "linear",
      "range": "height",
      "nice": true,
      "zero": true,
      "domain": {"data": "table", "field": "_source.T107"} // "_source.['T107']" or "T107" doesn't work either
    },
    {
      "name": "NameC107",
      "type": "linear",
      "range": "height",
      "nice": true,
      "zero": true,
      "domain": {"data": "table", "field": "_source.C106"}
    }
  ],
  "axes": [
    {"orient": "bottom", "scale": "timex", "format": "%H:%m"},
    {"orient": "left", "scale": "NameT107"},
    {
      "orient": "left",
      "scale": "NameC107",
      "offset": 30,
      "domainColor": "#FF00FF",
      "labelColor": "#FF00FF",
      "tickColor": "#FF00FF"
    }
  ],
  "marks": [
    {
      "type": "line",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "x": {"scale": "timex", "field": "time"},
          "y": {"scale": "NameT107", "field": "_source.T107"}
        }
      }
    },
    {
      "type": "line",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "x": {"scale": "timex", "field": "time"},
          "y": {"scale": "NameC107", "field": "_source.C106"},
          "stroke": {"value": "#FF00FF"}
        }
      }
    }
  ]
}

```

I get the error: `Cannot read property 'T107' of undefined`.  
If I change the line `"domain": {"data": "table", "field": "_source.T107"} `  
to `"domain": {"data": "table", "field": "Whatever"} ` the error changes to `Cannot read property 'Whatever' of undefined`.

The output of F12-\>Console as [requested](https://discuss.elastic.co/t/visualize-cannot-read-property-some-of-undefined/134374/4) is:

```auto
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.

```

but below it it says: ` A single error about an inline script not firing due to content security policy is expected!`  
Haven't found a solution for this. Any ideas?  
Thanks,  
defalt.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-plot-raw-data-using-vega/238259)._
