Weird XY data ouput with Vega Lite

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? :frowning:

{
  "$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

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

Thanks in advance :slight_smile:

And...

image

1 Like

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

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.

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