VegaLite Code Error: Cannot convert undefined or null to object

System Specifications:
Kibana Version: 8.8.2
Elastic Search Version: 8.8.2
Environment: local (Mac OS arm64)

I am new to vega. I am trying to create a Gantt chart visualisation using vega code but for some reason the code returns the error:
Cannot convert undefined or null to object
Here's the vega code I wrote:

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "description": "A Gantt chart representing the availability of different datasets over time.",
  "padding": 5,
  "autosize": "fit",
  "data": [
    {
      "name": "table",
      "url": {
        // Specify the Elasticsearch index to query
        "index": "availability-index",
        "body": {
          "size": 10000,
          "_source": ["start_timestamp", "end_timestamp", "dataset_name", "is_available"],
          // Define any query here. For a full time range, you can use a match_all query
          "query": {
            "match_all": {}
          }
        }
      },
      // Use Elasticsearch's _source field to extract the values
      "format": { "property": "hits.hits._source" },
      "transform": [
        {
          "type": "formula",
          "as": "start_date",
          "expr": "toDate(datum.start_timestamp)"
        },
        {
          "type": "formula",
          "as": "end_date",
          "expr": "toDate(datum.end_timestamp)"
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "yscale",
      "type": "band",
      "domain": {
        "data": "table",
        "field": "dataset_name"
      },
      "range": "height",
      "padding": 0.2
    },
    {
      "name": "xscale",
      "type": "time",
      "domain": {
        "data": "table",
        "fields": ["start_date", "end_date"]
      },
      "range": "width"
    },
    {
      "name": "color",
      "type": "ordinal",
      "domain": [true, false],
      "range": ["#85C1E9", "#E74C3C"]
    }
  ],
  "axes": [
    {
      "orient": "bottom",
      "scale": "xscale",
      "title": "Time"
    },
    {
      "orient": "left",
      "scale": "yscale",
      "title": "Datasets"
    }
  ],
  "marks": [
    {
      "type": "rect",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "y": {"scale": "yscale", "field": "dataset_name"},
          "height": {"scale": "yscale", "band": 1},
          "x": {"scale": "xscale", "field": "start_date"},
          "x2": {"scale": "xscale", "field": "end_date"},
          "fill": {"scale": "color", "field": "is_available"}
        }
      }
    }
  ],
  "legends": [
    {
      "title": "Availability",
      "fill": "color",
      "orient": "right"
    }
  ]
}

The data when curling the index:

{"took":7,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":2,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"availability_index","_id":"-B2Qq4sBm7775WK2vuVm","_score":1.0,"_source":{"data_product_id": "c6c029b9-37d3-4906-a554-a31f221cde31", "data_product_name": "diana-test-1", "dataset_name": "test", "is_materialized": true, "is_available": false, "start_timestamp": "2023-11-07T14:11:07.241817", "end_timestamp": "2023-11-07T14:21:07.241817"}},{"_index":"availability_index","_id":"-R2Qq4sBm7775WK2vuXR","_score":1.0,"_source":{"data_product_id": "81c9a257-b754-472f-9dcc-81f9914cb156", "data_product_name": "minioconnection", "dataset_name": "minioconnection", "is_materialized": false, "is_available": false, "start_timestamp": "2023-11-07T14:11:07.241817", "end_timestamp": "2023-11-07T14:21:07.241817"}}]}}

Any help would be highly appreciated

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