Error while creating Parallel coordinate in Vega - "Cannot read properties of undefined (reading 'key')"

Hello everyone,
I am trying to create parallel coordinates for my timeseries data. I am first querying to get wanted fields and then trying to use them for scale and axis plotting.
But I am receiving properties undefined error.

Expected Output:

  • First parallel line should have Brand name, second product ID and third should be Product name
  • All line should have there particular data.
  • and respective data should connect other line data.

Code:

Code used:

{
  $schema: https://vega.github.io/schema/vega/v5.json
  description: Parallel coordinates plot showing 3dimensions of product statistics.
  data: [
    {
      name: pro
      url: {
        %context%: true
        %timefield%: @timestamp
        index: selling_data*
        body: {
          aggs: {
            brand_name: {
              terms: {
                field: brand.name
              }
              aggs: {
                prod_id: {
                  terms: {
                    field: ProductId
                  }
                  aggs: {
                    prod: {
                      top_hits: {
                        _source: {
                          includes: ProductName
                        }
                        size: 1
                      }
                    }
                  }
                }
              }
            }
          }
          size: 0
        }
      }
      format: {
        property: aggregations.brand_name.buckets
      }
      transform: [
        {
          type: filter
          expr: datum.key
        }
      ]
    }
    {
      name: fields
      values: [
        Brand_Name
        Product_ID
        Product
      ]
    }
  ]
  scales: [
    {
      name: ord
      type: point
      range: width
      round: true
      domain: {
        data: fields
        field: data
      }
    }
    {
      name: Brand_Name
      type: ordinal
      range: height
      zero: false
      nice: true
      domain: {
        data: pro
        field: datum.key
      }
    }
    {
      name: Prod_ID
      type: ordinal
      range: height
      zero: false
      nice: true
      domain: {
        data: pro
        field: datum.prod_id.buckets.key
      }
    }
    {
      name: Product
      type: ordinal
      range: height
      zero: false
      nice: true
      domain: {
        data: pro
        field: datum.prod_id.buckets.app.hits.hits._source.ProductName
      }
    }
  ]
  axes: [
    {
      orient: left
      zindex: 1
      scale: Brand_Name
      title: Brand_Name
      offset: {
        scale: ord
        value: Brand_Name
        mult: -1
      }
    }
    {
      orient: left
      zindex: 1
      scale: Prod_ID
      title: Prod_ID
      offset: {
        scale: ord
        value: Product_ID
        mult: -1
      }
    }
    {
      orient: left
      zindex: 1
      scale: Product
      title: Product
      offset: {
        scale: ord
        value: Product
        mult: -1
      }
    }
  ]
  marks: [
    {
      type: group
      from: {
        data: pro
      }
      marks: [
        {
          type: line
          from: {
            data: fields
          }
          encode: {
            enter: {
              x: {
                scale: ord
                field: data
              }
              y: {
                scale: {
                  datum: data
                }
                field: {
                  parent: {
                    datum: data
                  }
                }
              }
              stroke: {
                value: steelblue
              }
              strokeWidth: {
                value: 1.01
              }
              strokeOpacity: {
                value: 0.3
              }
            }
          }
        }
      ]
    }
  ]
}

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