# Weird XY data ouput with Vega Lite

**URL:** <https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [December 11, 2020, 3:18am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356 "2020-12-11T03:18:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganymede](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Ganymede](https://discuss.elastic.co/u/Ganymede)\
**Post date:** [December 11, 2020, 3:18am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356/1 "2020-12-11T03:18:29Z")

</div>

Hello everyone,

I'm sure someone can point out my stupid error. I'm quite new to Vega Lite, slightly getting the hang of it.

Everything is working fine except that my numeric data and time data are mixed up as it seems. How can I fix this?

I know it's not a simple matter of sort:"". Setting the type of numericData to "quantitative" lets the data disappear for some reason. Maybe because they are integers? ☹

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "url": {
      "%context%": true,
      "%timefield%": "@timestamp",
      "index": "default-*",
      "body": {"size": 100, "_source": ["numericData", "@timestamp"]}
    },
    "format": {"property": "hits.hits"}
  },
  "transform": [
    {"calculate": "toDate(datum._source['@timestamp'])", "as": "time"}
  ],
  "vconcat": [
    {
      "width": 1200,
      "mark": "area",
      "encoding": {
        "x": {
          "field": "time",
          "scale": {"domain": {"selection": "brush"}},
          "type": "temporal",
          "axis": {"title": ""}
        },
        "y": {"field": "_source.numericData"}
      }
    },
    {
      "width": 1200,
      "height": 60,
      "mark": "area",
      "selection": {"brush": {"type": "interval", "encodings": ["x"]}},
      "encoding": {
        "x": {"field": "time", "type": "temporal"},
        "y": {
          "field": "_source.numericData",
          "axis": {"tickCount": 3, "grid": false}
        }
      }
    }
  ]
}

```

This illustrates my output - time and intensity (0-10ish) are correct. The ordering is odd though.

![image](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5ce4a4c932f60a4901fff0b6eb504ecd33cea73c.png)

How can I reorder the values for a correct intensity-time correlation?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![brunet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brunet/32/80525_2.png) [@brunet](https://discuss.elastic.co/u/brunet)\
**Post date:** [December 11, 2020, 8:23am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356/2 "2020-12-11T08:23:21Z")

</div>

> [@Ganymede](#):
>
> `"y": {"field": "_source.numericData", "type": "quantitative"}`

And...

![image](https://us1.discourse-cdn.com/elastic/original/3X/2/1/2197dda78b7823ae13e7978826714074a63c7e9e.png)

---

<div class="post-metadata">

**Author:** ![Ganymede](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Ganymede](https://discuss.elastic.co/u/Ganymede)\
**Post date:** [December 11, 2020, 9:31am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356/3 "2020-12-11T09:31:45Z")

</div>

When I set y to quantitative no green diagram appears. Empty xy diagram or invisible due to a bug?

---

<div class="post-metadata">

**Author:** ![Ganymede](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Ganymede](https://discuss.elastic.co/u/Ganymede)\
**Post date:** [December 23, 2020, 11:36am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356/4 "2020-12-23T11:36:13Z")

</div>

Thanks for the suggestion. I didn't post any data with it so it was hard to track down but thanks again for responding.

In the end a filter for values that are `> 0` or `!= null` did the trick.

---

<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:** [January 20, 2021, 11:36am UTC](https://discuss.elastic.co/t/weird-xy-data-ouput-with-vega-lite/258356/5 "2021-01-20T11:36:17Z")

</div>

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